forked from Imagelibrary/binutils-gdb
Index PowerPC64 linker generated .eh_frame in .eh_frame_hdr
I noticed recently that .eh_frame FDEs generated by the linker for
call stubs and .glink weren't being indexed in .eh_frame_hdr, due to
bfd_elf_discard_info being run before the linker generated .eh_frame
sections were available for parsing. This patch moves code around in
elf64-ppc.c and ppc64elf.em to avoid that problem.
Another problem fixed here is that --gc-sections parses .eh_frame
early, and the existing machinery allows only one go at parsing the
.eh_frame sections. That resulted in the linker generated .eh_frame
CIEs not being merged and no .eh_frame_hdr index entries for those
FDEs. It turns out that all the info from parsing .eh_frame is
attached to the section, so order of parsing isn't important, and
after parsing sec_info_type being set will prevent a section being
parsed again. At least, when parsing doesn't hit an error. So there
isn't really any need for "parsed_eh_frame". "merge_cies" is also
redundant, which means _bfd_elf_{begin,end}_eh_frame_parsing can also
disappear.
bfd/
* elf-bfd.h (struct eh_frame_hdr_info): Delete merge_cies and
parsed_eh_frames.
(_bfd_elf_begin_eh_frame_parsing): Delete.
(_bfd_elf_end_eh_frame_parsing): Delete.
* elf-eh-frame.c (_bfd_elf_begin_eh_frame_parsing): Delete.
(_bfd_elf_end_eh_frame_parsing): Delete.
(_bfd_elf_parse_eh_frame): Don't test parsed_eh_frame. Test
!info->relocatable in place of merge_cies.
* elflink.c (bfd_elf_gc_sections, bfd_elf_discard_info): Adjust.
* elf64-ppc.c (glink_eh_frame_cie): Pad to multiple of 8.
(ppc64_elf_size_stubs): Likewise pad stub FDE.
(ppc64_elf_build_stubs): Move code setting glink .eh_frame to..
(ppc64_elf_size_stubs): ..here and..
(ppc64_elf_finish_dynamic_sections): ..here.
ld/
* emultempl/ppc64elf.em (gld${EMULATION_NAME}_after_allocation): Call
bfd_elf_discard_info after generating glink .eh_frame. Delete
redundant test on ppc64_elf_setup_section_lists status.
This commit is contained in:
@@ -12154,6 +12154,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
bfd *sub;
|
||||
elf_gc_mark_hook_fn gc_mark_hook;
|
||||
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
struct elf_link_hash_table *htab;
|
||||
|
||||
if (!bed->can_gc_sections
|
||||
|| !is_elf_hash_table (info->hash))
|
||||
@@ -12163,10 +12164,10 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
}
|
||||
|
||||
bed->gc_keep (info);
|
||||
htab = elf_hash_table (info);
|
||||
|
||||
/* Try to parse each bfd's .eh_frame section. Point elf_eh_frame_section
|
||||
at the .eh_frame section if we can mark the FDEs individually. */
|
||||
_bfd_elf_begin_eh_frame_parsing (info);
|
||||
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
|
||||
{
|
||||
asection *sec;
|
||||
@@ -12183,27 +12184,20 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
sec = bfd_get_next_section_by_name (sec);
|
||||
}
|
||||
}
|
||||
_bfd_elf_end_eh_frame_parsing (info);
|
||||
|
||||
/* Apply transitive closure to the vtable entry usage info. */
|
||||
elf_link_hash_traverse (elf_hash_table (info),
|
||||
elf_gc_propagate_vtable_entries_used,
|
||||
&ok);
|
||||
elf_link_hash_traverse (htab, elf_gc_propagate_vtable_entries_used, &ok);
|
||||
if (!ok)
|
||||
return FALSE;
|
||||
|
||||
/* Kill the vtable relocations that were not used. */
|
||||
elf_link_hash_traverse (elf_hash_table (info),
|
||||
elf_gc_smash_unused_vtentry_relocs,
|
||||
&ok);
|
||||
elf_link_hash_traverse (htab, elf_gc_smash_unused_vtentry_relocs, &ok);
|
||||
if (!ok)
|
||||
return FALSE;
|
||||
|
||||
/* Mark dynamically referenced symbols. */
|
||||
if (elf_hash_table (info)->dynamic_sections_created)
|
||||
elf_link_hash_traverse (elf_hash_table (info),
|
||||
bed->gc_mark_dynamic_ref,
|
||||
info);
|
||||
if (htab->dynamic_sections_created)
|
||||
elf_link_hash_traverse (htab, bed->gc_mark_dynamic_ref, info);
|
||||
|
||||
/* Grovel through relocs to find out who stays ... */
|
||||
gc_mark_hook = bed->gc_mark_hook;
|
||||
@@ -12682,7 +12676,6 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
|
||||
{
|
||||
asection *i;
|
||||
|
||||
_bfd_elf_begin_eh_frame_parsing (info);
|
||||
for (i = o->map_head.s; i != NULL; i = i->map_head.s)
|
||||
{
|
||||
if (i->size == 0)
|
||||
@@ -12703,7 +12696,6 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
|
||||
|
||||
fini_reloc_cookie_for_section (&cookie, i);
|
||||
}
|
||||
_bfd_elf_end_eh_frame_parsing (info);
|
||||
}
|
||||
|
||||
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next)
|
||||
|
||||
Reference in New Issue
Block a user