This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: binutils ld and new PT_GNU_PROPERTY segment


On Wed, Feb 19, 2020 at 10:27 AM Fangrui Song <i@maskray.me> wrote:
>
> On 2020-02-19, H.J. Lu wrote:
> >On Wed, Feb 19, 2020 at 5:17 AM Mark Wielaard <mark@klomp.org> wrote:
> >>
> >> On Wed, 2020-02-19 at 04:28 -0800, H.J. Lu wrote:
> >> > On Wed, Feb 19, 2020 at 4:02 AM Mark Wielaard <mark@klomp.org> wrote:
> >> > > > https://patchwork.kernel.org/patch/11285409/
> >> > > >
> >> > > > It is for both x86 and arm64.
> >> > >
> >> > > So that is not upstream in the mainline kernel? Why can't that patch
> >> > > use the existing PT_NOTE segment? That would make it compatible with
> >> > > existing binaries that don't have this PT_GNU_PROPERTY program header.
> >> >
> >> > Kernel loader is one of motivations of PT_GNU_PROPERTY.  Kernel loader
> >> > only wants to check PT_XXX.
> >>
> >> So they can check PT_NOTE because it provides the same information and
> >> is already available in existing binaries.
> >>
> >
> >Please take a look at glibc note.gnu.property parser.  It is very complicated to
> >check for invalid .note.gnu.property sections generated by the older
> >linkers with
> >the new object.  Kernel loader doesn't want to do it.
>
> One way to make things follow the spirit of https://sourceware.org/ml/gnu-gabi/2018-q4/msg00036.html
>
> * Define SHT_GNU_PROPERTY
> * Set sh_type(.note.gnu.property) to SHT_GNU_PROPERTY
> * Place SHT_GNU_PROPERTY sections in a PT_GNU_PROPERTY segment
>
> The generated PT_NOTE will not include .note.gnu.property, so the scheme is compatible with old loaders (ld.so, gdb, Linux, etc).
> New loaders should interpret PT_GNU_PROPERTY, instead of PT_NOTE.
>    ( https://patchwork.kernel.org/patch/11285409/ needs no change)
>
> This way linkers can keep treating SHT_NOTE sections as opaque and apply "Rules for Linking Unrecognized Sections" (http://www.sco.com/developers/gabi/latest/ch4.sheader.html ) when combining SHT_NOTE sections. At least for lld, there will be no special rules for input SHT_NOTE sections.
>
> I will be happy to make changes to lld and LLVM binary utilities if this
> scheme reaches consensus.

It is kind of too late now.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]