This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Don't create .eh_frame_hdr on shared lib bfd

On Wed, Dec 24, 2014 at 10:30:51PM +1030, Alan Modra wrote:
> 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.

Let's do the same for build-id too.  It's not completely true to say
we're excluding shared libraries by the section count test, since some
target backends will add linker created sections to a shared library
bfd, but this is good enough.

	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.

diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 137446f..36dee8e 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -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->
-	if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+	if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+	    && bfd_count_sections (abfd) != 0)
       /* 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->
+	  if (bfd_count_sections (abfd) == 0)
+	    continue;
 	  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
 	    elfbfd = abfd;
 	  if (!warn_eh_frame)

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]