From: Xiaotian Wu Date: Tue, 13 Jun 2023 09:06:34 +0000 (+0800) Subject: loongarch: Add ELF relocation types documentation and comments X-Git-Tag: grub-2.12-rc1~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=857af0e17b3f8df8a2e1b355e159c48ddb801419;p=thirdparty%2Fgrub.git loongarch: Add ELF relocation types documentation and comments See https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#relocations Signed-off-by: Xiaotian Wu Reviewed-by: Daniel Kiper --- diff --git a/grub-core/kern/loongarch64/dl_helper.c b/grub-core/kern/loongarch64/dl_helper.c index 879ae6189..006e8500e 100644 --- a/grub-core/kern/loongarch64/dl_helper.c +++ b/grub-core/kern/loongarch64/dl_helper.c @@ -24,6 +24,10 @@ #include #include +/* + * LoongArch relocations documentation: + * https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#relocations + */ static void grub_loongarch64_stack_push (grub_loongarch64_stack_t stack, grub_uint64_t x); static grub_uint64_t grub_loongarch64_stack_pop (grub_loongarch64_stack_t stack); @@ -200,6 +204,11 @@ grub_loongarch64_sop_32_s_0_10_10_16_s2 (grub_loongarch64_stack_t stack, *place =(*place) | ((a >> 18) & 0x3ff); } +/* + * B26 relocation for the 28-bit PC-relative jump + * (*(uint32_t *) PC) [9 ... 0] = (S + A - PC) [27 ... 18] + * (*(uint32_t *) PC) [25 ... 10] = (S + A - PC) [17 ... 2] + */ void grub_loongarch64_b26 (grub_uint32_t *place, grub_int64_t offset) { grub_uint32_t val; @@ -215,6 +224,10 @@ void grub_loongarch64_b26 (grub_uint32_t *place, grub_int64_t offset) *place |= grub_cpu_to_le32 (val) & ~insmask; } +/* + * ABS_HI20/PCALA_HI20 relocations for 32/64-bit absolute address/PC-relative offset + * (*(uint32_t *) PC) [24 ... 5] = (S + A) [31 ... 12] + */ void grub_loongarch64_xxx_hi20 (grub_uint32_t *place, grub_int64_t offset) { const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfe00001f); @@ -227,6 +240,10 @@ void grub_loongarch64_xxx_hi20 (grub_uint32_t *place, grub_int64_t offset) *place |= grub_cpu_to_le32 (val) & ~insmask; } +/* + * ABS_LO12/PCALA_LO12 relocations for 32/64-bit absolute address + * (*(uint32_t *) PC) [21 ... 10] = (S + A) [11 ... 0] + */ void grub_loongarch64_xxx_lo12 (grub_uint32_t *place, grub_int64_t offset) { const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff); @@ -235,6 +252,10 @@ void grub_loongarch64_xxx_lo12 (grub_uint32_t *place, grub_int64_t offset) *place |= grub_cpu_to_le32 (offset << 10) & ~insmask; } +/* + * ABS64_HI12 relocation for the 64-bit absolute address + * (*(uint32_t *) PC) [21 ... 10] = (S + A) [63 ... 52] + */ void grub_loongarch64_abs64_hi12 (grub_uint32_t *place, grub_int64_t offset) { const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff); @@ -247,6 +268,10 @@ void grub_loongarch64_abs64_hi12 (grub_uint32_t *place, grub_int64_t offset) *place |= grub_cpu_to_le32 (val) & ~insmask; } +/* + * ABS64_LO20 relocation for the 64-bit absolute address + * (*(uint32_t *) PC) [24 ... 5] = (S + A) [51 ... 32] + */ void grub_loongarch64_abs64_lo20 (grub_uint32_t *place, grub_int64_t offset) { const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfe00001f);