[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ld: spurious empty .plt/.rela.plt sections generated
From: |
H.J. Lu |
Subject: |
Re: ld: spurious empty .plt/.rela.plt sections generated |
Date: |
Sun, 1 May 2011 06:40:02 -0700 |
On Sat, Apr 30, 2011 at 6:13 PM, H.J. Lu <address@hidden> wrote:
> On Sat, Apr 30, 2011 at 4:57 PM, Alan Modra <address@hidden> wrote:
>> On Fri, Apr 29, 2011 at 05:07:33PM -0700, Roland McGrath wrote:
>>> I am seeing a strange thing. The (BFD) linker spuriously generates .plt
>>> and .rela.plt sections (both empty) for a link that has no need for them.
>>> It's reproduced with a trivial example, and seen on today's binutils trunk.
>>> Gold does not produce the empty sections.
>>
>> HJ, please verify that this fix doesn't break anything else.
>>
>> Index: bfd/elf64-x86-64.c
>> ===================================================================
>> RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
>> retrieving revision 1.223
>> diff -u -p -r1.223 elf64-x86-64.c
>> --- bfd/elf64-x86-64.c 23 Apr 2011 01:16:31 -0000 1.223
>> +++ bfd/elf64-x86-64.c 30 Apr 2011 23:50:57 -0000
>> @@ -1261,7 +1261,9 @@ elf_x86_64_check_relocs (bfd *abfd, stru
>> case R_X86_64_PLT32:
>> case R_X86_64_GOTPCREL:
>> case R_X86_64_GOTPCREL64:
>> - if (!_bfd_elf_create_ifunc_sections (abfd, info))
>> + if (htab->elf.dynobj == NULL)
>> + htab->elf.dynobj = abfd;
>> + if (!_bfd_elf_create_ifunc_sections (htab->elf.dynobj, info))
>> return FALSE;
>> break;
>> }
>> Index: bfd/elf32-i386.c
>> ===================================================================
>> RCS file: /cvs/src/src/bfd/elf32-i386.c,v
>> retrieving revision 1.251
>> diff -u -p -r1.251 elf32-i386.c
>> --- bfd/elf32-i386.c 23 Apr 2011 01:16:31 -0000 1.251
>> +++ bfd/elf32-i386.c 30 Apr 2011 23:50:59 -0000
>> @@ -1376,7 +1376,9 @@ elf_i386_check_relocs (bfd *abfd,
>> case R_386_PLT32:
>> case R_386_GOT32:
>> case R_386_GOTOFF:
>> - if (!_bfd_elf_create_ifunc_sections (abfd, info))
>> + if (htab->elf.dynobj == NULL)
>> + htab->elf.dynobj = abfd;
>> + if (!_bfd_elf_create_ifunc_sections (htab->elf.dynobj, info))
>> return FALSE;
>> break;
>> }
>
> It works.
I checked in 2 testcases.
--
H.J.
---
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 1fd011e..8909846 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2011-05-01 H.J. Lu <address@hidden>
+
+ PR ld/12718
+ * ld-i386/i386.exp: Run pr12718.
+ * ld-x86-64/x86-64.exp: Likewise.
+
+ * ld-i386/pr12718.d: New.
+ * ld-i386/pr12718.s: Likewise.
+ * ld-x86-64/pr12718.d: Likewise.
+ * ld-x86-64/pr12718.s: Likewise.
+
2011-04-26 Kai Tietz <address@hidden>
* ld-pe/pe.exp: Add cfi/cfi32 tests.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index cc82e15..3bce2d3 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -194,6 +194,7 @@ run_dump_test "tlspie2"
run_dump_test "nogot1"
run_dump_test "nogot2"
run_dump_test "discarded1"
+run_dump_test "pr12718"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/pr12718.d b/ld/testsuite/ld-i386/pr12718.d
new file mode 100644
index 0000000..57eea4e
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr12718.d
@@ -0,0 +1,19 @@
+#name: PR ld/12718
+#as: --32
+#ld: -melf_i386
+#readelf: -S
+
+There are 5 section headers, starting at offset 0x7c:
+
+Section Headers:
+ \[Nr\] Name Type Addr Off Size ES
Flg Lk Inf Al
+ \[ 0\] NULL 00000000 000000 000000 00
0 0 0
+ \[ 1\] .text PROGBITS 08048054 000054 000006 00
AX 0 0 4
+ \[ 2\] .shstrtab STRTAB 00000000 00005a 000021 00
0 0 1
+ \[ 3\] .symtab SYMTAB 00000000 000144 000070 10
4 2 4
+ \[ 4\] .strtab STRTAB 00000000 0001b4 000024 00
0 0 1
+Key to Flags:
+ W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\)
+ I \(info\), L \(link order\), G \(group\), T \(TLS\), E
\(exclude\), x \(unknown\)
+ O \(extra OS processing required\) o \(OS specific\), p \(processor
specific\)
+#pass
diff --git a/ld/testsuite/ld-i386/pr12718.s b/ld/testsuite/ld-i386/pr12718.s
new file mode 100644
index 0000000..162704e
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr12718.s
@@ -0,0 +1,4 @@
+.globl foo
+foo: ret
+.globl _start
+_start: call foo
diff --git a/ld/testsuite/ld-x86-64/pr12718.d b/ld/testsuite/ld-x86-64/pr12718.d
new file mode 100644
index 0000000..ed04fd6
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr12718.d
@@ -0,0 +1,19 @@
+#name: PR ld/12718
+#as: --64
+#ld: -melf_x86_64
+#readelf: -S --wide
+
+There are 5 section headers, starting at offset 0xa0:
+
+Section Headers:
+ \[Nr\] Name Type Address Off
Size ES Flg Lk Inf Al
+ \[ 0\] NULL 0000000000000000 000000
000000 00 0 0 0
+ \[ 1\] .text PROGBITS 0000000000400078 000078
000006 00 AX 0 0 4
+ \[ 2\] .shstrtab STRTAB 0000000000000000 00007e
000021 00 0 0 1
+ \[ 3\] .symtab SYMTAB 0000000000000000 0001e0
0000a8 18 4 2 8
+ \[ 4\] .strtab STRTAB 0000000000000000 000288
000024 00 0 0 1
+Key to Flags:
+ W \(write\), A \(alloc\), X \(execute\), M \(merge\), S
\(strings\), l \(large\)
+ I \(info\), L \(link order\), G \(group\), T \(TLS\), E
\(exclude\), x \(unknown\)
+ O \(extra OS processing required\) o \(OS specific\), p \(processor
specific\)
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr12718.s b/ld/testsuite/ld-x86-64/pr12718.s
new file mode 100644
index 0000000..162704e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr12718.s
@@ -0,0 +1,4 @@
+.globl foo
+foo: ret
+.globl _start
+_start: call foo
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp
b/ld/testsuite/ld-x86-64/x86-64.exp
index 8e97729..c77640b 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -155,6 +155,7 @@ run_dump_test "unique1"
run_dump_test "nogot1"
run_dump_test "nogot2"
run_dump_test "discarded1"
+run_dump_test "pr12718"
if { ![istarget "x86_64-*-linux*"] } {
return
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: ld: spurious empty .plt/.rela.plt sections generated,
H.J. Lu <=