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

Re: [PATCH] x86/build: use --orphan-handling linker option if available


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 4 Mar 2022 10:46:19 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I4wCX8Yi6MLEgQvA1tVPPT2clhigiZoNTvtJw7rYau8=; b=gecbx3yyABGOP3SxqKE8W74nzCOaonUeZrv1stn/nVrz8OMwhvrh+iB6LWleO1nKUrJU8/yG3Pz/r03dTJQTEelQj2BWBex+r09UKYIX3mruRyCxw4n9RhGuDNVzDDp/OGgtIo+8eK+WWTB4yzufrwd+xg9gZVoQ401PINhfSF37qKiN5zeaIlM1v6Fu0JDsRV6CQ8uOIOMlyKr4oD9dMy2fDUq6pqxbldRwTiJVf5c0JKEygVT8A82r8P2dG264JMwIZZef69WqYy5XTL1+MQytKk6lr7w58ZpVhWTImnW6HIBjNsPaCOeFwwTPlpZLXxvV0HYPS5NDd9BzjZAb6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jy2yWJtUhnvfBpL521Mx7dMQ/KZz7IDomS0yx6KE4Xm4nxXG+fsd2OByzzCMEjYbKU93HgU1qki9fxpVz6GWaSJvvUNxB0gjRD3Er0HMoM6CFTD2pxSgYPDk6jGuPtTW7QTE1PRKTDvR5LAMLC6zf9DSN6N6WRgEjaGI+G2xqeFt5IUcrghEMkyxH7RyfyLXizTzDBy0xaYflCnzU2m05SuzhkHu5aoI0qKJ2gnPxKVL9vjn803m5xmo16vNkK567PeUU+lWbjrtwKAP1n90DCGQFi5xQSpbhhDaiYgxPGM2tttOeUkb1BHgUPe850Lnh65G3PI8w0cQXoIPgobowg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 04 Mar 2022 09:46:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04.03.2022 10:31, Roger Pau Monné wrote:
> On Fri, Mar 04, 2022 at 09:02:08AM +0100, Jan Beulich wrote:
>> On 03.03.2022 16:09, Roger Pau Monné wrote:
>>> On Thu, Mar 03, 2022 at 01:17:03PM +0100, Jan Beulich wrote:
>>>> On 03.03.2022 12:19, Roger Pau Monné wrote:
>>>>> On Wed, Mar 02, 2022 at 03:19:35PM +0100, Jan Beulich wrote:
>>>>>> As was e.g. making necessary 4b7fd8153ddf ("x86: fold sections in final
>>>>>> binaries"), arbitrary sections appearing without our linker script
>>>>>> placing them explicitly can be a problem. Have the linker make us aware
>>>>>> of such sections, so we would know that the script needs adjusting.
>>>>>>
>>>>>> To deal with the resulting warnings:
>>>>>> - Retain .note.* explicitly for ELF, and discard all of them (except the
>>>>>>   earlier consumed .note.gnu.build-id) for PE/COFF.
>>>>>> - Have explicit statements for .got, .plt, and alike and add assertions
>>>>>>   that they're empty. No output sections will be created for these as
>>>>>>   long as they remain empty (or else the assertions would cause early
>>>>>>   failure anyway).
>>>>>> - Collect all .rela.* into a single section, with again an assertion
>>>>>>   added for the resulting section to be empty.
>>>>>> - Extend the enumerating of .debug_* to ELF. Note that for Clang adding
>>>>>>   of .debug_macinfo is necessary. Amend this by its Dwarf5 counterpart,
>>>>>>   .debug_macro, then as well (albeit more may need adding for full
>>>>>>   coverage).
>>>>>>
>>>>>> Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>>>>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>>>>> ---
>>>>>> I would have wanted to make this generic (by putting it in
>>>>>> xen/Makefile), but the option cannot be added to LDFLAGS, or else
>>>>>> there'll be a flood of warnings with $(LD) -r. (Besides, adding to
>>>>>> LDFLAGS would mean use of the option on every linker pass rather than
>>>>>> just the last one.)
>>>>>>
>>>>>> Retaining of .note in xen-syms is under question. Plus if we want to
>>>>>> retain all notes, the question is whether they wouldn't better go into
>>>>>> .init.rodata. But .note.gnu.build-id shouldn't move there, and when
>>>>>> notes are discontiguous all intermediate space will also be assigned to
>>>>>> the NOTE segment, thus making the contents useless for tools going just
>>>>>> by program headers.
>>>>>>
>>>>>> Newer Clang may require yet more .debug_* to be added. I've only played
>>>>>> with versions 5 and 7 so far.
>>>>>>
>>>>>> Unless we would finally drop all mentioning of Stabs sections, we may
>>>>>> want to extend to there what is done for Dwarf here (allowing the EFI
>>>>>> conditional around the section to also go away).
>>>>>>
>>>>>> See also 
>>>>>> https://sourceware.org/pipermail/binutils/2022-March/119922.html.
>>>>>
>>>>> LLD 13.0.0 also warns about:
>>>>>
>>>>> ld: warning: <internal>:(.symtab) is being placed in '.symtab'
>>>>> ld: warning: <internal>:(.shstrtab) is being placed in '.shstrtab'
>>>>> ld: warning: <internal>:(.strtab) is being placed in '.strtab'
>>>>>
>>>>> So seeing your mail where you mention GNU ld not needing those, I
>>>>> think we would need to add them anyway for LLVM ld.
>>>>
>>>> Hmm, that's ugly. How do I recognize LLVM ld? I can't simply use a
>>>> pre-processor conditional keying off of __clang__, as that used as the
>>>> compiler doesn't mean their ld is also in use (typically the case on
>>>> Linux).
>>>
>>> Hard to tell, `ld -v` for LLD will typically contain '^LLD' I think,
>>> but I don't really like matching on human readable output like this.
>>
>> Same here. But Linux'es ld-version.sh looks to be doing just that.
>>
>>>> I also don't want to add these uniformly, for now knowing what
>>>> side effects their mentioning might have with GNU ld.
>>>
>>> Wouldn't it be fine to just place them at the end, just like it's
>>> done by default by ld?
>>>
>>> Are you worried about not getting the proper type if mentioned in the
>>> linker script?
>>
>> I'm worried of about any kind of anomaly that could be caused by
>> mentioning sections which a linker doesn't expect to be named in
>> a script. That's hardly something they would even test their
>> linkers against.
> 
> Just realized, in arch/x86/boot/build32.lds we already explicitly
> handle .symtab, .shstrtab and .strtab for LLD, it was added by commit
> 10d27b48b5b in order to prevent LLD from complaining about discarding
> those sections. So it should be safe to also do this handling in the
> general linker script?

I wouldn't want to infer such. What build32.lds is used for is very
simple input. It's a hint at best that it might be okay to use even
with GNU ld.

Jan




 


Rackspace

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