grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.3


From: Jan Nieuwenhuizen
Subject: Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
Date: Thu, 13 May 2021 12:35:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Daniel Kiper writes:

Hello Daniel,

> May I ask you to try latest GRUB master git branch [1]? The GRUB 2.04
> release is a few years old. We are going to release 2.06 soon.

Sure.  The bug is still there (see attached patch to reproduce using
Guix):

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build --system=i686-linux --target=i586-pc-gnu grub 
starting phase `unpack'
grub-2.06~rc1/
[..]
starting phase `configure'
source directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1" (relative 
from build: ".")
build directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1"
configure flags: ("CC_FOR_BUILD=gcc" 
"CONFIG_SHELL=/gnu/store/v1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash"
 
"SHELL=/gnu/store/v1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash"
 "--prefix=/gnu/store/753q8z0xa9ijap3p3phpsvns7287c7sn-grub-2.06-rc1" 
"--enable-fast-install" "--build=i686-unknown-linux-gnu" "--host=i586-pc-gnu" 
"PYTHON=true")
[..]
starting phase `build'
[..]
i586-pc-gnu-gcc -DHAVE_CONFIG_H -I. -I..  -Wall -W  -DGRUB_MACHINE_PCBIOS=1 
-DGRUB_MACHINE=I386_PC -m32 -nostdinc -isystem 
/gnu/store/q8af3pvwsknn132pl1nzrb5281i4pgij-gcc-cross-i586-pc-gnu-7.5.0-lib/lib/gcc/i586-pc-gnu/7.5.0/include
 -I../include -I../include -DGRUB_FILE=\"lib/i386/relocator.c\" -I. -I. -I.. 
-I.. -I../include -I../include -I../grub-core/lib/libgcrypt-grub/src/    
-D_FILE_OFFSET_BITS=64 -std=gnu99 -Os -m32 -Wall -W -Wshadow -Wpointer-arith 
-Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations 
-Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args 
-Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration 
-Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar 
-Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch 
-Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label 
-Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings 
-Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes 
-Wmissing-declarations  -Wextra -Wattributes -Wendif-labels -Winit-self 
-Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull 
-Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros 
-Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs 
-Wmissing-prototypes -Wmissing-declarations -Wformat=2 -march=i386 -mrtd 
-mregparm=3 -falign-jumps=1 -falign-loops=1 -falign-functions=1 
-freg-struct-return -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow 
-msoft-float -fno-dwarf2-cfi-asm -mno-stack-arg-probe 
-fno-asynchronous-unwind-tables -fno-unwind-tables -fno-ident 
-fno-stack-protector -Wtrampolines -Werror   -ffreestanding   -MT 
lib/i386/relocator_module-relocator.o -MD -MP -MF 
lib/i386/.deps-core/relocator_module-relocator.Tpo -c -o 
lib/i386/relocator_module-relocator.o `test -f 'lib/i386/relocator.c' || echo 
'./'`lib/i386/relocator.c
lib/i386/relocator64.S: Assembler messages:
lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
lib/i386/relocator64.S:74: Error: bad register name `%rax'
lib/i386/relocator64.S:98: Error: bad register name `%rax'
lib/i386/relocator64.S:132: Error: bad register name `%rip)'
--8<---------------cut here---------------end--------------->8---

>> > lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
>>
>> So, the working patch is attached. Please add it to grub2.
>
> You can find a few comments below...

Thanks!

>> From 270667540146f8ef9ea7a44258a71b3837a7af4a Mon Sep 17 00:00:00 2001
>> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
>> Date: Sun, 21 Jun 2020 15:10:40 +0200
>> Subject: [PATCH] grub-core: Build fixes for i386
>>
>> * grub-core/lib/i386/relocator64.S: Avoid x86_64 instructions on i386.
>
> Please describe in the commit message why this patch is needed and how
> the issue can be reproduced.

I have added:

--8<---------------cut here---------------start------------->8---
This fixes cross-compiling to x86 (e.g., the Hurd) from x86-linux.

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 (32bit!) 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
--8<---------------cut here---------------end--------------->8---

>> diff --git a/grub-core/lib/i386/relocator64.S 
>> b/grub-core/lib/i386/relocator64.S
>> index 148f38adb..45fed9444 100644
[..]
>> +#ifndef __x86_64__
>> +    /* movq %rax, %rsp */
>> +    .byte   0x48
>> +    .byte   0x89
>> +    .byte   0xc4
>> +#else
>>      movq    %rax, %rsp
>> +#endif
>
> I would do it other way around to increase readability...
>
> #ifdef __x86_64__
>      movq    %rax, %rsp
> #else
>      /* movq %rax, %rsp */
>      .byte   0x48
>      ...

Done.

>> +#ifndef     __x86_64__
>> +    /* movq %rax, %rsi */
>> +    .byte   0x48
>> +    .byte   0x89
>> +    .byte   0xc6
>> +#else
>>      movq    %rax, %rsi
>> -
>> +#endif
>
> Ditto...

Ok.

>>  #ifdef __APPLE__
>>      .byte 0xff, 0x25
>>      .quad 0
>> +#elif !defined (__x86_64__)
>> +    /* jmp *LOCAL(jump_addr) (%rip) */
>> +    .byte 0xff
>> +        .byte 0x25
>> +    .byte 0
>> +    .byte 0
>> +    .byte 0
>> +    .byte 0
>>  #else
>>      jmp *LOCAL(jump_addr) (%rip)
>>  #endif
>
> #if defined(__APPLE__) || !defined (__x86_64__)
>      .byte 0xff, 0x25
>      .quad 0
> #else
>      jmp *LOCAL(jump_addr) (%rip)
> #endif

Ah, yes; that's better.  Also updated.

> A patch should be prepared on top of latest GRUB master git branch [1].

Sure, but well..

    https://lists.gnu.org/archive/html/bug-grub/2020-06/msg00013.html

it was when I sent the report ;)

Luckily it still applied cleanly to current master.

> And please use "git-send-email" to send the patch as Adrian said...

Sure, sent separately to bug-grub.

Greetings,
Janneke

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 56bef57cb7..78923e4303 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -88,18 +88,15 @@
 (define-public grub
   (package
     (name "grub")
-    (version "2.04")
+    (version "2.06-rc1")
     (source (origin
              (method url-fetch)
-             (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
+             (uri (string-append "https://alpha.gnu.org/pub/gnu/grub/";
+                                 "grub-2.06~rc1" ".tar.xz"))
+             (file-name (string-append "grub-" version ".tar.xz"))
              (sha256
               (base32
-               "0zgp5m3hmc9jh8wpjx6czzkh5id2y8n1k823x2mjvm2sk6b28ag5"))
-             (patches (search-patches
-                       "grub-efi-fat-serial-number.patch"
-                       "grub-setup-root.patch"
-                       "grub-verifiers-Blocklist-fallout-cleanup.patch"
-                       "grub-cross-system-i686.patch"))))
+               "112l2isb0rgdz4zz4ssmf5hklv0viz0674fdwr1h1d9a3vrg31rc"))))
     (build-system gnu-build-system)
     (arguments
      `(#:configure-flags
-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]