diff --git a/0284-loongarch-Disable-relaxation-relocations.patch b/0284-loongarch-Disable-relaxation-relocations.patch new file mode 100644 index 0000000000000000000000000000000000000000..bd7ce8dc5987cebac6e8af4ed98dad341242915b --- /dev/null +++ b/0284-loongarch-Disable-relaxation-relocations.patch @@ -0,0 +1,64 @@ +From 5cba5bf765c9fc417258f265979c6a7a795705bc Mon Sep 17 00:00:00 2001 +From: Xiaotian Wu +Date: Thu, 15 Jun 2023 20:10:38 +0800 +Subject: [PATCH] loongarch: Disable relaxation relocations + +commit 87247635c0d583cfbc1947107d23b40877d107b8 upstream. + +A working GRUB cannot be built with upcoming binutils and GCC, because linker +relaxation was added [1] causing new unsupported relocations to appear in modules. + +So we pass -mno-relax to GCC if it is supported, to disable relaxation and make +GRUB forward-compatible with new toolchains. + +While similar code already exists for sparc64 in configure.ac, sparc64 sets +LDFLAGS while LoongArch requires CFLAGS to be set. If we only set LDFLAGS on +LoongArch, GCC will still generate relaxation relocations in the .o files, so +the sparc64 code cannot be reused. + +[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=56576f4a722b7398d35802ecf7d4185c27d6d69b + +Signed-off-by: Xiaotian Wu +Reviewed-by: Daniel Kiper +Signed-off-by: Yingkun Meng +--- + configure.ac | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/configure.ac b/configure.ac +index dea4dfe..469e3ad 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -908,6 +908,29 @@ if test "x$target_cpu" = xloongarch64; then + TARGET_CFLAGS="$TARGET_CFLAGS -mno-explicit-relocs -fno-plt" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mno-explicit-relocs -fno-plt" + fi ++ ++ AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [ ++ grub_cv_target_cc_mno_relax=no ++ for cand in "-mno-relax" "-Wa,-mno-relax"; do ++ if test x"$grub_cv_target_cc_mno_relax" != xno ; then ++ break ++ fi ++ CFLAGS="$TARGET_CFLAGS $cand -Werror" ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++ asm (".globl start; start:"); ++ void __main (void); ++ void __main (void) {} ++ int main (void); ++ ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], []) ++ done ++ ]) ++ CFLAGS="$TARGET_CFLAGS" ++ ++ if test x"$grub_cv_target_cc_mno_relax" != xno ; then ++ TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_relax" ++ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mno_relax" ++ fi ++ + TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mla-global-with-abs" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mla-global-with-abs" + fi +-- +2.40.1 + diff --git a/grub.patches b/grub.patches index 56a080148abd74cbc65800074d3098041055a62b..a9b6d4919f1bf9130cb29ca9f76d8bca357d5889 100644 --- a/grub.patches +++ b/grub.patches @@ -281,6 +281,6 @@ Patch0280: 0280-loongarch-Add-support-for-new-EFI-screen-info-GUID.patch 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 Patch1000: 1000-change-to-use-fuse3.patch diff --git a/grub2.spec b/grub2.spec index 4a3570ce4794ba8151dbce5c69a95eff2b6c5b5b..1a8f24aad2a732fff12735610cc181b4427083ec 100644 --- a/grub2.spec +++ b/grub2.spec @@ -1,4 +1,4 @@ -%define anolis_release 12 +%define anolis_release 13 %global _lto_cflags %{nil} %undefine _hardened_build @@ -506,6 +506,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Wed Sep 06 2023 Yingkun Meng -2.06-13 +- loongarch: disable relaxation relocations + * Wed Aug 09 2023 Yingkun Meng -2.06-12 - add support for loongarch