forked from Imagelibrary/binutils-gdb
bfd/
* section.c (struct bfd_section): Replace link_order_head and link_order_tail with map_head and map_tail union. (STD_SECTION): Update. (_bfd_strip_section_from_output): Delete. * aoutx.h: Update throughout for above changes. * coff-ppc.c: Likewise. * cofflink.c: Likewise. * ecoff.c: Likewise. * elf-eh-frame.c: Likewise. * elf-m10300.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-cris.c: Likewise. * elf32-hppa.c: Likewise. * elf32-i386.c: Likewise. * elf32-m32r.c: Likewise. * elf32-m68hc1x.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-s390.c: Likewise. * elf32-sh.c: Likewise. * elf32-vax.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise. * elf64-sh64.c: Likewise. * elf64-x86-64.c: Likewise. * elflink.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * linker.c: Likewise. * merge.c: Likewise. * pdp11.c: Likewise. * xcofflink.c: Likewise. * elflink.c (bfd_boolean bfd_elf_size_dynsym_hash_dynstr): Split out from bfd_elf_size_dynamic_sections. * bfd-in.h (bfd_boolean bfd_elf_size_dynsym_hash_dynstr): Declare. * bfd-in2.h: Regenerate. ld/ * ldemul.c: Include bfdlink.h. (ldemul_before_allocation): Assume before_allocation is non-zero. (before_allocation_default): Call strip_excluded_output_sections. * ldlang.c (stripped_excluded_sections): New variable. (lang_add_section): Build input section list for each output section, attached via map_head and map_tail pointers. (strip_excluded_output_sections): Make global. Traverse the input section lists to find which output sections can go. Clear link_order pointers and set stripped_excluded_sections. (lang_process): Call strip_excluded_output_sections. * ldlang.h (strip_excluded_output_sections): Declare. * ldwrite.c: Update throuhout for link_order_head -> map_head change. * emultempl/aix.em (before_allocation): Call strip_excluded_output_sections. * emultempl/armcoff.em (before_allocation): Likewise. * emultempl/beos.em (before_allocation): Likewise. * emultempl/linux.em (before_allocation): Likewise. * emultempl/pe.em (before_allocation): Likewise. * emultempl/sunos.em (before_allocation): Likewise. * emultempl/elf32.em (before_allocation): Likewise. Call bfd_elf_size_dynsym_hash_dynstr too. * emultempl/lnk960.em (lnk960_before_allocation): Delete. (ld_lnk960): Use before_allocation_default.
This commit is contained in:
@@ -5289,12 +5289,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
|
||||
if (elf_hash_table (info)->dynamic_sections_created)
|
||||
{
|
||||
bfd_size_type dynsymcount;
|
||||
unsigned long section_sym_count;
|
||||
asection *s;
|
||||
size_t bucketcount = 0;
|
||||
size_t hash_entry_size;
|
||||
unsigned int dtagcount;
|
||||
|
||||
/* Set up the version definition section. */
|
||||
s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
|
||||
@@ -5309,7 +5305,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
verdefs = verdefs->next;
|
||||
|
||||
if (verdefs == NULL && !info->create_default_symver)
|
||||
_bfd_strip_section_from_output (info, s);
|
||||
s->flags |= SEC_EXCLUDE;
|
||||
else
|
||||
{
|
||||
unsigned int cdefs;
|
||||
@@ -5563,7 +5559,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
&sinfo);
|
||||
|
||||
if (elf_tdata (output_bfd)->verref == NULL)
|
||||
_bfd_strip_section_from_output (info, s);
|
||||
s->flags |= SEC_EXCLUDE;
|
||||
else
|
||||
{
|
||||
Elf_Internal_Verneed *t;
|
||||
@@ -5652,6 +5648,37 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
}
|
||||
}
|
||||
|
||||
if ((elf_tdata (output_bfd)->cverrefs == 0
|
||||
&& elf_tdata (output_bfd)->cverdefs == 0)
|
||||
|| _bfd_elf_link_renumber_dynsyms (output_bfd, info,
|
||||
§ion_sym_count) == 0)
|
||||
{
|
||||
s = bfd_get_section_by_name (dynobj, ".gnu.version");
|
||||
s->flags |= SEC_EXCLUDE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
|
||||
{
|
||||
if (!is_elf_hash_table (info->hash))
|
||||
return TRUE;
|
||||
|
||||
if (elf_hash_table (info)->dynamic_sections_created)
|
||||
{
|
||||
bfd *dynobj;
|
||||
const struct elf_backend_data *bed;
|
||||
asection *s;
|
||||
bfd_size_type dynsymcount;
|
||||
unsigned long section_sym_count;
|
||||
size_t bucketcount = 0;
|
||||
size_t hash_entry_size;
|
||||
unsigned int dtagcount;
|
||||
|
||||
dynobj = elf_hash_table (info)->dynobj;
|
||||
|
||||
/* Assign dynsym indicies. In a shared library we generate a
|
||||
section symbol for each output section, which come first.
|
||||
Next come all of the back-end allocated local dynamic syms,
|
||||
@@ -5663,17 +5690,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
/* Work out the size of the symbol version section. */
|
||||
s = bfd_get_section_by_name (dynobj, ".gnu.version");
|
||||
BFD_ASSERT (s != NULL);
|
||||
if (dynsymcount == 0
|
||||
|| (verdefs == NULL && elf_tdata (output_bfd)->verref == NULL
|
||||
&& !info->create_default_symver))
|
||||
{
|
||||
_bfd_strip_section_from_output (info, s);
|
||||
/* The DYNSYMCOUNT might have changed if we were going to
|
||||
output a dynamic symbol table entry for S. */
|
||||
dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info,
|
||||
§ion_sym_count);
|
||||
}
|
||||
else
|
||||
if (dynsymcount != 0
|
||||
&& (s->flags & SEC_EXCLUDE) == 0)
|
||||
{
|
||||
s->size = dynsymcount * sizeof (Elf_External_Versym);
|
||||
s->contents = bfd_zalloc (output_bfd, s->size);
|
||||
@@ -5692,6 +5710,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
section as we went along in elf_link_add_object_symbols. */
|
||||
s = bfd_get_section_by_name (dynobj, ".dynsym");
|
||||
BFD_ASSERT (s != NULL);
|
||||
bed = get_elf_backend_data (output_bfd);
|
||||
s->size = dynsymcount * bed->s->sizeof_sym;
|
||||
|
||||
if (dynsymcount != 0)
|
||||
@@ -5957,7 +5976,7 @@ elf_link_sort_relocs (bfd *abfd, struct bfd_link_info *info, asection **psec)
|
||||
count = reldyn->size / ext_size;
|
||||
|
||||
size = 0;
|
||||
for (lo = reldyn->link_order_head; lo != NULL; lo = lo->next)
|
||||
for (lo = reldyn->map_head.link_order; lo != NULL; lo = lo->next)
|
||||
if (lo->type == bfd_indirect_link_order)
|
||||
{
|
||||
asection *o = lo->u.indirect.section;
|
||||
@@ -5982,7 +6001,7 @@ elf_link_sort_relocs (bfd *abfd, struct bfd_link_info *info, asection **psec)
|
||||
else
|
||||
r_sym_mask = ~(bfd_vma) 0xffffffff;
|
||||
|
||||
for (lo = reldyn->link_order_head; lo != NULL; lo = lo->next)
|
||||
for (lo = reldyn->map_head.link_order; lo != NULL; lo = lo->next)
|
||||
if (lo->type == bfd_indirect_link_order)
|
||||
{
|
||||
bfd_byte *erel, *erelend;
|
||||
@@ -6032,7 +6051,7 @@ elf_link_sort_relocs (bfd *abfd, struct bfd_link_info *info, asection **psec)
|
||||
|
||||
qsort (s_non_relative, count - ret, sort_elt, elf_link_sort_cmp2);
|
||||
|
||||
for (lo = reldyn->link_order_head; lo != NULL; lo = lo->next)
|
||||
for (lo = reldyn->map_head.link_order; lo != NULL; lo = lo->next)
|
||||
if (lo->type == bfd_indirect_link_order)
|
||||
{
|
||||
bfd_byte *erel, *erelend;
|
||||
@@ -7655,7 +7674,7 @@ elf_fixup_link_order (bfd *abfd, asection *o)
|
||||
|
||||
seen_other = 0;
|
||||
seen_linkorder = 0;
|
||||
for (p = o->link_order_head; p != NULL; p = p->next)
|
||||
for (p = o->map_head.link_order; p != NULL; p = p->next)
|
||||
{
|
||||
if (p->type == bfd_indirect_link_order
|
||||
&& (bfd_get_flavour ((sub = p->u.indirect.section->owner))
|
||||
@@ -7689,7 +7708,7 @@ elf_fixup_link_order (bfd *abfd, asection *o)
|
||||
xmalloc (seen_linkorder * sizeof (struct bfd_link_order *));
|
||||
seen_linkorder = 0;
|
||||
|
||||
for (p = o->link_order_head; p != NULL; p = p->next)
|
||||
for (p = o->map_head.link_order; p != NULL; p = p->next)
|
||||
{
|
||||
sections[seen_linkorder++] = p;
|
||||
}
|
||||
@@ -7803,7 +7822,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
|
||||
struct bfd_elf_section_data *esdo = elf_section_data (o);
|
||||
o->reloc_count = 0;
|
||||
|
||||
for (p = o->link_order_head; p != NULL; p = p->next)
|
||||
for (p = o->map_head.link_order; p != NULL; p = p->next)
|
||||
{
|
||||
unsigned int reloc_count = 0;
|
||||
struct bfd_elf_section_data *esdi = NULL;
|
||||
@@ -8143,7 +8162,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
|
||||
{
|
||||
struct bfd_link_order *o;
|
||||
|
||||
for (o = sec->link_order_head; o != NULL; o = o->next)
|
||||
for (o = sec->map_head.link_order; o != NULL; o = o->next)
|
||||
if (size < o->offset + o->size)
|
||||
size = o->offset + o->size;
|
||||
}
|
||||
@@ -8185,7 +8204,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
|
||||
sub->output_has_begun = FALSE;
|
||||
for (o = abfd->sections; o != NULL; o = o->next)
|
||||
{
|
||||
for (p = o->link_order_head; p != NULL; p = p->next)
|
||||
for (p = o->map_head.link_order; p != NULL; p = p->next)
|
||||
{
|
||||
if (p->type == bfd_indirect_link_order
|
||||
&& (bfd_get_flavour ((sub = p->u.indirect.section->owner))
|
||||
|
||||
Reference in New Issue
Block a user