Don't create .eh_frame_hdr on shared lib bfd
authorAlan Modra <amodra@gmail.com>
Wed, 24 Dec 2014 11:37:42 +0000 (22:07 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 24 Dec 2014 13:17:56 +0000 (23:47 +1030)
If no object files have .eh_frame, but some shared library does, then
ld creates a .eh_frame_hdr section using the shared library bfd.  This
is silly since shared library .eh_frame sections don't contribute to
the output .eh_frame and thus no .eh_frame_hdr is needed.

Also, the bfd section list and count is cleared for shared libraries,
and a zero section count used as a flag in lang_check to omit a call
to bfd_merge_private_bfd_data for shared libraries.  If we create a
section on a shared lib bfd then ld will wrongly attempt to merge the
shared library private bfd data.

PR 17742
* ld/emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Exclude
shared libraries in loop looking for .eh_frame sections.
Similarly for build-id loop.

ld/ChangeLog
ld/emultempl/elf32.em

index 0b2f058c092726991d760c9c019913a31b38297b..31eb04eeedea3f033588195043f6f0b2306b17ad 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-24  Alan Modra  <amodra@gmail.com>
+
+       * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Exclude
+       shared libraries in loop looking for .eh_frame sections.
+       Similarly for build-id loop.
+
 2014-12-23  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * emultempl/avrelf.em: Add include of elf/avr.h.
index 137446fe973d0d65c9a9009d491906f1b9263c83..36dee8e66ab702be1234e093377d70f8567ba903 100644 (file)
@@ -1015,7 +1015,8 @@ gld${EMULATION_NAME}_after_open (void)
       /* 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)
+       if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+           && bfd_count_sections (abfd) != 0)
          break;
 
       /* PR 10555: If there are no ELF input files do not try to
@@ -1053,6 +1054,8 @@ gld${EMULATION_NAME}_after_open (void)
 
       for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
        {
+         if (bfd_count_sections (abfd) == 0)
+           continue;
          if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
            elfbfd = abfd;
          if (!warn_eh_frame)
This page took 0.028497 seconds and 4 git commands to generate.