mengqinggang e493ba6255 LoongArch: Fix linker generate PLT entry for data symbol
With old "medium" code model, we call a function with a pair of PCALAU12I
and JIRL instructions. The assembler produces something like:

   8:	1a00000c 	pcalau12i   	$t0, 0
			8: R_LARCH_PCALA_HI20	g
   c:	4c000181 	jirl        	$ra, $t0, 0
			c: R_LARCH_PCALA_LO12	g

The linker generates a "PLT entry" for data without any diagnostic.
If "g" is a data symbol and ld with -shared option, it may load two
instructions in the PLT.

Without -shared option, loongarch_elf_adjust_dynamic_symbol can delete PLT
entry.

For R_LARCH_PCALA_HI20 relocation, linker only generate PLT entry for STT_FUNC
and STT_GNU_IFUNC symbols.
2024-01-04 19:08:53 +08:00

21 lines
363 B
ArmAsm

# The first version medium codel model function call is: pcalau12i + jirl.
# R_LARCH_PCALA_HI20 only need to generate PLT entry for function symbols.
.text
.globl a
.data
.align 2
.type a, @object
.size a, 4
a:
.word 1
.text
.align 2
.globl test
.type test, @function
test:
pcalau12i $r12,%pc_hi20(a)
ld.w $r12,$r12,%pc_lo12(a)
.size test, .-test