Fix build error in binutils 2.36
PATCH 1/1 Fix build error in binutils 2.36
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;
--- configure.ac | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
configure.ac +14 -0
@@ -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)
Signature · 1 line
2.31.1
Quoted 5 lines · Michael Chang via Grub-devel
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.
Quoted 1 line
The most significant factor is that new assembler (gnu as) generates the
Could you give us gas version which does that?
Quoted 5 lines
.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
0x400000where the elf executable defaults to start.
Is not it linker bug?
Daniel
Quoted 8 lines · Daniel Kiper
Quoted 5 lines · Michael Chang via Grub-devel
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
Quoted 2 lines
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.
Quoted 3 lines
Quoted 1 line
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'.
Quoted 7 lines
Quoted 5 lines
.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
0x400000where 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
Quoted 7 lines
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 51 lines · Michael Chang via Grub-devel
Quoted 8 lines · Daniel Kiper
Quoted 5 lines · Michael Chang via Grub-devel
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
makeQuoted 2 lines
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.
6643507cebuild: Fix GRUB i386-pc build with Ubuntu gccTo avoid falling into such trap again when manipulating on object files we'd better use assmbler option as the fix once and for all.
Quoted 3 lines
Quoted 1 line
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'.Quoted 6 lines
Quoted 5 lines
.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
0x400000where the elf executable defaults to start.
Quoted 8 lines
Quoted 1 line
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.
Quoted 2 lines · Mike Gilbert
On Mon, Aug 9, 2021 at 12:37 AM Michael Chang via Grub-devel <[email protected]> wrote:
[snip]
Quoted 6 lines
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
Quoted 2 lines
Quoted 23 lines · Michael Chang via Grub-devel
Quoted 8 lines · Daniel Kiper
Quoted 5 lines · Michael Chang via Grub-devel
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
makeQuoted 2 lines
Anyway, I would consider writing our own linker script which is dropping .note.gnu.property if we do not need it.
Quoted 8 lines
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.
6643507cebuild: Fix GRUB i386-pc build with Ubuntu gccTo 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?
Quoted 18 lines
Quoted 3 lines
Quoted 1 line
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'.Quoted 6 lines
Quoted 5 lines
.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
0x400000where the elf executable defaults to start.
Quoted 5 lines
Quoted 1 line
Is not it linker bug?
The binutils upstream apparently doesn't seem to consider this as a bug ...
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
Quoted 28 lines · Daniel Kiper
Quoted 27 lines · Michael Chang via Grub-devel
Quoted 8 lines · Daniel Kiper
Quoted 5 lines · Michael Chang via Grub-devel
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
makeQuoted 2 lines
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.
Quoted 6 lines
Quoted 4 lines
6643507cebuild: Fix GRUB i386-pc build with Ubuntu gccTo 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.
Quoted 19 lines
Quoted 19 lines
Quoted 4 lines
Quoted 2 lines
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'.Quoted 6 lines
Quoted 5 lines
.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
0x400000where the elf executable defaults to start.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Is not it linker bug?
The binutils upstream apparently doesn't seem to consider this as a bug ...
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.
Quoted 3 lines
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
Quoted 9 lines
Daniel
[1] https://bugs.gentoo.org/787221
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel