This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[testcase] bug caused by the orphan .rel placement patch
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 9 Oct 2002 22:35:27 +0200
- Subject: [testcase] bug caused by the orphan .rel placement patch
- References: <200209291441.KAA01834@bromo.msbb.uc.edu> <20020929170140.A25376@lucon.org> <20020930110026.G5311@bubble.sa.bigpond.net.au> <20020930125850.J5311@bubble.sa.bigpond.net.au>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Sep 30, 2002 at 12:58:50PM +0930, Alan Modra wrote:
> On Mon, Sep 30, 2002 at 11:00:26AM +0930, Alan Modra wrote:
> > * emultempl/elf32.em (output_rel_find): Always place orphan loadable
> > reloc sections just before .rel.plt/.rela.plt.
> > (gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code.
> > Only put loadable reloc sections in hold_rel.
>
> Revised patch after thinking about it a little longer..
> Also a testcase.
>
> ld/ChangeLog
> * emultempl/elf32.em (output_rel_find): Always place orphan loadable
> reloc sections just before .rel.plt/.rela.plt.
> (gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code.
> Only put loadable reloc sections in hold_rel.
Unfortunately this patch broke the following testcase (distilled
from glibc).
Guess the combreloc code should not have removed.
2002-10-09 Jakub Jelinek <jakub@redhat.com>
* ld-i386/combreloc.s: New test.
* ld-i386/combreloc.d: New test.
* ld-i386/i386.exp (i386tests): Add it.
--- ld/testsuite/ld-i386/combreloc.s.jj 2002-10-09 22:27:22.000000000 +0200
+++ ld/testsuite/ld-i386/combreloc.s 2002-10-09 22:29:51.000000000 +0200
@@ -0,0 +1,22 @@
+ .text
+ .globl _start, foo
+ .type _start,@function
+_start:
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ebx
+ call 1f
+1: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+ movl _start@GOT(%ebx), %eax
+ movl (%eax), %eax
+ call foo@PLT
+ movl (%esp), %ebx
+ leave
+foo: ret
+ .data
+ .long _start
+ .section "__libc_subfreeres", "aw", @progbits
+ .long _start
+ .section "__libc_atexit", "aw", @progbits
+ .long _start
--- ld/testsuite/ld-i386/i386.exp.jj 2002-10-01 12:48:03.000000000 +0200
+++ ld/testsuite/ld-i386/i386.exp 2002-10-09 22:35:19.000000000 +0200
@@ -59,6 +59,8 @@ set i386tests {
{{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
{"Reloc section order" "-shared -melf_i386" "--32" {reloc.s}
{{objdump -hw reloc.d}} "reloc.so"}
+ {"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc"
+ "--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"}
}
run_ld_link_tests $i386tests
--- ld/testsuite/ld-i386/combreloc.d.jj 2002-10-09 22:31:12.000000000 +0200
+++ ld/testsuite/ld-i386/combreloc.d 2002-10-09 22:38:01.000000000 +0200
@@ -0,0 +1,18 @@
+# Test that orphan reloc sections are merged into .rel.dyn with
+# -z combreloc.
+#source: combreloc.s
+#as: --32
+#ld: -shared -melf_i386 -z combreloc
+#readelf: -r
+#target: i?86-*-*
+
+Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
+ Offset Info Type Sym.Value Sym. Name
+[0-9a-f]+ [0-9a-f]+01 R_386_32 [0-9a-f]+ _start
+[0-9a-f]+ [0-9a-f]+01 R_386_32 [0-9a-f]+ _start
+[0-9a-f]+ [0-9a-f]+01 R_386_32 [0-9a-f]+ _start
+[0-9a-f]+ [0-9a-f]+06 R_386_GLOB_DAT [0-9a-f]+ _start
+
+Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name
+[0-9a-f]+ [0-9a-f]+07 R_386_JUMP_SLOT [0-9a-f]+ foo
Jakub