loongarch: Disable relaxation relocations
Signed-off-by: Yingkun Meng <mengyingkun@loongson.cn>
This commit is contained in:
parent
781871c861
commit
54048ecd9e
64
1008-loongarch-Disable-relaxation-relocations.patch
Normal file
64
1008-loongarch-Disable-relaxation-relocations.patch
Normal file
@ -0,0 +1,64 @@
|
||||
From 115c628cc44f89207858d0c79e970e43da75c772 Mon Sep 17 00:00:00 2001
|
||||
From: Yingkun Meng <mengyingkun@loongson.cn>
|
||||
Date: Tue, 5 Dec 2023 19:22:14 +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 <wuxiaotian@loongson.cn>
|
||||
Signed-off-by: Yingkun Meng <mengyingkun@loongson.cn>
|
||||
Change-Id: I09ef306dc8a0f8a59e9b7dbc53ae3fd3cc09ec55
|
||||
---
|
||||
configure.ac | 23 +++++++++++++++++++++++
|
||||
1 file changed, 23 insertions(+)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 0db9d7d111b8..e010bc0db465 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.33.0
|
||||
|
||||
@ -342,3 +342,4 @@ Patch0342: backport-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch
|
||||
Patch0343: backport-fs-ntfs-Make-code-more-readable.patch
|
||||
Patch0344: add-TPCM-support-with-ipmi-channel.patch
|
||||
Patch0345: skip-verification-when-not-loading-grub.cfg.patch
|
||||
Patch0346: 1008-loongarch-Disable-relaxation-relocations.patch
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.06
|
||||
Release: 42
|
||||
Release: 43
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
@ -448,6 +448,12 @@ fi
|
||||
%{_datadir}/man/man*
|
||||
|
||||
%changelog
|
||||
* Mon Dec 25 2023 mengyingkun <mengyingkun@loongson.cn> - 1:2.06-43
|
||||
- Type:requirement
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:loongarch: Disable relaxation relocations
|
||||
|
||||
* Wed Dec 20 2023 zhangqiumiao <zhangqiumiao1@huawei.com> - 1:2.06-42
|
||||
- Type:requirement
|
||||
- CVE:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user