+2017-12-04 Jim Wilson <jimw@sifive.com>
+
+ * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Mark
+ __global_pointer$ as HIDDEN.
+ * testsuite/ld-riscv-elf/gp-hidden-64.rd: New.
+ * testsuite/ld-riscv-elf/gp-hidden-lib.rd: New.
+ * testsuite/ld-riscv-elf/gp-hidden-lib.s: New.
+ * testsuite/ld-riscv-elf/gp-hidden-ver-64.rd: New.
+ * testsuite/ld-riscv-elf/gp-hidden-ver.rd: New.
+ * testsuite/ld-riscv-elf/gp-hidden-ver.s: New.
+ * testsuite/ld-riscv-elf/gp-hidder-ver.ver: New.
+ * testsuite/ld-riscv-elf/gp-hidden.rd: New.
+ * testsuite/ld-riscv-elf/gp-hidden.s: New.
+ * testsuite/ld-riscv-elf/gp-hidden.sd: New.
+ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Change riscv to riscv*.
+ Run the new tests with run_ld_link_tests.
+
2017-12-04 Alan Modra <amodra@gmail.com>
* testsuite/ld-i386/pr17935-1.d: Adjust expected error.
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
-SDATA_START_SYMBOLS="__global_pointer$ = . + 0x800;
+SDATA_START_SYMBOLS="HIDDEN (__global_pointer$ = . + 0x800);
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)"
INITIAL_READONLY_SECTIONS=".interp : { *(.interp) } ${CREATE_PIE-${INITIAL_READONLY_SECTIONS}}"
--- /dev/null
+
+Relocation section '\.rela\.dyn' at offset .* contains 1 entry:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name \+ Addend
+[0-9a-f]+ * [0-9a-f]+02 * R_RISCV_64 * [0-9a-f]+ * foo \+ 0
--- /dev/null
+
+Relocation section '\.rela\.dyn' at offset .* contains 1 entry:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name \+ Addend
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+03 * R_RISCV_RELATIVE * [0-9a-f]+
--- /dev/null
+ .data
+ .globl bar
+ .type bar, @object
+bar:
+ .dc.a __global_pointer$
+ .size bar, . - bar
--- /dev/null
+
+Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name \+ Addend
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+03 * R_RISCV_RELATIVE * [0-9a-f]+
+[0-9a-f]+ * [0-9a-f]+02 * R_RISCV_64 * [0-9a-f]+ * bar \+ 0
--- /dev/null
+
+Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name \+ Addend
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+03 * R_RISCV_RELATIVE * [0-9a-f]+
+[0-9a-f]+ * [0-9a-f]+01 * R_RISCV_32 * [0-9a-f]+ * bar \+ 0
--- /dev/null
+ .data
+ .globl foo
+ .type foo, @object
+foo:
+ .dc.a bar
+ .dc.a __global_pointer$
+ .size foo, . - foo
--- /dev/null
+{ global: foo; local: *; };
--- /dev/null
+
+Relocation section '\.rela\.dyn' at offset .* contains 1 entry:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name \+ Addend
+[0-9a-f]+ * [0-9a-f]+01 * R_RISCV_32 * [0-9a-f]+ * foo \+ 0
--- /dev/null
+ .data
+ .globl blah
+ .type blah, @object
+blah:
+ .dc.a foo
+ .dc.a __global_pointer$
+ .size blah, . - blah
--- /dev/null
+
+Symbol table '.dynsym' contains [0-9]+ entries:
+ * Num: * Value * Size * Type * Bind * Vis * Ndx * Name
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ * Num: * Value * Size * Type * Bind * Vis * Ndx * Name
+#...
+ * [0-9a-f]+: * [0-9a-f]+ * 0 * NOTYPE * LOCAL * DEFAULT .* __global_pointer\$
+#pass
# MA 02110-1301, USA.
#
-if [istarget "riscv-*-*"] {
+if [istarget "riscv*-*-*"] {
run_dump_test "c-lui"
+
+ set abis { rv32gc ilp32 elf32lriscv rv64gc lp64 elf64lriscv }
+ foreach { arch abi emul } $abis {
+ # This checks whether our linker scripts get the scope of
+ # __global_pointer$ right, and thus must therefore use default scripts.
+ set suff64 [string map {ilp32 "" lp64 -64} $abi]
+ run_ld_link_tests [list \
+ [list "gp scope test ($abi shared library)" \
+ "-m$emul -shared" "" \
+ "-march=$arch -mabi=$abi -fpic" \
+ { gp-hidden-lib.s } \
+ [list \
+ "readelf --relocs gp-hidden-lib.rd" \
+ "readelf --syms gp-hidden.sd"] \
+ "gp-hidden-lib-${abi}.so"] \
+ [list "gp scope test ($abi versioned lib)" \
+ "-m$emul -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
+ "-march=$arch -mabi=$abi -fpic" \
+ { gp-hidden-ver.s } \
+ [list \
+ "readelf --relocs gp-hidden-ver${suff64}.rd" \
+ "readelf --syms gp-hidden.sd"] \
+ "gp-hidden-ver-${abi}.so"] \
+ [list "gp scope test ($abi executable)" \
+ "-m$emul -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
+ "-march=$arch -mabi=$abi" \
+ {gp-hidden.s} \
+ [list \
+ "readelf --relocs gp-hidden${suff64}.rd" \
+ "readelf --syms gp-hidden.sd"]\
+ "gp-hidden-${abi}"]]
+ }
}