It's werid if it's absolute symbol but have a relative reloc for got entry
under pie. So don't generate relative reloc if symbol referenced section is
SH_ABS. However, x86 allows the absolute symbol defined in linker script has
a relative reloc, not sure if risc-v needs this or not.
if (h->dynindx == -1
&& !h->forced_local
&& h->root.type != bfd_link_hash_undefweak
- && bfd_link_pic (info))
+ && bfd_link_pic (info)
+ && !bfd_is_abs_section(h->root.u.def.section))
relative_got = true;
bfd_put_NN (output_bfd, relocation,
--- /dev/null
+#source: absolute-no-relative.s
+#as:
+#ld: -Tabsolute-no-relative.ld -pie
+#readelf: -Wr
+
+Relocation section '.rela.dyn' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+0+[ ]+0+[ ]+R_RISCV_NONE[ ]+0
+0+[ ]+0+[ ]+R_RISCV_NONE[ ]+0
--- /dev/null
+ENTRY(_start)
+SECTIONS {
+ __symbol_abs__ = 0x1234;
+ .text 0x10000 : { *(.text*)}
+ .got 0x20000 : { *(.got*) }
+}
--- /dev/null
+.text
+.global _start
+_start:
+lga x1, symbol_abs
+lga x1, __symbol_abs__
+
+.global symbol_abs
+.set symbol_abs, 0x100
}
run_dump_test "tls"
run_dump_test "tlsbin"
+ run_dump_test "absolute-no-relative"
}