* [PATCH] Fix build error in binutils 2.36
@ 2021-08-02 9:41 Michael Chang
2021-08-05 13:07 ` Daniel Kiper
0 siblings, 1 reply; 7+ messages in thread
From: Michael Chang @ 2021-08-02 9:41 UTC (permalink / raw)
To: The development of GNU GRUB
The xen build fails on binutils 2.36 with the following error.
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
section .note.gnu.property VMA [0000000000400158,0000000000400187]
overlaps section .bss VMA [000000000000f000,000000000041e1af]
The most significant factor is that new assembler (gnu as) generates the
.note.gnu.property section as default. This note section overlaps with
.bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
address of .text section is set, rather the address of
.note.gnu.property is calculated for some reason from 0x400000 where the
elf executable defaults to start.
Using -Ttext-segment doesn't help either, though it is said to set the
address of the first byte of the text segment according to "man ld".
What it actually does is to override the default 0x400000, aka the image
base address, to something else. The entire process can be observed in
the default linker script used by gcc [1]. Therefore we can't expect it
to achieve the same thing as -Ttext given that the first segment where
.text resides is offset by SIZEOF_HEADERS plus some sections may be
preceding it within the first segment. The end result is .text always
has to start with non-zero address with -Wl,-Ttext-segment,0 if using
default linker script.
As long as grub didn't use ISA information encoded in
.note.gnu.property, we can safely drop it via -Wa,-mx86-used-note=no
assembler option to fix the linker error here.
[1] In /usr/lib64/ldscripts/elf_x86_64.x or use 'gcc -Wl,--verbose ...'
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000));
. = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
Signed-off-by: Michael Chang <mchang@suse.com>
---
configure.ac | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/configure.ac b/configure.ac
index bee28dbeb..cf0a64378 100644
--- a/configure.ac
+++ b/configure.ac
@@ -836,6 +836,20 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
fi
+if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
+ AC_CACHE_CHECK([whether -Wa,-mx86-used-note works], [grub_cv_cc_mx86_used_note], [
+ CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_cc_mx86_used_note=yes],
+ [grub_cv_cc_mx86_used_note=no])
+ ])
+
+ if test "x$grub_cv_cc_mx86_used_note" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mx86-used-note=no"
+ fi
+fi
+
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix build error in binutils 2.36
2021-08-02 9:41 [PATCH] Fix build error in binutils 2.36 Michael Chang
@ 2021-08-05 13:07 ` Daniel Kiper
2021-08-09 4:37 ` Michael Chang
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Kiper @ 2021-08-05 13:07 UTC (permalink / raw)
To: Michael Chang; +Cc: grub-devel
On Mon, Aug 02, 2021 at 05:41:15PM +0800, Michael Chang via Grub-devel wrote:
> The xen build fails on binutils 2.36 with the following error.
>
> /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
> section .note.gnu.property VMA [0000000000400158,0000000000400187]
> overlaps section .bss VMA [000000000000f000,000000000041e1af]
Could you send us full command which is failing?
Anyway, I would consider writing our own linker script which is dropping
.note.gnu.property if we do not need it.
> The most significant factor is that new assembler (gnu as) generates the
Could you give us gas version which does that?
> .note.gnu.property section as default. This note section overlaps with
> .bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
> address of .text section is set, rather the address of
> .note.gnu.property is calculated for some reason from 0x400000 where the
> elf executable defaults to start.
Is not it linker bug?
Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix build error in binutils 2.36
2021-08-05 13:07 ` Daniel Kiper
@ 2021-08-09 4:37 ` Michael Chang
2021-09-14 14:13 ` Mike Gilbert
2021-09-16 21:47 ` Daniel Kiper
0 siblings, 2 replies; 7+ messages in thread
From: Michael Chang @ 2021-08-09 4:37 UTC (permalink / raw)
To: The development of GNU GRUB
On Thu, Aug 05, 2021 at 03:07:21PM +0200, Daniel Kiper wrote:
> On Mon, Aug 02, 2021 at 05:41:15PM +0800, Michael Chang via Grub-devel wrote:
> > The xen build fails on binutils 2.36 with the following error.
> >
> > /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
> > section .note.gnu.property VMA [0000000000400158,0000000000400187]
> > overlaps section .bss VMA [000000000000f000,000000000041e1af]
>
> Could you send us full command which is failing?
It is reproducible on xen platfrom with all defaults.
git clone https://git.savannah.gnu.org/git/grub.git
cd grub
./bootstrap
mkdir build-xen
cd build-xen
../configure --with-platform=xen
make
> Anyway, I would consider writing our own linker script which is dropping
> .note.gnu.property if we do not need it.
Dropping it from the assembler output is a cleaner cleanup than linker
script IMHO. We also faced similar issue in the past to stripping off
this section from soruces of objcopy to produce correct binary.
6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc
To avoid falling into such trap again when manipulating on object files
we'd better use assmbler option as the fix once and for all.
> > The most significant factor is that new assembler (gnu as) generates the
>
> Could you give us gas version which does that?
# as --version
GNU assembler (GNU Binutils; openSUSE Tumbleweed) 2.36.1.20210326-4
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-suse-linux'.
> > .note.gnu.property section as default. This note section overlaps with
> > .bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
> > address of .text section is set, rather the address of
> > .note.gnu.property is calculated for some reason from 0x400000 where the
> > elf executable defaults to start.
>
> Is not it linker bug?
The binutils upstream apparently doesn't seem to consider this as a bug ...
https://sourceware.org/bugzilla/show_bug.cgi?id=27377
Thanks,
Michael
>
> Daniel
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix build error in binutils 2.36
2021-08-09 4:37 ` Michael Chang
@ 2021-09-14 14:13 ` Mike Gilbert
2021-09-15 11:17 ` Michael Chang
2021-09-16 21:47 ` Daniel Kiper
1 sibling, 1 reply; 7+ messages in thread
From: Mike Gilbert @ 2021-09-14 14:13 UTC (permalink / raw)
To: The development of GNU GRUB; +Cc: Michael Chang
On Mon, Aug 9, 2021 at 12:37 AM Michael Chang via Grub-devel
<grub-devel@gnu.org> wrote:
>
> On Thu, Aug 05, 2021 at 03:07:21PM +0200, Daniel Kiper wrote:
> > On Mon, Aug 02, 2021 at 05:41:15PM +0800, Michael Chang via Grub-devel wrote:
> > > The xen build fails on binutils 2.36 with the following error.
> > >
> > > /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
> > > section .note.gnu.property VMA [0000000000400158,0000000000400187]
> > > overlaps section .bss VMA [000000000000f000,000000000041e1af]
> >
> > Could you send us full command which is failing?
>
> It is reproducible on xen platfrom with all defaults.
>
> git clone https://git.savannah.gnu.org/git/grub.git
> cd grub
> ./bootstrap
> mkdir build-xen
> cd build-xen
> ../configure --with-platform=xen
> make
>
> > Anyway, I would consider writing our own linker script which is dropping
> > .note.gnu.property if we do not need it.
>
> Dropping it from the assembler output is a cleaner cleanup than linker
> script IMHO. We also faced similar issue in the past to stripping off
> this section from soruces of objcopy to produce correct binary.
>
> 6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc
>
> To avoid falling into such trap again when manipulating on object files
> we'd better use assmbler option as the fix once and for all.
>
> > > The most significant factor is that new assembler (gnu as) generates the
> >
> > Could you give us gas version which does that?
>
> # as --version
> GNU assembler (GNU Binutils; openSUSE Tumbleweed) 2.36.1.20210326-4
> Copyright (C) 2021 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License version 3 or later.
> This program has absolutely no warranty.
> This assembler was configured for a target of `x86_64-suse-linux'.
>
> > > .note.gnu.property section as default. This note section overlaps with
> > > .bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
> > > address of .text section is set, rather the address of
> > > .note.gnu.property is calculated for some reason from 0x400000 where the
> > > elf executable defaults to start.
> >
> > Is not it linker bug?
>
> The binutils upstream apparently doesn't seem to consider this as a bug ...
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=27377
>
> Thanks,
> Michael
Just wondering if there has been any progress on this issue.
A few people have commented on the related bug [1] for Gentoo Linux
and a couple have confirmed that this patch fixes the build failure.
However, I haven't found anyone able to test if the resulting code
actually works at run time.
[1] https://bugs.gentoo.org/787221
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix build error in binutils 2.36
2021-09-14 14:13 ` Mike Gilbert
@ 2021-09-15 11:17 ` Michael Chang
0 siblings, 0 replies; 7+ messages in thread
From: Michael Chang @ 2021-09-15 11:17 UTC (permalink / raw)
To: The development of GNU GRUB; +Cc: Mike Gilbert
On Tue, Sep 14, 2021 at 10:13:36AM -0400, Mike Gilbert wrote:
> On Mon, Aug 9, 2021 at 12:37 AM Michael Chang via Grub-devel
> <grub-devel@gnu.org> wrote:
[snip]
> Just wondering if there has been any progress on this issue.
>
> A few people have commented on the related bug [1] for Gentoo Linux
> and a couple have confirmed that this patch fixes the build failure.
> However, I haven't found anyone able to test if the resulting code
> actually works at run time.
We (openSUSE) have been using this patch for months and doesn't see any
problem thus far.
Thanks,
Michael
>
> [1] https://bugs.gentoo.org/787221
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix build error in binutils 2.36
2021-08-09 4:37 ` Michael Chang
2021-09-14 14:13 ` Mike Gilbert
@ 2021-09-16 21:47 ` Daniel Kiper
2021-09-17 7:55 ` Michael Chang
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Kiper @ 2021-09-16 21:47 UTC (permalink / raw)
To: Michael Chang; +Cc: grub-devel
On Mon, Aug 09, 2021 at 12:37:59PM +0800, Michael Chang via Grub-devel wrote:
> On Thu, Aug 05, 2021 at 03:07:21PM +0200, Daniel Kiper wrote:
> > On Mon, Aug 02, 2021 at 05:41:15PM +0800, Michael Chang via Grub-devel wrote:
> > > The xen build fails on binutils 2.36 with the following error.
> > >
> > > /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
> > > section .note.gnu.property VMA [0000000000400158,0000000000400187]
> > > overlaps section .bss VMA [000000000000f000,000000000041e1af]
> >
> > Could you send us full command which is failing?
>
> It is reproducible on xen platfrom with all defaults.
>
> git clone https://git.savannah.gnu.org/git/grub.git
> cd grub
> ./bootstrap
> mkdir build-xen
> cd build-xen
> ../configure --with-platform=xen
> make
>
> > Anyway, I would consider writing our own linker script which is dropping
> > .note.gnu.property if we do not need it.
>
> Dropping it from the assembler output is a cleaner cleanup than linker
> script IMHO. We also faced similar issue in the past to stripping off
> this section from soruces of objcopy to produce correct binary.
>
> 6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc
>
> To avoid falling into such trap again when manipulating on object files
> we'd better use assmbler option as the fix once and for all.
May I ask you to expand commit message with the information above?
> > > The most significant factor is that new assembler (gnu as) generates the
> >
> > Could you give us gas version which does that?
>
> # as --version
> GNU assembler (GNU Binutils; openSUSE Tumbleweed) 2.36.1.20210326-4
> Copyright (C) 2021 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License version 3 or later.
> This program has absolutely no warranty.
> This assembler was configured for a target of `x86_64-suse-linux'.
>
> > > .note.gnu.property section as default. This note section overlaps with
> > > .bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
> > > address of .text section is set, rather the address of
> > > .note.gnu.property is calculated for some reason from 0x400000 where the
> > > elf executable defaults to start.
> >
> > Is not it linker bug?
>
> The binutils upstream apparently doesn't seem to consider this as a bug ...
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=27377
Please add this information and the link to the bug to the commit message too.
Additionally, I think it is worth mentioning Gentoo Linux bug [1] in it.
I treat this patch more as a workaround than real fix. However, after digging
deeper into this issue I think we do not have better choice here... :-(
Daniel
[1] https://bugs.gentoo.org/787221
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix build error in binutils 2.36
2021-09-16 21:47 ` Daniel Kiper
@ 2021-09-17 7:55 ` Michael Chang
0 siblings, 0 replies; 7+ messages in thread
From: Michael Chang @ 2021-09-17 7:55 UTC (permalink / raw)
To: The development of GNU GRUB
On Thu, Sep 16, 2021 at 11:47:57PM +0200, Daniel Kiper wrote:
> On Mon, Aug 09, 2021 at 12:37:59PM +0800, Michael Chang via Grub-devel wrote:
> > On Thu, Aug 05, 2021 at 03:07:21PM +0200, Daniel Kiper wrote:
> > > On Mon, Aug 02, 2021 at 05:41:15PM +0800, Michael Chang via Grub-devel wrote:
> > > > The xen build fails on binutils 2.36 with the following error.
> > > >
> > > > /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
> > > > section .note.gnu.property VMA [0000000000400158,0000000000400187]
> > > > overlaps section .bss VMA [000000000000f000,000000000041e1af]
> > >
> > > Could you send us full command which is failing?
> >
> > It is reproducible on xen platfrom with all defaults.
> >
> > git clone https://git.savannah.gnu.org/git/grub.git
> > cd grub
> > ./bootstrap
> > mkdir build-xen
> > cd build-xen
> > ../configure --with-platform=xen
> > make
> >
> > > Anyway, I would consider writing our own linker script which is dropping
> > > .note.gnu.property if we do not need it.
> >
> > Dropping it from the assembler output is a cleaner cleanup than linker
> > script IMHO. We also faced similar issue in the past to stripping off
> > this section from soruces of objcopy to produce correct binary.
> >
> > 6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc
> >
> > To avoid falling into such trap again when manipulating on object files
> > we'd better use assmbler option as the fix once and for all.
>
> May I ask you to expand commit message with the information above?
Sure. No problem.
>
> > > > The most significant factor is that new assembler (gnu as) generates the
> > >
> > > Could you give us gas version which does that?
> >
> > # as --version
> > GNU assembler (GNU Binutils; openSUSE Tumbleweed) 2.36.1.20210326-4
> > Copyright (C) 2021 Free Software Foundation, Inc.
> > This program is free software; you may redistribute it under the terms of
> > the GNU General Public License version 3 or later.
> > This program has absolutely no warranty.
> > This assembler was configured for a target of `x86_64-suse-linux'.
> >
> > > > .note.gnu.property section as default. This note section overlaps with
> > > > .bss because it doesn't reposition with -Wl,-Ttext,0 with which the base
> > > > address of .text section is set, rather the address of
> > > > .note.gnu.property is calculated for some reason from 0x400000 where the
> > > > elf executable defaults to start.
> > >
> > > Is not it linker bug?
> >
> > The binutils upstream apparently doesn't seem to consider this as a bug ...
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=27377
>
> Please add this information and the link to the bug to the commit message too.
> Additionally, I think it is worth mentioning Gentoo Linux bug [1] in it.
OK. I'll add the suggested information and refernce to next version.
>
> I treat this patch more as a workaround than real fix. However, after digging
> deeper into this issue I think we do not have better choice here... :-(
I feel likewise. It is no sliver bullet but can help us back on track
and move on.
Thanks,
Michael
>
> Daniel
>
> [1] https://bugs.gentoo.org/787221
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-09-17 7:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 9:41 [PATCH] Fix build error in binutils 2.36 Michael Chang
2021-08-05 13:07 ` Daniel Kiper
2021-08-09 4:37 ` Michael Chang
2021-09-14 14:13 ` Mike Gilbert
2021-09-15 11:17 ` Michael Chang
2021-09-16 21:47 ` Daniel Kiper
2021-09-17 7:55 ` Michael Chang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.