This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Committed: fix bug in elf32-cris.c with recent indirect-symbol-copy fix
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: binutils at sourceware dot org
- Date: Wed, 17 Dec 2008 03:19:18 +0100
- Subject: Committed: fix bug in elf32-cris.c with recent indirect-symbol-copy fix
Only the elf32-cris.c fix and libdso-15.d and its used files and
are committed, the other tests require the "ld_after_inputfiles"
option for which I'm waiting for approval. (Committed ChangeLog
adjusted accordingly.)
This bug was noticed through the recently added assert in
elf_cris_got_elt_size (see test-case) while linking libgomp.so
from gcc.
Of the new test-cases, only libdso-15b fails; libdso-15 is
foundation work (a DSO against which to link) and libdso-1d was
a "close but no cigar" type of guess that seems worthwhile to
add anyway.
Committed as above.
ld/testsuite:
* ld-cris/expalltst3, ld-cris/expdyn2.s, ld-cris/libdso-15.d,
ld-cris/expdref2.s, ld-cris/libdso-15b.d, ld-cris/expdyn1w.s,
ld-cris/libdso-1d.d: New tests.
bfd:
* elf32-cris.c (elf_cris_copy_indirect_symbol): Return without
action for symbols other than bfd_link_hash_indirect.
Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.91
diff -p -u -r1.91 elf32-cris.c
--- elf32-cris.c 15 Dec 2008 03:17:49 -0000 1.91
+++ elf32-cris.c 17 Dec 2008 01:54:03 -0000
@@ -3024,6 +3024,11 @@ elf_cris_copy_indirect_symbol (struct bf
edir = (struct elf_cris_link_hash_entry *) dir;
eind = (struct elf_cris_link_hash_entry *) ind;
+ /* Only indirect symbols are replaced; we're not interested in
+ updating any of EIND's fields for other symbols. */
+ if (eind->root.root.type != bfd_link_hash_indirect)
+ return;
+
BFD_ASSERT (edir->pcrel_relocs_copied == NULL);
BFD_ASSERT (edir->gotplt_offset == 0 || eind->gotplt_offset == 0);
Index: ld-cris/expalltst3
===================================================================
RCS file: ld-cris/expalltst3
diff -N ld-cris/expalltst3
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/expalltst3 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1 @@
+TST3 { global: *; };
Index: ld-cris/expdref2.s
===================================================================
RCS file: ld-cris/expdref2.s
diff -N ld-cris/expdref2.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/expdref2.s 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1,11 @@
+ .text
+ .global x
+ .type x,@function
+x:
+ move.d expobj2:GOT,$r10
+ move.d expobj2:PLT,$r10
+ move.d expfn2:GOT,$r10
+ move.d expfn2:PLT,$r10
+.Lfe1:
+ .size x,.Lfe1-x
+
Index: ld-cris/expdyn1w.s
===================================================================
RCS file: ld-cris/expdyn1w.s
diff -N ld-cris/expdyn1w.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/expdyn1w.s 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1,3 @@
+ .weak expobj
+ .weak expfn
+ .include "expdyn1.s"
Index: ld-cris/expdyn2.s
===================================================================
RCS file: ld-cris/expdyn2.s
diff -N ld-cris/expdyn2.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/expdyn2.s 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1,21 @@
+ .data
+ .global __expobj2
+ .type __expobj2,@object
+ .size __expobj2,4
+__expobj2:
+ .dword 0
+ .weak expobj2
+ .set expobj2,__expobj2
+
+ .text
+ .global _start
+_start:
+ nop
+ .global __expfn2
+__expfn2:
+ .type __expfn2,@function
+ nop
+.Lfe1:
+ .size __expfn2,.Lfe1-__expfn2
+ .weak expfn2
+ .set expfn2,__expfn2
Index: ld-cris/libdso-15.d
===================================================================
RCS file: ld-cris/libdso-15.d
diff -N ld-cris/libdso-15.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/libdso-15.d 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1,24 @@
+#source: expdyn2.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux --version-script $srcdir/$subdir/expalltst3
+#objdump: -s -T
+
+# A DSO that has two versioned symbols, each with a weak alias.
+# Each symbol is versioned.
+
+.*: file format elf32-cris
+
+DYNAMIC SYMBOL TABLE:
+#...
+0+2288 g[ ]+DO .data[ ]+0+4 TST3[ ]+__expobj2
+0+20a g[ ]+DF .text[ ]+0+2 TST3[ ]+__expfn2
+0+20a w[ ]+DF .text[ ]+0+2 TST3[ ]+expfn2
+0+2288 w[ ]+DO .data[ ]+0+4 TST3[ ]+expobj2
+#...
+Contents of section .text:
+ 0208 0f050f05 .*
+#...
+Contents of section .got:
+ 227c 0c220000 00000000 00000000 .*
+Contents of section .data:
+ 2288 00000000 .*
Index: ld-cris/libdso-15b.d
===================================================================
RCS file: ld-cris/libdso-15b.d
diff -N ld-cris/libdso-15b.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/libdso-15b.d 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1,36 @@
+#source: expdref2.s
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#ld_after_inputfiles: tmpdir/libdso-15.so
+#objdump: -s -T
+
+# A DSO that refers to two symbols in another DSO with
+# GOT/PLT-generating relocs, using weak aliases where the strong
+# definition is also in the other DSO.
+# There was a bug causing GOT markups to be during symbol handling,
+# with a newly added assertion failure and a reloc turned R_CRIS_NONE.
+
+.*: file format elf32-cris
+
+DYNAMIC SYMBOL TABLE:
+#...
+0+ w[ ]+DO \*UND\*[ ]+0+ TST3[ ]+__expobj2
+#...
+0+[ ]+DO \*UND\*[ ]+0+ TST3[ ]+expobj2
+0+[ ]+DF \*UND\*[ ]+0+ TST3[ ]+expfn2
+#...
+Contents of section .rela.dyn:
+ 01d4 fc220000 0a040000 00000000 00230000 .*
+ 01e4 0a050000 00000000 .*
+Contents of section .plt:
+ 01ec fce17e7e 0401307a 08013009 00000000 .*
+ 01fc 00000000 6f0d0c00 00003009 3f7e0000 .*
+ 020c 00002ffe ecffffff 6f0d1000 00003009 .*
+ 021c 3f7e0000 00002ffe ecffffff .*
+Contents of section .text:
+ 0228 6fae0c00 00006fae ccffffff 6fae1000 .*
+ 0238 00006fae d4ffffff .*
+#...
+Contents of section .got:
+ 22f0 40220000 00000000 00000000 00000000 .*
+ 2300 00000000 .*
Index: ld-cris/libdso-1d.d
===================================================================
RCS file: ld-cris/libdso-1d.d
diff -N ld-cris/libdso-1d.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld-cris/libdso-1d.d 17 Dec 2008 02:04:12 -0000
@@ -0,0 +1,36 @@
+#source: expdref1.s
+#source: expdyn1w.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux
+#ld_after_inputfiles: tmpdir/libdso-1b.so
+#objdump: -s -T
+
+# A DSO linked to another DSO that has two versioned symbols, to which
+# this DSO refers with two relocs each, a GOT and a PLT reference.
+# This DSO has weak definitions of those symbols.
+
+.*: file format elf32-cris
+
+DYNAMIC SYMBOL TABLE:
+#...
+0+1f2 w DF .text 0+2 expfn
+0+22a0 w DO .data 0+4 expobj
+#...
+Contents of section .rela.dyn:
+ 0184 98220000 0a020000 00000000 9c220000 .*
+ 0194 0a030000 00000000 .*
+Contents of section .plt:
+ 019c fce17e7e 0401307a 08013009 00000000 .*
+ 01ac 00000000 6f0d0c00 00003009 3f7e0000 .*
+ 01bc 00002ffe ecffffff 6f0d1000 00003009 .*
+ 01cc 3f7e0000 00002ffe ecffffff .*
+Contents of section .text:
+ 01d8 6fae1000 00006fae e0ffffff 6fae0c00 .*
+ 01e8 00006fae c0ffffff 0f050f05 .*
+Contents of section .dynamic:
+#...
+Contents of section .got:
+ 228c f4210000 00000000 00000000 00000000 .*
+ 229c 00000000 .*
+Contents of section .data:
+ 22a0 00000000 .*