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
Additionally, remove a line with redundant spaces.
Signed-off-by: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
movq %rax, %cr3
#endif
+#ifdef __x86_64__
.code64
+#endif
/* mov imm64, %rax */
.byte 0x48
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)
*/
VARIABLE(grub_relocator64_efi_start)
/* Align the stack as UEFI spec requires. */
+#ifdef __x86_64__
andq $~15, %rsp
+#else
+ /* andq $~15, %rsp */
+ .byte 0x48
+ .byte 0x83
+ .byte 0xe4
+ .byte 0xf0
+#endif
LOCAL(skip_efi_stack_align):
#endif
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
payload and makes this implementation easier. */
cld
-#ifdef __APPLE__
+#if defined (__APPLE__) || !defined (__x86_64__)
.byte 0xff, 0x25
.quad 0
#else