grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 4/5] loongarch: Add ELF relocation types documentation and com


From: Xiaotian Wu
Subject: [PATCH v3 4/5] loongarch: Add ELF relocation types documentation and comments
Date: Tue, 13 Jun 2023 17:06:34 +0800

see https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#relocations

Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/kern/loongarch64/dl_helper.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/grub-core/kern/loongarch64/dl_helper.c 
b/grub-core/kern/loongarch64/dl_helper.c
index 879ae6189..b5d39b282 100644
--- a/grub-core/kern/loongarch64/dl_helper.c
+++ b/grub-core/kern/loongarch64/dl_helper.c
@@ -24,6 +24,10 @@
 #include <grub/i18n.h>
 #include <grub/loongarch64/reloc.h>
 
+/*
+ * 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);
-- 
2.40.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]