mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 14:59:34 +00:00
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>
This commit is contained in:
1 parent
b264f098be
commit
0b4693e32c
7 files changed
+193
-4
No files matched your search
@@ -199,3 +199,62 @@ grub_loongarch64_sop_32_s_0_10_10_16_s2 (grub_loongarch64_stack_t stack,
|
||||
*place =(*place) | (((a >> 2) & 0xffff) << 10);
|
||||
*place =(*place) | ((a >> 18) & 0x3ff);
|
||||
}
|
||||
|
||||
void grub_loongarch64_b26 (grub_uint32_t *place, grub_int64_t offset)
|
||||
{
|
||||
grub_uint32_t val;
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfc000000);
|
||||
|
||||
grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n",
|
||||
place, offset > 0 ? '+' : '-',
|
||||
offset < 0 ? (long long) -(unsigned long long) offset : offset);
|
||||
|
||||
val = ((offset >> 18) & 0x3ff) | (((offset >> 2) & 0xffff) << 10);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (val) & ~insmask;
|
||||
}
|
||||
|
||||
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);
|
||||
grub_uint32_t val;
|
||||
|
||||
offset >>= 12;
|
||||
val = ((offset & 0xfffff) << 5);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (val) & ~insmask;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (offset << 10) & ~insmask;
|
||||
}
|
||||
|
||||
void grub_loongarch64_xxx64_hi12 (grub_uint32_t *place, grub_int64_t offset)
|
||||
{
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff);
|
||||
grub_uint32_t val;
|
||||
|
||||
offset >>= 52;
|
||||
val = ((offset & 0xfff) << 10);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (val) & ~insmask;
|
||||
}
|
||||
|
||||
void grub_loongarch64_xxx64_lo20 (grub_uint32_t *place, grub_int64_t offset)
|
||||
{
|
||||
const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfe00001f);
|
||||
grub_uint32_t val;
|
||||
|
||||
offset >>= 32;
|
||||
val = ((offset & 0xfffff) << 5);
|
||||
|
||||
*place &= insmask;
|
||||
*place |= grub_cpu_to_le32 (val) & ~insmask;
|
||||
}
|
||||
Reference in new issue
Block a user