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

Re: [PATCH 2/8] x86/EFI: sections may not live at VA 0 in PE binaries



On 21.04.2021 10:52, Roger Pau Monné wrote:
> On Thu, Apr 01, 2021 at 11:44:45AM +0200, Jan Beulich wrote:
>> PE binaries specify section addresses by (32-bit) RVA. GNU ld up to at
>> least 2.36 would silently truncate the (negative) difference when a
>> section is placed below the image base. Such sections would also be
>> wrongly placed ahead of all "normal" ones. Since, for the time being,
>> we build xen.efi with --strip-debug anyway, .stab* can't appear. And
>> .comment has an entry in /DISCARD/ already anyway in the EFI case.
>>
>> Because of their unclear origin, keep the directives for the ELF case
>> though.
> 
> It's my understadng thonse sections are only there for debug purposes,
> and never part of the final xen binary as they are stripped?
> 
> Could we maybe remove the section load address of 0 and instead just
> use the (NOLOAD) directive?

(NOLOAD) is meaningless for PE.

> Does it really matter to place them at address 0?

That's the convention for ELF, and also what ld defaults to for debugging
sections.

> I also wonder, is this change fixing some existing bug, or it's just a
> cleanup change?

If there were sections at 0, the resulting PE binary would end up broken.
Prior to binutils 2.37 this brokenness is silent, i.e. the linker doesn't
issue any form of diagnostic. The change therefore is addressing a latent
issue - if any such section started being non-empty, we'd be in trouble.

> I also only see the .comment section in my binary output, so maybe
> it's fine to just remove them from the script?

Which binary are you referring to - ELF or PE? In the former case, yes,
that's what the statement is for. In the latter case I can't see how this
would be, with .comment being explicitly part of /DISCARD/ in that case.

> Does the Arm linker script need a similar treatment?

No idea - they don't use ld to produce a PE binary. In fact during my
work on the binutils side for all of this, I was given a hint that on Arm
linking ELF objects into PE output may currently not be possible at all.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.