diff mbox

[1/2] elf: Update GNU_PROPERTY_X86_XXX macros [BZ #23797]

Message ID CAMe9rOoyn53k8gphwrM75mMrAW-qvy_mpE-1fGwn8Dc0oBTVUw@mail.gmail.com
State New, archived
Headers show

Commit Message

H.J. Lu Nov. 9, 2018, 1:53 p.m. UTC
On Fri, Nov 9, 2018 at 2:08 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > +/* Set by linker to indicate that the property is valid.  */
> > +#define GNU_PROPERTY_X86_UINT32_VALID                (1U << 31)
>
> This should somehow say that a relocatable link (which is also performed
> by the linker, via ld -r) must not set this bit.  Only the final link
> may set it.
>

Like this?
diff mbox

Patch

From 7f16db908aa2b513509321773f32e8db9e932f94 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 19 Oct 2018 15:47:43 -0700
Subject: [PATCH 1/2] elf: Update GNU_PROPERTY_X86_XXX macros [BZ #23797]

This patch updates GNU_PROPERTY_X86_XXX macros according to the x86
program property in x86-64 psABI:

https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-property.pdf

1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_AND_LO      0xc0000002
 #define GNU_PROPERTY_X86_UINT32_AND_HI      0xc0007fff

2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_LO    0xc0008000
 #define GNU_PROPERTY_X86_UINT32_OR_HI    0xc000ffff

3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_AND_LO   0xc0010000
 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI   0xc0017fff

4. GNU_PROPERTY_X86_UINT32_VALID: Set by linker to indicate that the
property is valid when creating executables and shared objects.

5. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.

GNU_PROPERTY_X86_FEATURE_1_AND is unchanged.  GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_FEATURE_2_USED are redefined to better support
targeted processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very
useful.  A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined.  The
previous GNU_PROPERTY_X86_ISA_1_XXX macros are removed.

NOTE: The NT_GNU_PROPERTY_TYPE_0 note is used to describe features and
capabilities supported by ELF binaries.  Consumers of ELF binaries can
consult the NT_GNU_PROPERTY_TYPE_0 note to make appropriate decisions.
If a consumer of ELF binaries ignores NT_GNU_PROPERTY_TYPE_0 note, nothing
is changed.

	[BZ #23797]
	* elf.h (GNU_PROPERTY_X86_UINT32_AND_LO): New.
	(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
	(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
	(GNU_PROPERTY_X86_UINT32_VALID): Likewise.
	(GNU_PROPERTY_X86_ISA_1_CMOV): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE3): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSSE3): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE4_1): Likewise.
	(GNU_PROPERTY_X86_ISA_1_SSE4_2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_FMA): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512F): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512CD): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512ER): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512PF): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512VL): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512BW): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_BITALG): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_IFMA): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_VBMI): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_AVX512_VNNI): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_X86): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_X87): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_MMX): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XMM): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_YMM): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_ZMM): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_FXSR): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XSAVE): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_XSAVEC): Likewise.
	(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
	(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Defined to
	(GNU_PROPERTY_X86_UINT32_OR_LO + 0).
	(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
	(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
	(GNU_PROPERTY_X86_ISA_1_USED): Defined to
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0).
	(GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
	(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).
---
 elf/elf.h | 99 +++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 74 insertions(+), 25 deletions(-)

diff --git a/elf/elf.h b/elf/elf.h
index 69ffa2ec0e..6a21b119b0 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -1307,33 +1307,82 @@  typedef struct
 /* Application-specific semantics, hi */
 #define GNU_PROPERTY_HIUSER			0xffffffff
 
-/* The x86 instruction sets indicated by the corresponding bits are
-   used in program.  Their support in the hardware is optional.  */
-#define GNU_PROPERTY_X86_ISA_1_USED		0xc0000000
+/* A 4-byte unsigned integer property: A bit is set if it is set in all
+   relocatable inputs.  */
+#define GNU_PROPERTY_X86_UINT32_AND_LO		0xc0000002
+#define GNU_PROPERTY_X86_UINT32_AND_HI		0xc0007fff
+
+/* A 4-byte unsigned integer property: A bit is set if it is set in any
+   relocatable inputs.  */
+#define GNU_PROPERTY_X86_UINT32_OR_LO		0xc0008000
+#define GNU_PROPERTY_X86_UINT32_OR_HI		0xc000ffff
+
+/* A 4-byte unsigned integer property: A bit is set if it is set in any
+   relocatable inputs and the property is present in all relocatable
+   inputs.  */
+#define GNU_PROPERTY_X86_UINT32_OR_AND_LO	0xc0010000
+#define GNU_PROPERTY_X86_UINT32_OR_AND_HI	0xc0017fff
+
+/* X86 processor-specific features used in program.  */
+#define GNU_PROPERTY_X86_FEATURE_1_AND \
+  (GNU_PROPERTY_X86_UINT32_AND_LO + 0)
+
 /* The x86 instruction sets indicated by the corresponding bits are
    used in program and they must be supported by the hardware.   */
-#define GNU_PROPERTY_X86_ISA_1_NEEDED		0xc0000001
-/* X86 processor-specific features used in program.  */
-#define GNU_PROPERTY_X86_FEATURE_1_AND		0xc0000002
-
-#define GNU_PROPERTY_X86_ISA_1_486		(1U << 0)
-#define GNU_PROPERTY_X86_ISA_1_586		(1U << 1)
-#define GNU_PROPERTY_X86_ISA_1_686		(1U << 2)
-#define GNU_PROPERTY_X86_ISA_1_SSE		(1U << 3)
-#define GNU_PROPERTY_X86_ISA_1_SSE2		(1U << 4)
-#define GNU_PROPERTY_X86_ISA_1_SSE3		(1U << 5)
-#define GNU_PROPERTY_X86_ISA_1_SSSE3		(1U << 6)
-#define GNU_PROPERTY_X86_ISA_1_SSE4_1		(1U << 7)
-#define GNU_PROPERTY_X86_ISA_1_SSE4_2		(1U << 8)
-#define GNU_PROPERTY_X86_ISA_1_AVX		(1U << 9)
-#define GNU_PROPERTY_X86_ISA_1_AVX2		(1U << 10)
-#define GNU_PROPERTY_X86_ISA_1_AVX512F		(1U << 11)
-#define GNU_PROPERTY_X86_ISA_1_AVX512CD		(1U << 12)
-#define GNU_PROPERTY_X86_ISA_1_AVX512ER		(1U << 13)
-#define GNU_PROPERTY_X86_ISA_1_AVX512PF		(1U << 14)
-#define GNU_PROPERTY_X86_ISA_1_AVX512VL		(1U << 15)
-#define GNU_PROPERTY_X86_ISA_1_AVX512DQ		(1U << 16)
-#define GNU_PROPERTY_X86_ISA_1_AVX512BW		(1U << 17)
+#define GNU_PROPERTY_X86_ISA_1_NEEDED \
+  (GNU_PROPERTY_X86_UINT32_OR_LO + 0)
+#define GNU_PROPERTY_X86_FEATURE_2_NEEDED \
+  (GNU_PROPERTY_X86_UINT32_OR_LO + 1)
+
+/* The x86 instruction sets indicated by the corresponding bits are
+   used in program.  Their support in the hardware is optional.  */
+#define GNU_PROPERTY_X86_ISA_1_USED \
+  (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0)
+#define GNU_PROPERTY_X86_FEATURE_2_USED \
+  (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1)
+
+/* Set by linker to indicate that the property is valid when creating
+   executables and shared objects.  */
+#define GNU_PROPERTY_X86_UINT32_VALID		(1U << 31)
+
+#define GNU_PROPERTY_X86_FEATURE_1_IBT		(1U << 0)
+#define GNU_PROPERTY_X86_FEATURE_1_SHSTK	(1U << 1)
+
+#define GNU_PROPERTY_X86_ISA_1_CMOV		(1U << 0)
+#define GNU_PROPERTY_X86_ISA_1_SSE		(1U << 1)
+#define GNU_PROPERTY_X86_ISA_1_SSE2		(1U << 2)
+#define GNU_PROPERTY_X86_ISA_1_SSE3		(1U << 3)
+#define GNU_PROPERTY_X86_ISA_1_SSSE3		(1U << 4)
+#define GNU_PROPERTY_X86_ISA_1_SSE4_1		(1U << 5)
+#define GNU_PROPERTY_X86_ISA_1_SSE4_2		(1U << 6)
+#define GNU_PROPERTY_X86_ISA_1_AVX		(1U << 7)
+#define GNU_PROPERTY_X86_ISA_1_AVX2		(1U << 8)
+#define GNU_PROPERTY_X86_ISA_1_FMA		(1U << 9)
+#define GNU_PROPERTY_X86_ISA_1_AVX512F		(1U << 10)
+#define GNU_PROPERTY_X86_ISA_1_AVX512CD		(1U << 11)
+#define GNU_PROPERTY_X86_ISA_1_AVX512ER		(1U << 12)
+#define GNU_PROPERTY_X86_ISA_1_AVX512PF		(1U << 13)
+#define GNU_PROPERTY_X86_ISA_1_AVX512VL		(1U << 14)
+#define GNU_PROPERTY_X86_ISA_1_AVX512DQ		(1U << 15)
+#define GNU_PROPERTY_X86_ISA_1_AVX512BW		(1U << 16)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS	(1U << 17)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW	(1U << 18)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_BITALG	(1U << 19)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_IFMA	(1U << 20)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_VBMI	(1U << 21)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2	(1U << 22)
+#define GNU_PROPERTY_X86_ISA_1_AVX512_VNNI	(1U << 23)
+
+#define GNU_PROPERTY_X86_FEATURE_2_X86		(1U << 0)
+#define GNU_PROPERTY_X86_FEATURE_2_X87		(1U << 1)
+#define GNU_PROPERTY_X86_FEATURE_2_MMX		(1U << 2)
+#define GNU_PROPERTY_X86_FEATURE_2_XMM		(1U << 3)
+#define GNU_PROPERTY_X86_FEATURE_2_YMM		(1U << 4)
+#define GNU_PROPERTY_X86_FEATURE_2_ZMM		(1U << 5)
+#define GNU_PROPERTY_X86_FEATURE_2_FXSR		(1U << 6)
+#define GNU_PROPERTY_X86_FEATURE_2_XSAVE	(1U << 7)
+#define GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT	(1U << 8)
+#define GNU_PROPERTY_X86_FEATURE_2_XSAVEC	(1U << 9)
 
 /* This indicates that all executable sections are compatible with
    IBT.  */
-- 
2.19.1