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: [PATCH] x86: Don't remove empty x86 properties


> 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.

-cary


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