Committed, CRIS: Fix GOTPLT reloc-after-definition for hidden symbol
Hans-Peter Nilsson
hp@bitrange.com
Tue Sep 7 18:34:00 GMT 2004
The straightforward reloc-after-definition case was buggy
(i.e. when the hide_symbol function is *not* executed), because
the cris_elf_check_relocs function tried to eliminate PLT
entries early. This caused GOTPLT handling to derail. The
error message then SEGV:d, because symname was NULL. Gah.
Found in the process of making a testcase for the suspicous
hide_symbol bug.
bfd:
* elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_16_GOTPLT,
case R_CRIS_32_GOTPLT>: For internal error message, handle NULL
symname.
(cris_elf_check_relocs) <case R_CRIS_32_PLT_PCREL>: Don't try to
handle symbol visibility here.
ld/testsuite:
* ld-cris/hiddef1.d, ld-cris/hiddef1.d, ld-cris/hidrefgotplt1.s:
New test.
Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.53
diff -u -p -r1.53 elf32-cris.c
--- elf32-cris.c 13 Aug 2004 03:15:56 -0000 1.53
+++ elf32-cris.c 7 Sep 2004 18:01:22 -0000
@@ -982,7 +982,8 @@ cris_elf_relocate_section (output_bfd, i
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
- symname[0] != '\0' ? symname : _("[whose name is lost]"));
+ (symname != NULL && symname[0] != '\0'
+ ? symname : _("[whose name is lost]")));
/* FIXME: Perhaps blaming input is not the right thing to
do; this is probably an internal error. But it is true
@@ -2468,9 +2469,13 @@ cris_elf_check_relocs (abfd, info, sec,
don't need to generate a procedure linkage table entry
after all. */
- /* If this is a local symbol, we resolve it directly without
- creating a procedure linkage table entry. */
- if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+ /* Beware: if we'd check for visibility of the symbol here
+ (and not marking the need for a PLT when non-visible), we'd
+ get into trouble with keeping handling consistent with
+ regards to relocs found before definition and GOTPLT
+ handling. Eliminable PLT entries will be dealt with later
+ anyway. */
+ if (h == NULL)
continue;
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
--- /dev/null Tue Oct 29 15:57:07 2002
+++ testsuite/ld-cris/hiddef1.d Tue Sep 7 19:24:24 2004
@@ -0,0 +1,28 @@
+#source: gotrel1.s
+#source: hiddef1.s
+#source: hidrefgotplt1.s
+#ld: -shared -m crislinux
+#as: --pic --no-underscore -I$srcdir/$subdir
+#readelf: -S -s -r
+
+# Regression test for mishandling of GOTPLT relocs against a
+# hidden symbol, where the reloc is found after the symbol
+# definition. There should be no PLT, just a single GOT entry
+# from a GOTPLT reloc moved to the .got section. It's hard to
+# check for absence of a .plt section, so we just check the
+# number of symbols and sections. When the number of symbols
+# and sections change, make sure that there's no .plt and that
+# dsofn is hidden (not exported as a dynamic symbol).
+
+There are 13 section headers, starting at offset 0x[0-9a-f]+:
+#...
+ \[[ 0-9]+\] \.got PROGBITS [0-9a-f]+ [0-9a-f]+ 0+10 04 WA 0 0 4
+#...
+Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+#...
+[0-9a-f]+ 0+c R_CRIS_RELATIVE [0-9a-f]+
+#...
+Symbol table '\.dynsym' contains 10 entries:
+#...
+Symbol table '\.symtab' contains 21 entries:
+#pass
--- /dev/null Tue Oct 29 15:57:07 2002
+++ testsuite/ld-cris/hiddef1.s Tue Sep 7 19:22:17 2004
@@ -0,0 +1,2 @@
+ .include "dso-1.s"
+ .hidden dsofn
--- /dev/null Tue Oct 29 15:57:07 2002
+++ testsuite/ld-cris/hidrefgotplt1.s Tue Sep 7 20:00:03 2004
@@ -0,0 +1,2 @@
+ .text
+ move.d [$r0+dsofn:GOTPLT],$r1
brgds, H-P
More information about the Binutils
mailing list