This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] x86: Don't remove empty x86 properties
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: x86-64-abi <x86-64-abi at googlegroups dot com>, Binutils <binutils at sourceware dot org>
- Date: Wed, 5 Dec 2018 10:41:35 -0800
- Subject: Re: [PATCH] x86: Don't remove empty x86 properties
- References: <20181126214508.105748-1-hjl.tools@gmail.com> <CAJimCsHhUNTbMrO5uDfkaRVJSGz6QaJK3vBPbbpYGHE0mPirEA@mail.gmail.com> <CAMe9rOqNwUxYTYN1xVdrpSc9VC16tnxAYuzvgJvGAacE6W5eMQ@mail.gmail.com> <CAJimCsHdzQF8dwQUO5Yeg8RjZVOxOmVbdtBXFbLBEqGKnNAV0g@mail.gmail.com> <CAJimCsHwHoiB+mFozJeeL9Cux5-9bJA2Vu0VAAWsDtJGoXUv8w@mail.gmail.com> <CAMe9rOrdHAg6KNLXXvrbkLPxehi6yodOPzchZuHY9B+3ayQ7SA@mail.gmail.com> <CAJimCsH+8X=UC-EaeR0H8iVS67yLc-DK9PzSrHFnzoRP_thNPQ@mail.gmail.com> <CAMe9rOri3Osi9d6db-+EFw3bcp7tWG12ytx5rebcpaVSa2id_A@mail.gmail.com> <CAJimCsEwWqqWxnTNrXZ+AhcBVovjOdb33O=VE2eKpJ6baMHFQA@mail.gmail.com> <CAMe9rOoB5unY6MOL8DmTWDo2gkbwBOHRvj0oxZ2E3SK8t4VO3A@mail.gmail.com> <CAJimCsEuD+Cgq_zSbTMxTPjbPouB9i729FxgaB3=p-ccA=cNtA@mail.gmail.com> <CAMe9rOrwbiAmyL3=KDstQmwrxKVZ6odrma71s_fOx-vUdnPaVg@mail.gmail.com> <CAJimCsFHjvgZaCDmhOPd+1iD_HJqhKmn6jiy72PSXBugt04a6Q@mail.gmail.com> <CAMe9rOoJSUQtWE=BmhXFKsfO=CoB56RK+8uEC25btgoThSN1+w@mail.gmail.com> <CAJimCsHR2ixUqqLAiHvr6j+a3XDOgstbNRcTq_s_82dsNgs01Q@mail.gmail.com> <CAMe9rOoKQsJpkfVauOaYwbydb4OF=dOGq3fmOFW=bjOiyui5Vw@mail.gmail.com> <CAJimCsExxWio=XbjeTFBKiCb1+0h9jmWjfkojns1PCsAtEw5BQ@mail.gmail.com>
On Wed, Dec 5, 2018 at 10:17 AM Cary Coutant <ccoutant@gmail.com> wrote:
>
> > GNU_PROPERTY_X86_UINT32_OR_LO..GNU_PROPERTY_X86_UINT32_OR_HI
> > A bit in the output pr_data field is set if it is set in any
> > relocatable input pr_data
> > fields. If all bits in the the output pr_data field are zero, this
> > property should be
> > removed from output. If the bit is 1, some input relocatables have the
> > feature. If
> > the bit is 0 or the property is missing, it is unknown whether any
> > input relocatables
> > have the feature.
> >
> > GNU_PROPERTY_X86_UINT32_OR_AND_LO..GNU_PROPERTY_X86_UINT32_OR_AND_HI
> > A bit in the output pr_data field is set if it is set in any
> > relocatable input pr_data
> > fields and this property is present in all relocatable input files. A
> > missing property
> > implies that its bits have unknown values. When all bits in the the
> > output pr_data
> > field are zero, this property should not be removed from output to
> > indicate it has
> > zero in all bits. If the property is in output, all input relocatables
> > have the property.
> > If the bit is 1, some input relocatables have the feature. If the bit
> > is 0, none of input
> > relocatables have the feature.
> >
> > How do they differ from bfd linker?
>
> I didn't say they did. Indeed, it seems that bfd linker implements
> these ranges as documented. But see below.
>
> > An x86 program main () may contain AVX512 instructions, whose usage is
> > guarded by CPUID. NEEDED describes features that main() uses without
> > CPUID check. In this case, AVX512 is USED, not NEEDED.
>
> Fine. That's what I at first presumed, until you said that bit about
> "NEEDED is for main() and USED is for functions that main() may call".
> That was very misleading.
>
> > How about this?
> >
> > GNU_PROPERTY_X86_FEATURE_2_USED The x86 processor features indicated
> > by the corresponding bits are used in program. Their support in the hardware is
> > optional. Its absence in an x86 ELF binary implies that any x86
> > processor features
> > may be used. GNU_PROPERTY_X86_FEATURE_2_USED can be used to check
> > for features used in the program.
> >
> > GNU_PROPERTY_X86_FEATURE_2_NEEDED The x86 processor features
> > indicated by the corresponding bits are used in program and they must be
> > supported by the hardware. Loader may refuse to load the program whose
> > GNU_PROPERTY_X86_FEATURE_2_NEEDED features aren’t supported by the
> > hardware.
> >
> > GNU_PROPERTY_X86_ISA_1_NEEDED The x86 instruction sets indicated by the
> > corresponding bits are used in program and they must be supported by
> > the hardware.
> > Loader may refuse to load the program whose GNU_PROPERTY_X86_ISA_1_NEEDED
> > ISAs aren’t supported by the hardware.
> >
> > GNU_PROPERTY_X86_ISA_1_USED The x86 instruction sets indicated by the
> > corresponding bits are used in program. Their support in the hardware
> > is optional.
> > GNU_PROPERTY_X86_ISA_1_USED can be used to check for ISAs used in the
> > program.
>
> This is also fine. But it's not what you've implemented!
>
> You've implemented these with the USED properties in the OR_AND range,
> and the NEEDED properties in the OR range:
>
> Table 5.3: Program Property Types
> Name Value
> GNU_PROPERTY_X86_FEATURE_1_AND GNU_PROPERTY_X86_UINT32_AND_LO + 0
> GNU_PROPERTY_X86_FEATURE_2_USED GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1
> GNU_PROPERTY_X86_FEATURE_2_NEEDED GNU_PROPERTY_X86_UINT32_OR_LO + 1
> GNU_PROPERTY_X86_ISA_1_USED GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0
> GNU_PROPERTY_X86_ISA_1_NEEDED GNU_PROPERTY_X86_UINT32_OR_LO + 0
>
> The way you've defined the values, ISA_1_USED uses the OR_AND rule,
> which implements the behavior you want for ISA_1_NEEDED. ISA_1_NEEDED
> uses the OR rule, which implements the behavior you want for
> ISA_1_USED. Likewise for FEATURE_2_USED and FEATURE_2_NEEDED.
I committed a typo fix. Now it reads
GNU_PROPERTY_X86_FEATURE_2_NEEDED The x86 processor features in-
dicated by the corresponding bits are needed in program and they must be
supported by the hardware. Loader may refuse to load the program whose
GNU_PROPERTY_X86_FEATURE_2_NEEDED features aren’t supported by the
hardware.
GNU_PROPERTY_X86_ISA_1_NEEDED The x86 instruction sets indicated
by the corresponding bits are needed in program and they must be sup-
ported by the hardware.
Loader may refuse to load the program whose
GNU_PROPERTY_X86_ISA_1_NEEDED ISAs aren’t supported by the hardware.
--
H.J.