loongarch: Add support for ELF psABI v2.00 relocations

A new set of relocation types was added in the LoongArch ELF psABI v2.00
spec [1], [2] to replace the stack-based scheme in v1.00. Toolchain
support is available from binutils 2.40 and gcc 13 onwards.

This patch adds support for the new relocation types, that are simpler
to handle (in particular, stack operations are gone). Support for the
v1.00 relocs are kept for now, for compatibility with older toolchains.

[1] https://github.com/loongson/LoongArch-Documentation/pull/57
[2] https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_appendix_revision_history

Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
This commit is contained in:
Wentao Guan
2024-08-25 16:05:11 +08:00
parent a12fcf90ed
commit 30b840dae2
7 changed files with 193 additions and 4 deletions

View File

@@ -57,6 +57,12 @@ void grub_loongarch64_sop_32_s_0_5_10_16_s2 (grub_loongarch64_stack_t stack,
void grub_loongarch64_sop_32_s_0_10_10_16_s2 (grub_loongarch64_stack_t stack,
grub_uint64_t *place);
void grub_loongarch64_b26 (grub_uint32_t *place, grub_int64_t offset);
void grub_loongarch64_xxx_hi20 (grub_uint32_t *place, grub_int64_t offset);
void grub_loongarch64_xxx_lo12 (grub_uint32_t *place, grub_int64_t offset);
void grub_loongarch64_xxx64_hi12 (grub_uint32_t *place, grub_int64_t offset);
void grub_loongarch64_xxx64_lo20 (grub_uint32_t *place, grub_int64_t offset);
#define GRUB_LOONGARCH64_RELOCATION(STACK, PLACE, OFFSET) \
case R_LARCH_SOP_PUSH_ABSOLUTE: \
grub_loongarch64_sop_push (STACK, OFFSET); \