[2/7] ipfire-netboot: Fix build with binutils 2.41

Message ID 20230815170230.306397-2-michael.tremer@ipfire.org
State Staged
Commit 852324e2aa445fd80a4df88d10ca2c59aad21266
Headers
Series [1/7] ffmpeg: Fix build with binutils 2.41 |

Commit Message

Michael Tremer Aug. 15, 2023, 5:02 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/ipfire-netboot                            |  1 +
 ...se-the-right-sized-register-for-push.patch | 44 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 src/patches/ipxe-use-the-right-sized-register-for-push.patch
  

Patch

diff --git a/lfs/ipfire-netboot b/lfs/ipfire-netboot
index 1fd37e9eb..e7ba44af9 100644
--- a/lfs/ipfire-netboot
+++ b/lfs/ipfire-netboot
@@ -80,6 +80,7 @@  $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	cd $(DIR_APP)/ipxe-$(PXE_VER) && patch -Np1 < $(DIR_SRC)/src/patches/ipxe-fix-stringop-truncation-warning-with-gcc-8-x.patch
 	cd $(DIR_APP)/ipxe-$(PXE_VER) && patch -Np1 < $(DIR_SRC)/src/patches/ipxe-handle-R_X86_64_PLT32.patch
 	cd $(DIR_APP)/ipxe-$(PXE_VER) && patch -Np1 < $(DIR_SRC)/src/patches/ipxe-1b67a05-be-explicit-about-fcommon-compiler-directive.patch
+	cd $(DIR_APP)/ipxe-$(PXE_VER) && patch -Np1 < $(DIR_SRC)/src/patches/ipxe-use-the-right-sized-register-for-push.patch
 	cd $(DIR_APP) && rm -rfv ipxe && ln -s ipxe-$(PXE_VER) ipxe
 	cd $(DIR_APP) && make $(MAKETUNING) bin/ipxe.lkrn
 ifeq "$(BUILD_ARCH)" "x86_64"
diff --git a/src/patches/ipxe-use-the-right-sized-register-for-push.patch b/src/patches/ipxe-use-the-right-sized-register-for-push.patch
new file mode 100644
index 000000000..99b76de66
--- /dev/null
+++ b/src/patches/ipxe-use-the-right-sized-register-for-push.patch
@@ -0,0 +1,44 @@ 
+From 08caa8be3a143d6f33782f398b7937efb39ff283 Mon Sep 17 00:00:00 2001
+From: Justin Cano <5184128+jstncno@users.noreply.github.com>
+Date: Thu, 3 Aug 2023 09:58:11 -0700
+Subject: [PATCH] Use the right sized register for the push operand based on
+ the size of the value being pushed
+
+Fixes https://github.com/ipxe/ipxe/issues/997
+---
+ src/arch/x86/include/librm.h | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/arch/x86/include/librm.h b/src/arch/x86/include/librm.h
+index 5196d390fa..d9e748adfc 100644
+--- a/src/arch/x86/include/librm.h
++++ b/src/arch/x86/include/librm.h
+@@ -250,8 +250,10 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
+ /* CODE_DEFAULT: restore default .code32/.code64 directive */
+ #ifdef __x86_64__
+ #define CODE_DEFAULT ".code64"
++#define PUSH "pushq"
+ #else
+ #define CODE_DEFAULT ".code32"
++#define PUSH "pushl"
+ #endif
+ 
+ /* LINE_SYMBOL: declare a symbol for the current source code line */
+@@ -268,7 +270,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
+ 
+ /* REAL_CODE: declare a fragment of code that executes in real mode */
+ #define REAL_CODE( asm_code_str )			\
+-	"push $1f\n\t"					\
++	PUSH " $1f\n\t"					\
+ 	"call real_call\n\t"				\
+ 	TEXT16_CODE ( "\n1:\n\t"			\
+ 		      asm_code_str			\
+@@ -277,7 +279,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
+ 
+ /* PHYS_CODE: declare a fragment of code that executes in flat physical mode */
+ #define PHYS_CODE( asm_code_str )			\
+-	"push $1f\n\t"					\
++	PUSH " $1f\n\t"					\
+ 	"call phys_call\n\t"				\
+ 	".section \".text.phys\", \"ax\", @progbits\n\t"\
+ 	"\n" LINE_SYMBOL "\n\t"				\