Fix build with binutils 2.41

https://github.com/ipxe/ipxe/issues/997
https://github.com/ipxe/ipxe/pull/1036
This commit is contained in:
Yaakov Selkowitz 2023-12-19 11:48:26 -05:00
parent 2188e9bf03
commit 517efa2f1b
2 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,58 @@
From 0aa2e4ec963597794dd8f8b36f77f4d0cf4e03c8 Mon Sep 17 00:00:00 2001
From: Michael Brown <mcb30@ipxe.org>
Date: Tue, 5 Sep 2023 12:46:39 +0100
Subject: [PATCH] [librm] Use explicit operand size when pushing a label
address
We currently use "push $1f" within inline assembly to push the address
of the real-mode code fragment, relying on the assembler to treat this
as "pushl" for 32-bit code or "pushq" for 64-bit code.
As of binutils commit 5cc0077 ("x86: further adjust extend-to-32bit-
address conditions"), first included in binutils-2.41, this implicit
operand size is no longer calculated as expected and 64-bit builds
will fail with
Error: operand size mismatch for `push'
Fix by adding an explicit operand size to the "push" instruction.
Originally-fixed-by: Justin Cano <jstncno@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
---
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..40f075439a 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 STACK_DEFAULT "q"
#else
#define CODE_DEFAULT ".code32"
+#define STACK_DEFAULT "l"
#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" STACK_DEFAULT " $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" STACK_DEFAULT " $1f\n\t" \
"call phys_call\n\t" \
".section \".text.phys\", \"ax\", @progbits\n\t"\
"\n" LINE_SYMBOL "\n\t" \

View File

@ -39,7 +39,7 @@
Name: ipxe
Version: %{date}
Release: 4.git%{hash}%{?dist}
Release: 5.git%{hash}%{?dist}
Summary: A network boot loader
License: BSD-2-Clause AND BSD-3-Clause AND GPL-2.0-only AND (GPL-2.0-only OR MPL-1.1) AND GPL-2.0-or-later AND GPL-2.0-or-later WITH UBDL-exception AND ISC AND MIT
@ -51,6 +51,8 @@ Source0: %{name}-%{version}-git%{hash}.tar.xz
# Sent upstream: http://lists.ipxe.org/pipermail/ipxe-devel/2015-November/004494.html
Patch0001: 0001-build-customize-configuration.patch
Patch0002: 0002-Use-spec-compliant-timeouts.patch
# Fix build with binutils-2.41, https://github.com/ipxe/ipxe/pull/1011
Patch0003: 0003-librm-Use-explicit-operand-size.patch
%ifarch %{buildarches}
BuildRequires: perl-interpreter
@ -278,6 +280,9 @@ cp -a src/bin-arm64-efi/ipxe.efi %{buildroot}/%{_datadir}/%{name}/arm64-efi/ipxe
%endif
%changelog
* Tue Dec 19 2023 Yaakov Selkowitz <yselkowi@redhat.com> - 20220210-5.git64113751
- Fix build with binutils 2.41
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 20220210-4.git64113751
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild