[committed, PATCH] 2.29: Do not choose a non-ELF format input file to hold the linker created GOT sections.
H.J. Lu
hongjiu.lu@intel.com
Fri Aug 11 15:21:00 GMT 2017
More information about the Binutils mailing list
Fri Aug 11 15:21:00 GMT 2017
- Previous message (by thread): [committed, PATCH] Add 2 more tests for PR ld/21884
- Next message (by thread): Commit: Add -z globalaudit linker command line option
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I backported 2 commits to 2.29 branch. H.J. -- bfd/ PR 21884 * elf32-i386.c (elf_i386_link_setup_gnu_properties): If the dynobj has not been set then use the bfd returned by _bfd_elf_link_setup_gnu_properties. If that is null then search through all the input bfds selecting the first normal, ELF format one. * elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise. ld/ PR ld/21884 * testsuite/ld-i386/i386.exp: Run pr21884. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr21884.d: New file. * testsuite/ld-i386/pr21884.t: Likewise. * testsuite/ld-x86-64/pr21884.d: Likewise. * testsuite/ld-x86-64/pr21884.t: Likewise. (cherry picked from commit b7a18930e3925c4092bd975e95bc3603aa1418d9 and 9593aade74f0da0c08a4ab55e4c59173b07b1f63) --- bfd/ChangeLog | 10 ++++++++++ bfd/elf32-i386.c | 39 ++++++++++++++++++++++++--------------- bfd/elf64-x86-64.c | 5 +++-- ld/ChangeLog | 10 ++++++++++ ld/testsuite/ld-i386/i386.exp | 1 + ld/testsuite/ld-i386/pr21884.d | 9 +++++++++ ld/testsuite/ld-i386/pr21884.t | 11 +++++++++++ ld/testsuite/ld-x86-64/pr21884.d | 9 +++++++++ ld/testsuite/ld-x86-64/pr21884.t | 11 +++++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 1 + 10 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 ld/testsuite/ld-i386/pr21884.d create mode 100644 ld/testsuite/ld-i386/pr21884.t create mode 100644 ld/testsuite/ld-x86-64/pr21884.d create mode 100644 ld/testsuite/ld-x86-64/pr21884.t diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 211e34016f..078dc43acd 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2017-08-11 Nick Clifton <nickc@redhat.com> + + PR 21884 + * elf32-i386.c (elf_i386_link_setup_gnu_properties): If the dynobj + has not been set then use the bfd returned by + _bfd_elf_link_setup_gnu_properties. If that is null then search + through all the input bfds selecting the first normal, ELF format + one. + * elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise. + 2017-08-08 Alan Modra <amodra@gmail.com> PR 21017 diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index df16775d54..b46ed2dd13 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -6914,20 +6914,29 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info) set it in check_relocs. */ if (dynobj == NULL) { - bfd *abfd; - - /* Find a normal input file to hold linker created - sections. */ - for (abfd = info->input_bfds; - abfd != NULL; - abfd = abfd->link.next) - if ((abfd->flags - & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0) - { - htab->elf.dynobj = abfd; - dynobj = abfd; - break; - } + if (pbfd != NULL) + { + htab->elf.dynobj = pbfd; + dynobj = pbfd; + } + else + { + bfd *abfd; + + /* Find a normal input file to hold linker created + sections. */ + for (abfd = info->input_bfds; + abfd != NULL; + abfd = abfd->link.next) + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (abfd->flags + & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0) + { + htab->elf.dynobj = abfd; + dynobj = abfd; + break; + } + } } /* Even when lazy binding is disabled by "-z now", the PLT0 entry may @@ -7019,7 +7028,7 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info) return pbfd; /* Since create_dynamic_sections isn't always called, but GOT - relocations need GOT relocations, create them here so that we + relocations need GOT sections, create them here so that we don't need to do it in check_relocs. */ if (htab->elf.sgot == NULL && !_bfd_elf_create_got_section (dynobj, info)) diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index c80a9caaa6..821a7d9cbe 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -7466,8 +7466,9 @@ error_alignment: for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) - if ((abfd->flags - & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0) + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (abfd->flags + & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0) { htab->elf.dynobj = abfd; dynobj = abfd; diff --git a/ld/ChangeLog b/ld/ChangeLog index 8c374e3d84..96e7a6aed1 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2017-08-11 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/21884 + * testsuite/ld-i386/i386.exp: Run pr21884. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/ld-i386/pr21884.d: New file. + * testsuite/ld-i386/pr21884.t: Likewise. + * testsuite/ld-x86-64/pr21884.d: Likewise. + * testsuite/ld-x86-64/pr21884.t: Likewise. + 2017-08-03 Alan Modra <amodra@gmail.com> PR ld/21884 diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 6c53046193..fe490a7486 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -434,6 +434,7 @@ run_dump_test "property-x86-shstk3a" run_dump_test "property-x86-shstk3b" run_dump_test "property-x86-shstk4" run_dump_test "property-x86-shstk5" +run_dump_test "pr21884" if { !([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"] diff --git a/ld/testsuite/ld-i386/pr21884.d b/ld/testsuite/ld-i386/pr21884.d new file mode 100644 index 0000000000..dc212d3c68 --- /dev/null +++ b/ld/testsuite/ld-i386/pr21884.d @@ -0,0 +1,9 @@ +#source: dummy.s +#as: --32 +#ld: -m elf_i386 -T pr21884.t -b binary +#objdump: -b binary -s + +.*: file format binary + +Contents of section .data: +#pass diff --git a/ld/testsuite/ld-i386/pr21884.t b/ld/testsuite/ld-i386/pr21884.t new file mode 100644 index 0000000000..9ec7dc8614 --- /dev/null +++ b/ld/testsuite/ld-i386/pr21884.t @@ -0,0 +1,11 @@ +OUTPUT_FORMAT("elf32-i386"); +OUTPUT_ARCH(i386); + +ENTRY(_start); +SECTIONS { + . = 0x10000; + _start = . ; + .data : { + *(.data) + } +} diff --git a/ld/testsuite/ld-x86-64/pr21884.d b/ld/testsuite/ld-x86-64/pr21884.d new file mode 100644 index 0000000000..a62d8bc4f7 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr21884.d @@ -0,0 +1,9 @@ +#source: dummy.s +#as: --64 +#ld: -m elf_x86_64 -T pr21884.t -b binary +#objdump: -b binary -s + +.*: file format binary + +Contents of section .data: +#pass diff --git a/ld/testsuite/ld-x86-64/pr21884.t b/ld/testsuite/ld-x86-64/pr21884.t new file mode 100644 index 0000000000..f57cb3a601 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr21884.t @@ -0,0 +1,11 @@ +OUTPUT_FORMAT("elf64-x86-64"); +OUTPUT_ARCH(i386:x86-64); + +ENTRY(_start); +SECTIONS { + . = 0x10000; + _start = . ; + .data : { + *(.data) + } +} diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index c582582297..38009a811b 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -365,6 +365,7 @@ run_dump_test "property-x86-shstk4" run_dump_test "property-x86-shstk4-x32" run_dump_test "property-x86-shstk5" run_dump_test "property-x86-shstk5-x32" +run_dump_test "pr21884" if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { return -- 2.13.4
- Previous message (by thread): [committed, PATCH] Add 2 more tests for PR ld/21884
- Next message (by thread): Commit: Add -z globalaudit linker command line option
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list