unsigned int leb128_tmp;
unsigned int cie_usage_count, last_cie_ndx, i, offset;
unsigned int make_relative, make_lsda_relative;
- Elf_Internal_Rela *rel;
bfd_size_type new_size;
unsigned int ptr_size;
+ ((buf - ehbuf + per_width - 1)
& ~((bfd_size_type) per_width - 1)));
ENSURE_NO_RELOCS (buf);
- rel = GET_RELOC (buf);
/* Ensure we have a reloc here, against
a global symbol. */
- if (rel != NULL)
+ if (GET_RELOC (buf) != NULL)
{
unsigned long r_symndx;
goto free_no_table;
ENSURE_NO_RELOCS (buf);
- rel = GET_RELOC (buf);
- if (rel == NULL)
+ if (GET_RELOC (buf) == NULL)
/* This should not happen. */
goto free_no_table;
if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie))
be deleted. */
new_size -= hdr.length + 4;
sec_info->entry[sec_info->count].removed = 1;
- memset (rel, 0, sizeof (*rel));
}
else
{
cie_usage_count++;
hdr_info->fde_count++;
}
- cookie->rel = rel;
if (cie.lsda_encoding != DW_EH_PE_omit)
{
unsigned int dummy;
asection *sec;
{
struct eh_frame_hdr_info *hdr_info;
- unsigned int ptr_size;
-
- ptr_size = (elf_elfheader (abfd)->e_ident[EI_CLASS]
- == ELFCLASS64) ? 8 : 4;
if ((elf_section_data (sec)->sec_info_type
!= ELF_INFO_TYPE_EH_FRAME_HDR)
asection *sec;
{
struct eh_frame_hdr_info *hdr_info;
- unsigned int ptr_size;
bfd_byte *contents;
asection *eh_frame_sec;
bfd_size_type size;
- ptr_size = (elf_elfheader (sec->owner)->e_ident[EI_CLASS]
- == ELFCLASS64) ? 8 : 4;
-
BFD_ASSERT (elf_section_data (sec)->sec_info_type
== ELF_INFO_TYPE_EH_FRAME_HDR);
hdr_info = (struct eh_frame_hdr_info *)
Elf_Internal_Shdr *symtab_hdr;
struct elf_backend_data *bed;
bfd *abfd;
+ unsigned int count;
boolean ret = false;
- boolean strip = info->strip == strip_all || info->strip == strip_debugger;
if (info->relocateable
|| info->traditional_format
continue;
eh = NULL;
- if (ehdr)
+ if (ehdr != NULL)
{
eh = bfd_get_section_by_name (abfd, ".eh_frame");
- if (eh && (eh->_raw_size == 0
- || bfd_is_abs_section (eh->output_section)))
+ if (eh != NULL
+ && (eh->_raw_size == 0
+ || bfd_is_abs_section (eh->output_section)))
eh = NULL;
}
- stab = NULL;
- if (!strip)
- {
- stab = bfd_get_section_by_name (abfd, ".stab");
- if (stab && (stab->_raw_size == 0
- || bfd_is_abs_section (stab->output_section)))
- stab = NULL;
- }
- if ((! stab
- || elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS)
- && ! eh
- && (strip || ! bed->elf_backend_discard_info))
+ stab = bfd_get_section_by_name (abfd, ".stab");
+ if (stab != NULL
+ && (stab->_raw_size == 0
+ || bfd_is_abs_section (stab->output_section)
+ || elf_section_data (stab)->sec_info_type != ELF_INFO_TYPE_STABS))
+ stab = NULL;
+
+ if (stab == NULL
+ && eh == NULL
+ && bed->elf_backend_discard_info == NULL)
continue;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
cookie.bad_symtab = elf_bad_symtab (abfd);
if (cookie.bad_symtab)
{
- cookie.locsymcount =
- symtab_hdr->sh_size / sizeof (Elf_External_Sym);
+ cookie.locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
cookie.extsymoff = 0;
}
else
return false;
}
- if (stab)
+ if (stab != NULL)
{
- cookie.rels = (NAME(_bfd_elf,link_read_relocs)
- (abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL,
- info->keep_memory));
- if (cookie.rels)
+ cookie.rels = NULL;
+ count = stab->reloc_count;
+ if (count != 0)
+ cookie.rels = (NAME(_bfd_elf,link_read_relocs)
+ (abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+ info->keep_memory));
+ if (cookie.rels != NULL)
{
cookie.rel = cookie.rels;
- cookie.relend =
- cookie.rels + stab->reloc_count * bed->s->int_rels_per_ext_rel;
+ cookie.relend = cookie.rels;
+ cookie.relend += count * bed->s->int_rels_per_ext_rel;
if (_bfd_discard_section_stabs (abfd, stab,
elf_section_data (stab)->sec_info,
elf_reloc_symbol_deleted_p,
}
}
- if (eh)
+ if (eh != NULL)
{
cookie.rels = NULL;
- cookie.rel = NULL;
- cookie.relend = NULL;
- if (eh->reloc_count)
+ count = eh->reloc_count;
+ if (count != 0)
cookie.rels = (NAME(_bfd_elf,link_read_relocs)
(abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL,
info->keep_memory));
- if (cookie.rels)
- {
- cookie.rel = cookie.rels;
- cookie.relend =
- cookie.rels + eh->reloc_count * bed->s->int_rels_per_ext_rel;
- }
+ cookie.rel = cookie.rels;
+ cookie.relend = cookie.rels;
+ if (cookie.rels != NULL)
+ cookie.relend += count * bed->s->int_rels_per_ext_rel;
+
if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, ehdr,
elf_reloc_symbol_deleted_p,
&cookie))
- {
- /* Relocs have been edited. Ensure edited version is
- used later in relocate_section. */
- elf_section_data (eh)->relocs = cookie.rels;
- ret = true;
- }
- if (cookie.rels && elf_section_data (eh)->relocs != cookie.rels)
+ ret = true;
+
+ if (cookie.rels != NULL
+ && elf_section_data (eh)->relocs != cookie.rels)
free (cookie.rels);
}
- if (bed->elf_backend_discard_info)
- {
- if (bed->elf_backend_discard_info (abfd, &cookie, info))
- ret = true;
- }
+ if (bed->elf_backend_discard_info != NULL
+ && (*bed->elf_backend_discard_info) (abfd, &cookie, info))
+ ret = true;
if (cookie.locsyms != NULL
&& symtab_hdr->contents != (unsigned char *) cookie.locsyms)
}
}
- if (ehdr && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr))
+ if (ehdr != NULL
+ && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr))
ret = true;
+
return ret;
}
{
Elf_Internal_Rela outrel;
- offset += sec->output_section->vma + sec->output_offset;
-
BFD_ASSERT (dynindx != -1);
outrel.r_info = ELFNN_R_INFO (dynindx, type);
outrel.r_addend = addend;
outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset);
- if ((outrel.r_offset | 1) == (bfd_vma) -1)
+ if (outrel.r_offset >= (bfd_vma) -2)
{
/* Run for the hills. We shouldn't be outputting a relocation
for this. So do what everyone else does and output a no-op. */
outrel.r_addend = 0;
outrel.r_offset = 0;
}
+ else
+ outrel.r_offset += sec->output_section->vma + sec->output_offset;
bfd_elfNN_swap_reloca_out (abfd, &outrel,
((ElfNN_External_Rela *) srel->contents