Find an ELF input for --build-id and --eh-frame-hdr.

2010-08-22  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11937
	* emultempl/elf32.em (_after_open): Find an ELF input for
	--build-id and --eh-frame-hdr.
This commit is contained in:
H.J. Lu
2010-08-22 19:11:58 +00:00
parent 14d8bca30e
commit a654efd60a
2 changed files with 32 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2010-08-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/11937
* emultempl/elf32.em (_after_open): Find an ELF input for
--build-id and --eh-frame-hdr.
2010-08-20 Maciej W. Rozycki <macro@codesourcery.com> 2010-08-20 Maciej W. Rozycki <macro@codesourcery.com>
* Makefile.am (eshlelf_fd.c): Correct the name of the tool * Makefile.am (eshlelf_fd.c): Correct the name of the tool

View File

@ -1065,7 +1065,11 @@ gld${EMULATION_NAME}_after_open (void)
asection *s; asection *s;
bfd_size_type size; bfd_size_type size;
abfd = link_info.input_bfds; /* Find an ELF input. */
for (abfd = link_info.input_bfds;
abfd != (bfd *) NULL; abfd = abfd->link_next)
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
break;
if (abfd == NULL) if (abfd == NULL)
{ {
@ -1120,33 +1124,38 @@ gld${EMULATION_NAME}_after_open (void)
if (link_info.eh_frame_hdr if (link_info.eh_frame_hdr
&& !link_info.traditional_format) && !link_info.traditional_format)
{ {
bfd *abfd; bfd *abfd, *elfbfd = NULL;
bfd_boolean warn_eh_frame = FALSE;
asection *s; asection *s;
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next) for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next)
{ {
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
elfbfd = abfd;
s = bfd_get_section_by_name (abfd, ".eh_frame"); s = bfd_get_section_by_name (abfd, ".eh_frame");
if (s && s->size > 8 && !bfd_is_abs_section (s->output_section)) if (s && s->size > 8 && !bfd_is_abs_section (s->output_section))
break; warn_eh_frame = TRUE;
if (elfbfd && warn_eh_frame)
break;
} }
if (abfd) if (elfbfd)
{ {
const struct elf_backend_data *bed; const struct elf_backend_data *bed;
bed = get_elf_backend_data (abfd); bed = get_elf_backend_data (elfbfd);
if (bed == NULL) s = bfd_make_section_with_flags (elfbfd, ".eh_frame_hdr",
s = NULL; bed->dynamic_sec_flags
else | SEC_READONLY);
s = bfd_make_section_with_flags (abfd, ".eh_frame_hdr",
bed->dynamic_sec_flags
| SEC_READONLY);
if (s != NULL if (s != NULL
&& bfd_set_section_alignment (abfd, s, 2)) && bfd_set_section_alignment (elfbfd, s, 2))
htab->eh_info.hdr_sec = s; {
else htab->eh_info.hdr_sec = s;
einfo ("%P: warning: Cannot create .eh_frame_hdr section," warn_eh_frame = FALSE;
" --eh-frame-hdr ignored.\n"); }
} }
if (warn_eh_frame)
einfo ("%P: warning: Cannot create .eh_frame_hdr section,"
" --eh-frame-hdr ignored.\n");
} }
/* Get the list of files which appear in DT_NEEDED entries in /* Get the list of files which appear in DT_NEEDED entries in