Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lly6u-00075M-0d for mharc-grub-devel@gnu.org; Wed, 26 May 2021 14:18:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lly6s-000730-9T for grub-devel@gnu.org; Wed, 26 May 2021 14:18:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42110) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lly6r-0000ZX-WC; Wed, 26 May 2021 14:18:26 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=55136 helo=dundal.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.90_1) (envelope-from ) id 1lly6r-0003wN-KG; Wed, 26 May 2021 14:18:25 -0400 From: "Jan (janneke) Nieuwenhuizen" To: grub-devel@gnu.org Subject: [PATCH v3] grub-core: Build fixes for i386 Date: Wed, 26 May 2021 20:18:24 +0200 Message-Id: <20210526181824.24221-1-janneke@gnu.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 May 2021 18:18:27 -0000 This fixes cross-compiling to x86 (e.g., the Hurd) from x86-linux of grub-core/lib/i386/relocator64.S This file has six sections that only build with a 64-bit assembler, yet only the first two sections had support for a 32-bit assembler; this patch completes this for the remaining sections. To reproduce, update the GRUB source description in your local Guix archive and run ./pre-inst-env guix build --system=i686-linux --target=i586-pc-gnu grub or install an x86 cross-build environment on x86-linux (32-bit!) and configure to cross build and make, e.g., do something like ./configure \ CC_FOR_BUILD=gcc \ --build=i686-unknown-linux-gnu \ --host=i586-pc-gnu make Signed-off-by: Jan (janneke) Nieuwenhuizen --- grub-core/lib/i386/relocator64.S | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S index 148f38adb..b8b1f896b 100644 --- a/grub-core/lib/i386/relocator64.S +++ b/grub-core/lib/i386/relocator64.S @@ -63,7 +63,9 @@ VARIABLE(grub_relocator64_cr3) movq %rax, %cr3 #endif +#ifdef __x86_64__ .code64 +#endif /* mov imm64, %rax */ .byte 0x48 @@ -71,7 +73,14 @@ VARIABLE(grub_relocator64_cr3) VARIABLE(grub_relocator64_rsp) .quad 0 +#ifdef __x86_64__ movq %rax, %rsp +#else + /* movq %rax, %rsp */ + .byte 0x48 + .byte 0x89 + .byte 0xc4 +#endif #ifdef GRUB_MACHINE_EFI jmp LOCAL(skip_efi_stack_align) @@ -85,7 +94,14 @@ VARIABLE(grub_relocator64_rsp) */ VARIABLE(grub_relocator64_efi_start) /* Align the stack as UEFI spec requires. */ +#ifdef __x86_64__ andq $~15, %rsp +#else + .byte 0x48 + .byte 0x83 + .byte 0xe4 + .byte 0xf0 +#endif LOCAL(skip_efi_stack_align): #endif @@ -95,8 +111,15 @@ LOCAL(skip_efi_stack_align): VARIABLE(grub_relocator64_rsi) .quad 0 +#ifdef __x86_64__ movq %rax, %rsi - +#else + /* movq %rax, %rsi */ + .byte 0x48 + .byte 0x89 + .byte 0xc6 +#endif + /* mov imm64, %rax */ .byte 0x48 .byte 0xb8 @@ -125,7 +148,7 @@ VARIABLE(grub_relocator64_rdx) payload and makes this implementation easier. */ cld -#ifdef __APPLE__ +#if defined (__APPLE__) || !defined (__x86_64__) .byte 0xff, 0x25 .quad 0 #else -- Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com