From 39d96c27d2ffdf6bb62e6e9bfb91860c6f703b5f Mon Sep 17 00:00:00 2001 From: U2FsdGVkX1 Date: Thu, 14 Dec 2023 10:26:12 +0800 Subject: [PATCH] Add riscv64 support --- ...RISC-V-Handle-R_RISCV_CALL_PLT-reloc.patch | 56 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 5 +- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 0285-RISC-V-Handle-R_RISCV_CALL_PLT-reloc.patch diff --git a/0285-RISC-V-Handle-R_RISCV_CALL_PLT-reloc.patch b/0285-RISC-V-Handle-R_RISCV_CALL_PLT-reloc.patch new file mode 100644 index 0000000..19f6221 --- /dev/null +++ b/0285-RISC-V-Handle-R_RISCV_CALL_PLT-reloc.patch @@ -0,0 +1,56 @@ +From 403d6540cd608b2706cfa0cb4713f7e4b490ff45 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 23 Feb 2023 13:15:08 -0800 +Subject: [PATCH] RISC-V: Handle R_RISCV_CALL_PLT reloc + +GNU assembler starting 2.40 release always generates R_RISCV_CALL_PLT +reloc for call in assembler [1], similarly LLVM does not make +distinction between R_RISCV_CALL_PLT and R_RISCV_CALL [2]. + +Fixes "grub-mkimage: error: relocation 0x13 is not implemented yet.". + +[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=70f35d72ef04cd23771875c1661c9975044a749c +[2] https://reviews.llvm.org/D132530 + +Signed-off-by: Khem Raj +Reviewed-by: Daniel Kiper +--- + grub-core/kern/riscv/dl.c | 1 + + util/grub-mkimagexx.c | 2 ++ + 2 files changed, 3 insertions(+) + +diff --git a/grub-core/kern/riscv/dl.c b/grub-core/kern/riscv/dl.c +index f26b12aaa..896653bb4 100644 +--- a/grub-core/kern/riscv/dl.c ++++ b/grub-core/kern/riscv/dl.c +@@ -188,6 +188,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, + break; + + case R_RISCV_CALL: ++ case R_RISCV_CALL_PLT: + { + grub_uint32_t *abs_place = place; + grub_ssize_t off = sym_addr - (grub_addr_t) place; +diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c +index a1927e786..c5fb336e9 100644 +--- a/util/grub-mkimagexx.c ++++ b/util/grub-mkimagexx.c +@@ -1294,6 +1294,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, + } + break; + case R_RISCV_CALL: ++ case R_RISCV_CALL_PLT: + { + grub_uint32_t hi20, lo12; + +@@ -1726,6 +1727,7 @@ translate_relocation_pe (struct translate_context *ctx, + case R_RISCV_BRANCH: + case R_RISCV_JAL: + case R_RISCV_CALL: ++ case R_RISCV_CALL_PLT: + case R_RISCV_PCREL_HI20: + case R_RISCV_PCREL_LO12_I: + case R_RISCV_PCREL_LO12_S: +-- +2.41.0 + diff --git a/grub.patches b/grub.patches index a9b6d49..1e0afb6 100644 --- a/grub.patches +++ b/grub.patches @@ -282,5 +282,6 @@ Patch0281: 0281-loongarch-Force-initrd-load-address-64KiB-alignment.patch Patch0282: 0282-loongarch-Implement-cache-synchronization-operation.patch Patch0283: 0283-loongarch-Fix-the-initrd-parameter-passing.patch Patch0284: 0284-loongarch-Disable-relaxation-relocations.patch +Patch0285: 0285-RISC-V-Handle-R_RISCV_CALL_PLT-reloc.patch Patch1000: 1000-change-to-use-fuse3.patch diff --git a/grub2.spec b/grub2.spec index 371b979..bca9119 100644 --- a/grub2.spec +++ b/grub2.spec @@ -1,4 +1,4 @@ -%define anolis_release 14 +%define anolis_release 15 %global _lto_cflags %{nil} %undefine _hardened_build @@ -506,6 +506,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Fri Nov 10 2023 Guoguo - 2.06-15 +- fix build error on riscv64 + * Wed Dec 06 2023 happy_orange -2.06-14 - rebuild for loongarch -- Gitee