summaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-cris
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-04-05 15:10:05 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-04-05 15:14:54 +0100
commit1f599d0e7b5039c814731293043e247304ec006b (patch)
treeb1b07c8c700a397f5002a102723f05ac24a14d2e /ld/testsuite/ld-cris
parenta9fa4610b8b6dbd8dd91d0ea37141b1182c1837c (diff)
downloadbinutils-gdb-1f599d0e7b5039c814731293043e247304ec006b.tar.gz
ELF/LD: Avoid producing hidden and internal dynamic symbols
Always turn hidden and internal symbols which have a dynamic index into local ones. This is required by the the ELF gABI[1]: "A hidden symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." "An internal symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." The ELF linker usually respects this requirement, however in the case where a dynamic symbol has been preallocated due to a reference of the default export class aka visibility from the object being linked, and then merged with a hidden or internal symbol definition from within the same object, then the original export class is carried over to the output dynamic symbol table, because while merging the generic ELF linker only converts affected dynamic symbols to local when they are defined or referenced by the object being linked and a dynamic object involved in the link both at a time. The dynamic symbol produced confuses then the dynamic loader at the run time -- the hidden or internal export class is ignored and the symbol follows preemption rules as with the default export class. In the MIPS target it happens when `mips_elf_record_global_got_symbol' creates a dynamic symbol when a call relocation is encountered. Additionally if the undefined symbol referred by such a relocation does specify the intended export class, then a local dynamic symbol is created instead, which is harmless and allowed, but useless. Normally no local dynamic symbols are created, except for a single dummy one at the beginning. Correct the problem by removing the extra check for a dynamic symbol being defined or referenced by the object being linked and a dynamic object involved in the link both at a time. The test cases included cover the internal and hidden symbol cases, as well as a protected symbol for a reference, the handling of which is unchanged by this fix. Both cases described above are covered, that is where an internal or hidden dynamic symbol is produced and where a local one is. NB this change affects CRIS results where some symbols in the static table produced in a final link are now converted from STV_HIDDEN to STB_LOCAL. This happens whenever the `elf_backend_hide_symbol' handler is called, so the affected symbols must have been chosen for entering into the dynamic symbol table, except in these test cases no such symbol table is produced. In fully linked binaries the static symbol table is only used for debugging though, so such a change is fine. References: [1] "System V Application Binary Interface - DRAFT - 24 April 2001", The Santa Cruz Operation, Inc., "Symbol Table", <http://www.sco.com/developers/gabi/2001-04-24/ch4.symtab.html> bfd/ PR ld/19908 * elflink.c (elf_link_add_object_symbols): Always turn hidden and internal symbols which have a dynamic index into local ones. ld/ PR ld/19908 * testsuite/ld-cris/tls-e-20.d: Adjust for hidden symbol handling fix. * testsuite/ld-cris/tls-e-20a.d: Likewise. * testsuite/ld-cris/tls-e-21.d: Likewise. * testsuite/ld-cris/tls-e-23.d: Likewise. * testsuite/ld-cris/tls-e-80.d: Likewise. * testsuite/ld-cris/tls-gd-3h.d: Likewise. * testsuite/ld-cris/tls-leie-19.d: Likewise. * testsuite/ld-mips-elf/export-class-ref-lib.sd: New test. * testsuite/ld-mips-elf/export-hidden-ref.sd: New test. * testsuite/ld-mips-elf/export-internal-ref.sd: New test. * testsuite/ld-mips-elf/export-protected-ref.sd: New test. * testsuite/ld-mips-elf/export-class-ref-f0.s: New test source. * testsuite/ld-mips-elf/export-class-ref-f1.s: New test source. * testsuite/ld-mips-elf/export-class-ref-f2.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld/testsuite/ld-cris')
-rw-r--r--ld/testsuite/ld-cris/tls-e-20.d2
-rw-r--r--ld/testsuite/ld-cris/tls-e-20a.d2
-rw-r--r--ld/testsuite/ld-cris/tls-e-21.d2
-rw-r--r--ld/testsuite/ld-cris/tls-e-23.d2
-rw-r--r--ld/testsuite/ld-cris/tls-e-80.d2
-rw-r--r--ld/testsuite/ld-cris/tls-gd-3h.d2
-rw-r--r--ld/testsuite/ld-cris/tls-leie-19.d8
7 files changed, 10 insertions, 10 deletions
diff --git a/ld/testsuite/ld-cris/tls-e-20.d b/ld/testsuite/ld-cris/tls-e-20.d
index 6b4e7142cea..eb323a59804 100644
--- a/ld/testsuite/ld-cris/tls-e-20.d
+++ b/ld/testsuite/ld-cris/tls-e-20.d
@@ -35,8 +35,8 @@ SYMBOL TABLE:
0+80094 l d \.text 0+ \.text
0+820b0 l d \.tdata 0+ \.tdata
0+820bc l d \.got 0+ \.got
+0+ l \.tdata 0+4 x
0+820bc l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+ g \.tdata 0+4 \.hidden x
0+80098 g F \.text 0+6 tlsdsofn2
0+8 g \.tdata 0+4 \.hidden x2
0+80094 g \.text 0+ _start
diff --git a/ld/testsuite/ld-cris/tls-e-20a.d b/ld/testsuite/ld-cris/tls-e-20a.d
index 13b3be8b824..7d5a95e8b26 100644
--- a/ld/testsuite/ld-cris/tls-e-20a.d
+++ b/ld/testsuite/ld-cris/tls-e-20a.d
@@ -43,8 +43,8 @@ SYMBOL TABLE:
0+ l df \*ABS\* 0+ .*
0+ l \.tdata 0+80 tls128
0+ l df \*ABS\* 0+ .*
+0+80 l \.tdata 0+4 x
0+82168 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+80 g \.tdata 0+4 \.hidden x
0+800c4 g F \.text 0+6 tlsdsofn2
0+821b4 g O \.data 0+4 got7var5
0+88 g \.tdata 0+4 \.hidden x2
diff --git a/ld/testsuite/ld-cris/tls-e-21.d b/ld/testsuite/ld-cris/tls-e-21.d
index fa56b9faad8..80ca3e37f77 100644
--- a/ld/testsuite/ld-cris/tls-e-21.d
+++ b/ld/testsuite/ld-cris/tls-e-21.d
@@ -19,7 +19,7 @@ private flags = 0:
#...
SYMBOL TABLE:
#...
-0+80 g \.tdata 0+4 \.hidden x
+0+80 l \.tdata 0+4 x
#...
Contents of section \.text:
#...
diff --git a/ld/testsuite/ld-cris/tls-e-23.d b/ld/testsuite/ld-cris/tls-e-23.d
index 499899edf76..a09d55ef901 100644
--- a/ld/testsuite/ld-cris/tls-e-23.d
+++ b/ld/testsuite/ld-cris/tls-e-23.d
@@ -19,7 +19,7 @@ private flags = 0:
#...
SYMBOL TABLE:
#...
-0+80 g \.tdata 0+4 \.hidden x
+0+80 l \.tdata 0+4 x
#...
Contents of section \.text:
#...
diff --git a/ld/testsuite/ld-cris/tls-e-80.d b/ld/testsuite/ld-cris/tls-e-80.d
index 7a6f4599e93..15ce3d7838b 100644
--- a/ld/testsuite/ld-cris/tls-e-80.d
+++ b/ld/testsuite/ld-cris/tls-e-80.d
@@ -42,8 +42,8 @@ SYMBOL TABLE:
0+820c0 l d \.tdata 0+ \.tdata
0+820d0 l d \.tbss 0+ \.tbss
0+820d0 l d \.got 0+ \.got
+0+ l \.tdata 0+4 x
0+820d0 l O \.got 0+ _GLOBAL_OFFSET_TABLE_
-0+ g \.tdata 0+4 \.hidden x
0+800a0 g F \.text 0+6 tlsdsofn2
0+800a8 g F \.text 0+6 tlsfn12
0+c g \.tdata 0+4 \.hidden x2
diff --git a/ld/testsuite/ld-cris/tls-gd-3h.d b/ld/testsuite/ld-cris/tls-gd-3h.d
index 78f109da8fa..898a670e164 100644
--- a/ld/testsuite/ld-cris/tls-gd-3h.d
+++ b/ld/testsuite/ld-cris/tls-gd-3h.d
@@ -19,7 +19,7 @@ private flags = 0:
#...
SYMBOL TABLE:
#...
-0+80 g \.tdata 0+4 \.hidden x
+0+80 l \.tdata 0+4 x
#...
Contents of section \.text:
#...
diff --git a/ld/testsuite/ld-cris/tls-leie-19.d b/ld/testsuite/ld-cris/tls-leie-19.d
index 6cf69b23f75..859e2e64dd8 100644
--- a/ld/testsuite/ld-cris/tls-leie-19.d
+++ b/ld/testsuite/ld-cris/tls-leie-19.d
@@ -26,13 +26,13 @@ private flags = 0:
CONTENTS.*
SYMBOL TABLE:
#...
-0+88 g .tdata 0+4 x
+0+84 l \.tdata 0+4 x2
#...
-0+84 g \.tdata 0+4 \.hidden x2
+0+80 l \.tdata 0+4 x1
#...
-0+8c g .tdata 0+4 z
+0+88 g .tdata 0+4 x
#...
-0+80 g \.tdata 0+4 \.hidden x1
+0+8c g .tdata 0+4 z
#...
Contents of section \.text:
#...