PATCH: PR ld/11913: Linker crash to discarded output sections
H.J. Lu
hongjiu.lu@intel.com
Sat Aug 14 03:09:00 GMT 2010
More information about the Binutils mailing list
Sat Aug 14 03:09:00 GMT 2010
- Previous message (by thread): [gold patch committed] Add prototype to avoid warning
- Next message (by thread): [PATCH] libiberty: add HAVE_CONFIG_H check to all files (lacking it already)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, I checked in this patch to avoid linker crash. H.J. --- bfd/ 2010-08-13 H.J. Lu <hongjiu.lu@intel.com> PR ld/11913 * elf32-i386.c (elf_i386_finish_dynamic_sections): Check if .got.plt section is discarded. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Likewise. ld/testsuite/ 2010-08-13 H.J. Lu <hongjiu.lu@intel.com> PR ld/11913 * ld-i386/discarded1.d: New. * ld-i386/discarded1.s: Likewise. * ld-i386/discarded1.t: Likewise. * ld-x86-64/discarded1.d: Likewise. * ld-x86-64/discarded1.s: Likewise. * ld-x86-64/discarded1.t: Likewise. * ld-i386/i386.exp: Run discarded1. * ld-x86-64/x86-64.exp: Likewise. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 0ff3147..4ba1ba0 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -4613,6 +4613,13 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd, if (htab->elf.sgotplt) { + if (bfd_is_abs_section (htab->elf.sgotplt->output_section)) + { + (*_bfd_error_handler) + (_("discarded output section: `%A'"), htab->elf.sgotplt); + return FALSE; + } + /* Fill in the first three entries in the global offset table. */ if (htab->elf.sgotplt->size > 0) { diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index b0bc5c0..9899fd4 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -4186,6 +4186,13 @@ elf64_x86_64_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf if (htab->elf.sgotplt) { + if (bfd_is_abs_section (htab->elf.sgotplt->output_section)) + { + (*_bfd_error_handler) + (_("discarded output section: `%A'"), htab->elf.sgotplt); + return FALSE; + } + /* Fill in the first three entries in the global offset table. */ if (htab->elf.sgotplt->size > 0) { diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 850713a..86ba9e4 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -190,6 +190,7 @@ run_dump_test "protected2" run_dump_test "protected3" run_dump_test "tlspie1" run_dump_test "nogot1" +run_dump_test "discarded1" if { !([istarget "i?86-*-linux*"] || [istarget "x86_64-*-linux*"]) } { diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index d7ca525..ed5d8dc 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -99,6 +99,7 @@ run_dump_test "tlsle1" run_dump_test "tlspie1" run_dump_test "unique1" run_dump_test "nogot1" +run_dump_test "discarded1" if { ![istarget "x86_64-*-linux*"] } { return --- /dev/null 2010-08-11 15:57:03.635230126 -0700 +++ binutils/ld/testsuite/ld-i386/discarded1.d 2010-08-13 13:37:12.352919840 -0700 @@ -0,0 +1,3 @@ +#as: --32 +#ld: -melf_i386 -T discarded1.t +#error: .*discarded output section: `.got.plt' --- /dev/null 2010-08-11 15:57:03.635230126 -0700 +++ binutils/ld/testsuite/ld-i386/discarded1.s 2010-08-13 13:46:51.445977097 -0700 @@ -0,0 +1,13 @@ + .text +.globl _start + .type _start, @function +_start: + movl x@GOT(%ecx), %eax + .size _start, .-_start +.globl x + .data + .align 4 + .type x, @object + .size x, 4 +x: + .long 2 --- /dev/null 2010-08-11 15:57:03.635230126 -0700 +++ binutils/ld/testsuite/ld-i386/discarded1.t 2010-08-13 13:36:51.139101020 -0700 @@ -0,0 +1,7 @@ +ENTRY(_start) +SECTIONS +{ + .text : {*(.text)} + .data : {*(.data)} + /DISCARD/ : {*(*)} +} --- /dev/null 2010-08-11 15:57:03.635230126 -0700 +++ binutils/ld/testsuite/ld-x86-64/discarded1.d 2010-08-13 13:34:29.089728846 -0700 @@ -0,0 +1,3 @@ +#as: --64 +#ld: -melf_x86_64 -T discarded1.t +#error: .*discarded output section: `.got.plt' --- /dev/null 2010-08-11 15:57:03.635230126 -0700 +++ binutils/ld/testsuite/ld-x86-64/discarded1.s 2010-08-13 13:47:11.790857039 -0700 @@ -0,0 +1,13 @@ + .text +.globl _start + .type _start, @function +_start: + movq x@GOTPCREL(%rip), %rax + .size _start, .-_start +.globl x + .data + .align 4 + .type x, @object + .size x, 4 +x: + .long 2 --- /dev/null 2010-08-11 15:57:03.635230126 -0700 +++ binutils/ld/testsuite/ld-x86-64/discarded1.t 2010-08-13 12:52:58.846736153 -0700 @@ -0,0 +1,7 @@ +ENTRY(_start) +SECTIONS +{ + .text : {*(.text)} + .data : {*(.data)} + /DISCARD/ : {*(*)} +}
- Previous message (by thread): [gold patch committed] Add prototype to avoid warning
- Next message (by thread): [PATCH] libiberty: add HAVE_CONFIG_H check to all files (lacking it already)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list