aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-02-21 01:46:42 +0000
committerMaciej W. Rozycki <macro@imgtec.com>2017-02-22 18:16:28 +0000
commit902e9fc76a0ec9f642cefa71ef88cca1c675ad54 (patch)
treefcdfccabdc62dace9dc54f36aecb7226f001600e /ld/testsuite/ld-elf
parent5ff6a06c215a5288787decfb933591afb5aa434d (diff)
downloadgdb-902e9fc76a0ec9f642cefa71ef88cca1c675ad54.zip
gdb-902e9fc76a0ec9f642cefa71ef88cca1c675ad54.tar.gz
gdb-902e9fc76a0ec9f642cefa71ef88cca1c675ad54.tar.bz2
PR ld/20828: Move symbol version processing ahead of GC symbol sweep
Complement commit b531344c34b0 ("PR ld/20828: Reorder the symbol sweep stage of section GC") and commit 81ff47b3a546 ("PR ld/20828: Fix linker script symbols wrongly forced local with section GC") and move symbol version processing ahead of the symbol sweep stage of section GC, all in `bfd_elf_size_dynamic_sections', so that version symbols created stay in the global scope and are not output as local symbols to the dynamic symbol table in the presence of corresponding symbol definitions pulled from a DSO involved in a link. Consolidate the whole of symbol version processing into a single block from all parts scattered across the function and rearranging the local variables used as necessary, however leaving the setting of dynamic entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version' section in the original places. With the rearrangement of code blocks `Elf_Internal_Verneed *t' would shadow the previous definition of `struct bfd_elf_version_tree *t', so rename the former variable to `vn'. bfd/ PR ld/20828 * elflink.c (bfd_elf_size_dynamic_sections): Move symbol version processing ahead of the call to `elf_gc_sweep_symbol'. ld/ PR ld/20828 * testsuite/ld-elf/pr20828-d.sd: New test. * testsuite/ld-elf/pr20828-e.sd: New test. * testsuite/ld-elf/pr20828-v.od: New test. * testsuite/ld-elf/pr20828-v.ver: New test version script. * testsuite/ld-elf/pr20828-v.ld: New test linker script. * testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and `.gnu.version_d'. * testsuite/ld-elf/shared.exp: Run the new tests.
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r--ld/testsuite/ld-elf/pr20828-d.sd9
-rw-r--r--ld/testsuite/ld-elf/pr20828-e.sd9
-rw-r--r--ld/testsuite/ld-elf/pr20828-v.ld18
-rw-r--r--ld/testsuite/ld-elf/pr20828-v.od5
-rw-r--r--ld/testsuite/ld-elf/pr20828-v.s13
-rw-r--r--ld/testsuite/ld-elf/pr20828-v.ver1
-rw-r--r--ld/testsuite/ld-elf/pr20828.ld2
-rw-r--r--ld/testsuite/ld-elf/shared.exp38
8 files changed, 94 insertions, 1 deletions
diff --git a/ld/testsuite/ld-elf/pr20828-d.sd b/ld/testsuite/ld-elf/pr20828-d.sd
new file mode 100644
index 0000000..a5777a4
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr20828-d.sd
@@ -0,0 +1,9 @@
+# Make sure `vdata' is global rather than local in the dynamic symbol table,
+# e.g.:
+# Num: Value Size Type Bind Vis Ndx Name
+# 1: 00000000 0 OBJECT GLOBAL DEFAULT ABS vdata
+# vs:
+# 1: 00000000 0 OBJECT LOCAL DEFAULT ABS vdata
+#...
+ *[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +ABS +vdata
+#pass
diff --git a/ld/testsuite/ld-elf/pr20828-e.sd b/ld/testsuite/ld-elf/pr20828-e.sd
new file mode 100644
index 0000000..893fb31
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr20828-e.sd
@@ -0,0 +1,9 @@
+# Make sure `edata' is global rather than local in the dynamic symbol table,
+# e.g.:
+# Num: Value Size Type Bind Vis Ndx Name
+# 1: 00000000 0 NOTYPE GLOBAL DEFAULT 1 edata@@vdata
+# vs:
+# 1: 00000000 0 NOTYPE LOCAL DEFAULT 1 edata@@vdata
+#...
+ *[0-9]+: +[0-9a-f]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +edata@@vdata
+#pass
diff --git a/ld/testsuite/ld-elf/pr20828-v.ld b/ld/testsuite/ld-elf/pr20828-v.ld
new file mode 100644
index 0000000..cdba796
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr20828-v.ld
@@ -0,0 +1,18 @@
+SECTIONS
+{
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .text : { *(.text) }
+ .dynamic : { *(.dynamic) }
+ .data : { *(.data) }
+ .symtab : { *(.symtab) }
+ .strtab : { *(.strtab) }
+ .shstrtab : { *(.shstrtab) }
+ .plt : { *(.plt) }
+ .got.plt : { *(.got.plt) }
+ .got : { *(.got) }
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-elf/pr20828-v.od b/ld/testsuite/ld-elf/pr20828-v.od
new file mode 100644
index 0000000..12953b9
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr20828-v.od
@@ -0,0 +1,5 @@
+#...
+Version definitions:
+1 0x01 0x0b2e1e3([12]) pr20828-v-\1
+2 0x00 0x0cc85d2f ver_foo
+#pass
diff --git a/ld/testsuite/ld-elf/pr20828-v.s b/ld/testsuite/ld-elf/pr20828-v.s
new file mode 100644
index 0000000..363e09f
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr20828-v.s
@@ -0,0 +1,13 @@
+ .text
+ .globl new_foo
+ .type new_foo, %function
+new_foo:
+ .size new_foo, . - new_foo
+ .symver new_foo, foo@@ver_foo
+
+ .data
+ .globl bar
+ .type bar, %object
+bar:
+ .dc.a foo
+ .size bar, . - bar
diff --git a/ld/testsuite/ld-elf/pr20828-v.ver b/ld/testsuite/ld-elf/pr20828-v.ver
new file mode 100644
index 0000000..addc0f0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr20828-v.ver
@@ -0,0 +1 @@
+vdata { global: edata; local: *; };
diff --git a/ld/testsuite/ld-elf/pr20828.ld b/ld/testsuite/ld-elf/pr20828.ld
index 0166f52..034887d 100644
--- a/ld/testsuite/ld-elf/pr20828.ld
+++ b/ld/testsuite/ld-elf/pr20828.ld
@@ -10,6 +10,8 @@ SECTIONS
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
.shstrtab : { *(.shstrtab) }
.symtab : { *(.symtab) }
.strtab : { *(.strtab) }
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 3b8ab18..41fb2ba 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -50,6 +50,8 @@ if [istarget "tic6x-*-*"] {
# - the shared library symbols have been swept in section garbage collection.
# Verify that the symbols are global rather than local and that a version
# script adjusts them accordingly.
+# Also verify that a version definition supplied by an object rather than
+# a version script and forcibly exported is unaffected by section GC.
if { [check_gc_sections_available] } {
run_ld_link_tests [list \
[list \
@@ -77,7 +79,41 @@ if { [check_gc_sections_available] } {
{pr20828.s} \
{{readelf --dyn-syms pr20828-b.sd} \
{readelf --dyn-syms pr20828-c.sd}} \
- "pr20828-2.so"]]
+ "pr20828-2.so"] \
+ [list \
+ "PR ld/20828 dynamic symbols with section GC\
+ (versioned shared library)" \
+ "$LFLAGS -shared --gc-sections -T pr20828.ld\
+ --version-script=pr20828-v.ver" \
+ "" "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-c.sd} \
+ {readelf --dyn-syms pr20828-d.sd} \
+ {readelf --dyn-syms pr20828-e.sd}} \
+ "libpr20828-v.so"] \
+ [list \
+ "PR ld/20828 dynamic symbols with section GC (versioned)" \
+ "$LFLAGS -shared --gc-sections -T pr20828.ld\
+ --version-script=pr20828-v.ver" \
+ "tmpdir/libpr20828-v.so" \
+ "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-c.sd} \
+ {readelf --dyn-syms pr20828-d.sd} \
+ {readelf --dyn-syms pr20828-e.sd}} \
+ "pr20828-v.so"] \
+ [list \
+ "PR ld/20828 forcibly exported symbol version without section GC" \
+ "$LFLAGS -e foo -E -T pr20828-v.ld" "" "" \
+ {pr20828-v.s} \
+ {{objdump -p pr20828-v.od}} \
+ "pr20828-v-1"] \
+ [list \
+ "PR ld/20828 forcibly exported symbol version with section GC" \
+ "$LFLAGS -e foo --gc-sections -E -T pr20828-v.ld" "" "" \
+ {pr20828-v.s} \
+ {{objdump -p pr20828-v.od}} \
+ "pr20828-v-2"]]
}
# Check to see if the C compiler works