Commit: Fix test for .dynstr section

Nick Clifton nickc@redhat.com
Fri Jun 10 14:04:00 GMT 2011


Hi Guys,

  I am applying the patch below to fix a bug reported on the Fedora
  Bugzilla system:

     https://bugzilla.redhat.com/show_bug.cgi?id=712166

  The problem involves a broken linker script that accidentally marked
  all of the dynamic sections as being notes.  Now this is obviously a
  bad idea, but even so the linker should not seg-fault under such
  circumstances.

  The patch does two things.  It fixes the test for the .dynstr section
  in bfd_elf_final_link() so that it must have have both the SHT_STRTAB
  type and the name .dynstr.  (This was the cause of the original
  seg-fault).  Plus it makes the linker issue a warning message if it
  finds any dynamic section with the SHT_NOTE type, and sets the error
  to nonrepresentable_section.

  The patch also adds a test case for the warning message and fixes a
  mis-assumption in the ARM and HPPA ports that dynamic sections are
  always present in the output binary.  It also tidies up the
  description of the run_ld_link_tests function in the ld-lib.exp
  library, as this function is used to run the new test and the
  description was inaccurate in places.

  Tested with a large variety of different toolchains.

Cheers
  Nick

bfd/ChangeLog
2011-06-10  Nick Clifton  <nickc@redhat.com>

	* elflink.c (_bfd_elf_link_create_dynamic_sections): If the
	backend does not provide a function for creating dynamic sections
	then fail.
	(bfd_elf_final_link): Issue a warning message if a dynamic section
	has the SHT_NOTE type.
	(bfd_elf_final_link): Do not look for dynamic strings in a section
	that does not have the SHT_STRTAB type or the name .dynstr.
	* elf32-arm.c (elf32_arm_finish_dynamic_sections): Fail if the got
	section is not in the output binary.
	* elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Likewise.

ld/testsuite/ChangeLog
2011-06-10  Nick Clifton  <nickc@redhat.com>

	* ld-elf/elf.exp: Add test for linking a shared library with a
	broken linker script that marks dynamic sections as being notes.
	* ld-elf/note-3.s: New test source file.
	* ld-elf/note-3.t: New test linker script.
	* ld-elf/note-3.l: Expected output from the linker.
	* lib/ld-lib.exp (run_ld_link_tests): Improve description.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bz712166.patch
Type: text/x-patch
Size: 9820 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20110610/921a7218/attachment.bin>


More information about the Binutils mailing list