h->non_got_ref = 1;
break;
+ /* Since shared library global symbols interpose, any
+ PC-relative relocations against external symbols
+ should not be used to build shared libraries. */
+ case R_LARCH_PCREL20_S2:
+ if (bfd_link_pic (info)
+ && (sec->flags & SEC_ALLOC) != 0
+ && (sec->flags & SEC_READONLY) != 0
+ && ! LARCH_REF_LOCAL (info, h))
+ return bad_static_reloc (abfd, rel, sec, r_type, h, NULL);
+
+ break;
+
/* For normal cmodel, pcalau12i + addi.d/w used to data.
For first version medium cmodel, pcalau12i + jirl are used to
function call, it need to creat PLT entry for STT_FUNC and
h->pointer_equality_needed = 1;
}
+ /* PC-relative relocations are allowed For first version
+ medium cmodel function call. */
+ if (h != NULL && !h->needs_plt
+ && bfd_link_pic (info)
+ && (sec->flags & SEC_ALLOC) != 0
+ && (sec->flags & SEC_READONLY) != 0
+ && ! LARCH_REF_LOCAL (info, h))
+ return bad_static_reloc (abfd, rel, sec, r_type, h, NULL);
+
break;
case R_LARCH_B16:
--- /dev/null
+#name: PC-relative relocation making shared
+#source: bad_pcala_hi20_global.s
+#target: [check_shared_lib_support]
+#ld: -shared --defsym global_a=0x10 --defsym global_b=0x20
+#error: .*: relocation R_LARCH_PCALA_HI20 against `global_b` can not be used when making a shared object; recompile with -fPIC
--- /dev/null
+ .hidden global_a
+ .text
+ .align 2
+main:
+ # Symbols defined .hidden are bound local and
+ # the linker should differenciate them.
+ la.pcrel $a0, global_a
+ la.pcrel $a0, global_b
--- /dev/null
+#name: PC-relative relocation making shared
+#source: bad_pcala_hi20_weak.s
+#target: [check_shared_lib_support]
+#ld: -shared --defsym global_a=0x10 --defsym global_b=0x20
+#error: .*: relocation R_LARCH_PCALA_HI20 against `global_b` can not be used when making a shared object; recompile with -fPIC
--- /dev/null
+ .hidden global_a
+ .weak global_b
+ .text
+ .align 2
+main:
+ # Symbols defined .hidden are bound local and
+ # the linker should differenciate them.
+ la.pcrel $a0, global_a
+ la.pcrel $a0, global_b
--- /dev/null
+#name: PC-relative relocation making shared
+#source: bad_pcrel20_s2_global.s
+#target: [check_shared_lib_support]
+#ld: -shared --defsym global_a=0x10 --defsym global_b=0x20
+#error: .*: relocation R_LARCH_PCREL20_S2 against `global_b` can not be used when making a shared object; recompile with -fPIC
--- /dev/null
+ .hidden global_a
+ .text
+ .align 2
+main:
+ # Symbols defined .hidden are bound local and
+ # the linker should differenciate them.
+ pcaddi $a0, %pcrel_20(global_a)
+ pcaddi $a0, %pcrel_20(global_b)
--- /dev/null
+#name: PC-relative relocation making shared
+#source: bad_pcrel20_s2_weak.s
+#target: [check_shared_lib_support]
+#ld: -shared --defsym global_a=0x10 --defsym global_b=0x20
+#error: .*: relocation R_LARCH_PCREL20_S2 against `global_b` can not be used when making a shared object; recompile with -fPIC
--- /dev/null
+ .hidden global_a
+ .weak global_b
+ .text
+ .align 2
+main:
+ # Symbols defined .hidden are bound local and
+ # the linker should differenciate them.
+ pcaddi $a0, %pcrel_20(global_a)
+ pcaddi $a0, %pcrel_20(global_b)
# R_LARCH_PCALA_HI20 only need to generate PLT entry for function symbols.
.text
.globl a
+ .hidden a
.data
.align 2
run_dump_test "relr-got-shared"
run_dump_test "relr-text-shared"
run_dump_test "abssym_shared"
+ run_dump_test "bad_pcala_hi20_global"
+ run_dump_test "bad_pcala_hi20_weak"
+ run_dump_test "bad_pcrel20_s2_global"
+ run_dump_test "bad_pcrel20_s2_weak"
}
if [check_pie_support] {