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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 8 Mar 2022 15:07:40 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=sjaZHswrTyR4+kwDwtyQgFJTnNDjhsCfHY4wRa/Q9NA=; b=Sy5FbSfnichY+H59Si5yxygIQra9RAhch7RnoNV/8n/lbT/bnTEAyBqspPezpUMBHeuAlQ6NvxJLmCZQzp6br6LpJGOdsibC2HBI03t/6uVDvuQKl6KF9V6tE9e0doAUeCtqFChz1oJfuQuWNWFMYmHmJo5NHUqwVM+TsaJLSfNIWU0qz6kbOMze6BrE6SGl9Z/Rw3ogVnR10DYquQ0lzfMmroL4hvp1v5GWaxZTH53SERv/qNyecisagPuJREozH2VbNoCdX/+uWz7t+5MLSWlxxCi8AzAuTi5TAChW6k2yepw8R/5tTT694SZnWh/zr8Lfbpi/U9Gxv8EgmaoaJA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuHSQbZw1NDYjhWhM3FF4KhyKa/FePhS+bom7Z33orUks6b5quar2atLILYUd01e/exo+SW7B4ZPpfB2o/TSQz+tsH/bFEXGyQiPBj6mrIIuxVbpde/+ZYYYybWWr+rfCNs/mSVV0zsabkufzD5je6ShnkgZnq9T26z2Qxj5A/LmidtzbxYYCtBBAPoFYyH7veAcZM3wRYZ00OWmrc4tHHDu3Gbtso5hFaEBhHe1n1MToY7DHM6PJx925AyJoDPjDasngeFiQmyQwYQxFDdyg+hLrzCzMYBkhk7Cwekm1U2oHKWaEbiS2etakn+VWF4t+4EkOjhp5vQLX+ytl9z1RA==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 08 Mar 2022 14:08:01 +0000
  • Ironport-data: A9a23:5nrITatTFm8SdjZIDA7DF6Q/uufnVEBeMUV32f8akzHdYApBsoF/q tZmKTjSPvbeY2D1LY1xaYyy80sOvpCHndJjGgNr+HhjHnwQ+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZhSAgk/nOHNIQMcacUsxLbVYMpBwJ1FQyw4bVvqYy2YLjW1jV6 YuoyyHiEATNNwBcYzp8B52r8HuDjNyq0N/PlgVjDRzjlAa2e0g9VPrzF4noR5fLatA88tqBb /TC1NmEElbxpH/BPD8HfoHTKSXmSpaKVeSHZ+E/t6KK2nCurQRquko32WZ1he66RFxlkvgoo Oihu6BcRi8GAe7xvrU+CyUBOHB5PpBA0ZngK1aw5Jn7I03uKxMAwt1rBUAye4YZ5vx2ESdF8 vlwxDIlN07ZwbjsmfTiF7cq1p9LwMrDZevzvll6yj7UF7A+SI3rSKTW/95Imjw3g6iiGN6AO pVANWQ1M3wsZTVdAWgcOL4Snt3wm1+vaQxVjgOej6A4tj27IAtZj+G2bYu9lsaxbdpRtlaVo CTB5WuRKgEXMpmTxCSI9lqoh/TThmXrVYQKDrq6+/V2xlqJyQQ7ChcbSF+6qvmRkVOlVpRUL El8x8Y1hfFsrgrxFIC7BkDm5i7f1vIBZzZOO8IFqzyrm4mM31+yV28HczhoTvssmsBjEFTGy WS1t9/uADVutpicRnSc6qqYoFuOBMQFEYMRTXRaFFVYurEPtKl210uSFYg7TMZZm/WoQWmY/ tyckMQpa1z/Z+Yv3r7zw13IiinESnPhHl9svVW/so5IA2pEiG+Zi26AtACzARVodt/xory9U J4swZD2AAcmV83lqcB1aL9RdIxFHt7cWNEmvXZhHoM66xOm8GO5cIZb7VlWfRk1bJhbKWKyO R+O4mu9AaO/2lPwNsebhKrrV6wXIVXIT4y5Bpg4kPIUCnSOSON31H43PhPBt4wcuEMtjbs+K f+mnTWEVh4n5VBc5GPuHY81iOZzrghnnD+7bc2rnnyPjOvFDFbIGOhtDbd7Rr1ghE9yiF6Oq Ig32grj40g3bdASlQGLqd5Ddw5bdyNnbX00wuQOHtO+zsNdMDhJI9fawK87epwjmKJQl+zS+ Wq6VFMew1367UAr4y3UApy/QNsDhapCkE8=
  • Ironport-hdrordr: A9a23:2Uog96iyDOA87oTSs5fPSoHbY3BQXt4ji2hC6mlwRA09TyX+rb HIoB17726RtN91YhodcL+7VJVoLUmyyXcX2+ks1NWZMjUO0VHAROsO0WKI+VzdMhy72ulB1b pxN4hSYeeAaGSSVPyKgzVQxexQouW6zA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Mar 08, 2022 at 01:34:06PM +0100, Jan Beulich wrote:
> On 08.03.2022 13:11, Roger Pau Monné wrote:
> > On Tue, Mar 08, 2022 at 12:15:04PM +0100, Jan Beulich wrote:
> >> On 08.03.2022 11:12, Roger Pau Monné wrote:
> >>> On Mon, Mar 07, 2022 at 02:53:32PM +0100, Jan Beulich wrote:
> >>>> @@ -179,6 +188,13 @@ SECTIONS
> >>>>  #endif
> >>>>  #endif
> >>>>  
> >>>> +#ifndef EFI
> >>>> +  /* Retain these just for the purpose of possible analysis tools. */
> >>>> +  DECL_SECTION(.note) {
> >>>> +       *(.note.*)
> >>>> +  } PHDR(note) PHDR(text)
> >>>
> >>> Wouldn't it be enough to place it in the note program header?
> >>>
> >>> The buildid note is already placed in .rodata, so any remaining notes
> >>> don't need to be in a LOAD section?
> >>
> >> All the notes will be covered by the NOTE phdr. I had this much later
> >> in the script originally, but then the NOTE phdr covered large parts of
> >> .init.*. Clearly that yields invalid notes, which analysis (or simple
> >> dumping) tools wouldn't be happy about. We might be able to add 2nd
> >> NOTE phdr, but mkelf32 assumes exactly 2 phdrs if it finds more than
> >> one, so changes there would likely be needed then (which I'd like to
> >> avoid for the moment). I'm also not sure in how far tools can be
> >> expected to look for multiple NOTE phdrs ...
> > 
> > But if we are adding a .note section now we might as well merge it
> > with .note.gnu.build-id:
> > 
> >   DECL_SECTION(.note) {
> >        __note_gnu_build_id_start = .;
> >        *(.note.gnu.build-id)
> >        __note_gnu_build_id_end = .;
> >        *(.note.*)
> >   } PHDR(note) PHDR(text)
> > 
> > And drop the .note.Xen section?
> 
> In an ideal world we likely could, yes. But do we know for sure that
> nothing recognizes the Xen notes by section name?

Wouldn't that be wrong? In the elfnotes.h file it's clearly specified
that Xen notes live in a PT_NOTE program header and have 'Xen' in the
name field. There's no requirement of them being in any specific
section.

> .note.gnu.build-id
> cannot be folded in any event - see the rule for generating note.o,
> to be used by xen.efi linking in certain cases.

Right, so we need to keep the .note.gnu.build-id section, but we could
likely fold .note.Xen into .note I think?

Or at least add a comment to mention that we don't want to fold
.note.Xen into .note in case there are tools that search for specific
Xen notes to be contained in .note.Xen.

> >>>> +#endif
> >>>> +
> >>>>    _erodata = .;
> >>>>  
> >>>>    . = ALIGN(SECTION_ALIGN);
> >>>> @@ -266,6 +282,32 @@ SECTIONS
> >>>>         __ctors_end = .;
> >>>>    } PHDR(text)
> >>>>  
> >>>> +#ifndef EFI
> >>>> +  /*
> >>>> +   * With --orphan-sections=warn (or =error) we need to handle certain 
> >>>> linker
> >>>> +   * generated sections. These are all expected to be empty; respective
> >>>> +   * ASSERT()s can be found towards the end of this file.
> >>>> +   */
> >>>> +  DECL_SECTION(.got) {
> >>>> +       *(.got)
> >>>> +  } PHDR(text)
> >>>> +  DECL_SECTION(.got.plt) {
> >>>> +       *(.got.plt)
> >>>> +  } PHDR(text)
> >>>> +  DECL_SECTION(.igot.plt) {
> >>>> +       *(.igot.plt)
> >>>> +  } PHDR(text)
> >>>> +  DECL_SECTION(.iplt) {
> >>>> +       *(.iplt)
> >>>> +  } PHDR(text)
> >>>> +  DECL_SECTION(.plt) {
> >>>> +       *(.plt)
> >>>> +  } PHDR(text)
> >>>> +  DECL_SECTION(.rela) {
> >>>> +       *(.rela.*)
> >>>> +  } PHDR(text)
> >>>
> >>> Why do you need to explicitly place those in the text program header?
> >>
> >> I guess that's largely for consistency with all other directives. With the
> >> assertions that these need to be empty, we might get away without, as long
> >> as no linker would decide to set up another zero-size phdr for them.
> > 
> > We already set the debug sections to not be part of any program header
> > and seem to get away with it. I'm not sure how different the sections
> > handled below would be, linkers might indeed want to place them
> > regardless?
> 
> Simply because I don't know I'd like to be on the safe side. Debug sections
> can't really be taken as reference: At least GNU ld heavily special-cases
> them anyway.
> 
> > If so it might be good to add a comment that while those should be
> > empty (and thus don't end up in any program header) we assign them to
> > the text one in order to avoid the linker from creating a new program
> > header for them.
> 
> I'll add a sentence to the comment I'm already adding here.

Thanks, Roger.



 


Rackspace

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