Reference commit
1dcb9720d62cd053a72c31881b7724ce9f74332c
bfd/
* elfnn-riscv.c (RISCV_COPY_INPUT_RELOC): Bind defined symbol
locally in PIE.
ld/
* testsuite/ld-riscv-elf/pie-bind-locally-a.s: New test source.
* testsuite/ld-riscv-elf/pie-bind-locally-b.s: Likewise.
* testsuite/ld-riscv-elf/pie-bind-locally-rv32.d: New testcase.
* testsuite/ld-riscv-elf/pie-bind-locally-rv64.d: Likewise.
Signed-off-by: Linsen Zhou <i@lin.moe>
((H) != NULL \
&& (H)->dynindx != -1 \
&& (!bfd_link_pic (INFO) \
- || !SYMBOLIC_BIND ((INFO), (H)) \
+ || !(bfd_link_pie ((INFO)) || SYMBOLIC_BIND ((INFO), (H))) \
|| !(H)->def_regular))
/* True if this is actually a static link, or it is a -Bsymbolic link
run_dump_test "zicfilp-unlabeled-plt"
+ run_dump_test "pie-bind-locally-rv32"
+ run_dump_test "pie-bind-locally-rv64"
+
# IFUNC testcases.
# Check IFUNC by single type relocs.
run_dump_test_ifunc "ifunc-reloc-call-01" rv32 exe
--- /dev/null
+ .text
+ .global _start
+_start:
+ .option pic
+ la a0, _start
--- /dev/null
+ .section .data.rel,"aw",%progbits
+ .type q, %object
+q:
+.ifdef __64_bit__
+ .quad _start
+.else
+ .word _start
+.endif
--- /dev/null
+#source: pie-bind-locally-a.s
+#source: pie-bind-locally-b.s
+#as: -march=rv32i -mabi=ilp32
+#ld: -m[riscv_choose_ilp32_emul] -pie
+#readelf: -Wr
+
+Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_RELATIVE[ ].*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_RELATIVE[ ].*
--- /dev/null
+#source: pie-bind-locally-a.s
+#source: pie-bind-locally-b.s
+#as: -march=rv64i -mabi=lp64 -defsym __64_bit__=1
+#ld: -m[riscv_choose_lp64_emul] -pie
+#readelf: -Wr
+
+Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_RELATIVE[ ].*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_RELATIVE[ ].*