grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3] Fix build error in binutils 2.36


From: Daniel Kiper
Subject: Re: [PATCH v3] Fix build error in binutils 2.36
Date: Tue, 28 Sep 2021 15:28:29 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Sep 28, 2021 at 01:50:47PM +0800, Michael Chang via Grub-devel wrote:
> The following procedure to build xen/pvgrub is broken.
>
>   git clone https://git.savannah.gnu.org/git/grub.git
>   cd grub
>   ./bootstrap
>   mkdir build-xen
>   cd build-xen
>   ../configure --with-platform=xen
>   make
>
> It fails with the message:
>
>   /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.
>
> It is also worth mentioning that binutils upstream apparently doesn't
> seem to consider this as a bug [2] and proposed to use
> -Wl,-Ttext-segment,0 which's not fruitful as what has been tested by
> gentoo [3].
>
> 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 above.
>
> This is considered a better approach than using custom linker script to
> drop the .note.gnu.property section because object file manipulation can
> also be hampered one way or the other in that linker script may not be
> helpful. See also this commit removing the section in the process of
> objcopy.
>
>   6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc
>
> [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;
>
> [2] Ref: https://sourceware.org/bugzilla/show_bug.cgi?id=27377
> [3] Ref: https://bugs.gentoo.org/787221
>
> Signed-off-by: Michael Chang <mchang@suse.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel



reply via email to

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