RFA: Add new note types to elf/elf.h

Message ID 87vapy8657.fsf@redhat.com
State New
Headers show

Commit Message

Nick Clifton April 21, 2017, 9:24 a.m.
Hi Guys,

  I would like to apply a patch to elf/elf.h to add support for two new
  note types.  The first is the GNU Property notes, proposed by H.J. Lu:

    https://github.com/hjl-tools/linux-abi/wiki/property-draft.pdf

  These notes are intended to be used by the dynamic linker to verify
  that the binary being loaded matches the available environment.

  The second note type is the GNU build attributes, proposed by myself:

    https://fedoraproject.org/wiki/Toolchain/Watermark

  These notes are intended for static analysis.  Hence they are not
  stored in an allocatable section.  Both types of note are generated by
  the compiler, although in theory they can also be generated by the
  assembler of linker.

  This patch simply adds the definitions of the note types and some of
  the constant values that they use to the elf/elf.h header file.  This
  is my first time posting here, so I apologise if have made any
  mistakes.  Anyway is this patch OK, and if so, please could it be
  applied ?

Cheers
  Nick

2017-04-21  Nick Clifton  <nickc@redhat.com>

	* elf/elf.h (NT_GNU_PROPERTY_TYPE_0): Define.
	(NOTE_GNU_PROPERTY_SECTION_NAME): Define.
	(GNU_PROPERTY_STACK_SIZE): Define.
	(GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define.
	(GNU_PROPERTY_LOPROC): Define.
	(GNU_PROPERTY_HIPROC): Define.
	(GNU_PROPERTY_LOUSER): Define.
	(GNU_PROPERTY_HIUSER): Define.
	(GNU_PROPERTY_X86_ISA_1_USED): Define.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Define.
	(GNU_PROPERTY_X86_ISA_1_486): Define.
	(GNU_PROPERTY_X86_ISA_1_586): Define.
	(GNU_PROPERTY_X86_ISA_1_686): Define.
	(GNU_PROPERTY_X86_ISA_1_SSE): Define.
	(GNU_PROPERTY_X86_ISA_1_SSE2): Define.
	(GNU_PROPERTY_X86_ISA_1_SSE3): Define.
	(GNU_PROPERTY_X86_ISA_1_SSSE3): Define.
	(GNU_PROPERTY_X86_ISA_1_SSE4_1): Define.
	(GNU_PROPERTY_X86_ISA_1_SSE4_2): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX2): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512F): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512CD): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512ER): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512PF): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512VL): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define.
	(GNU_PROPERTY_X86_ISA_1_AVX512BW): Define.
	(NT_GNU_BUILD_ATTRIBUTE_OPEN): Define.
	(NT_GNU_BUILD_ATTRIBUTE_FUNC): Define.
	(GNU_BUILD_ATTRS_SECTION_NAME): Define.
	(GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define.
	(GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define.
	(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define.
	(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define.
	(GNU_BUILD_ATTRIBUTE_VERSION): Define.
	(GNU_BUILD_ATTRIBUTE_STACK_PROT): Define.
	(GNU_BUILD_ATTRIBUTE_RELRO): Define.
	(GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define.
	(GNU_BUILD_ATTRIBUTE_TOOL): Define.
	(GNU_BUILD_ATTRIBUTE_ABI): Define.
	(GNU_BUILD_ATTRIBUTE_PIC): Define.
	(GNU_BUILD_ATTRIBUTE_SHORT_ENUM): Define.

Patch

diff --git a/elf/elf.h b/elf/elf.h
index fff893d..be4d111 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -1247,6 +1247,71 @@  typedef struct
 /* Version note generated by GNU gold containing a version string.  */
 #define NT_GNU_GOLD_VERSION	4
 
+/* Property notes generated by GCC for use with the dynamic linker.  */
+#define NT_GNU_PROPERTY_TYPE_0  5
+
+/* Default name of section containing NT_GNU_PROPERTY_TYPE_0 notes.  */
+#define NOTE_GNU_PROPERTY_SECTION_NAME	".note.gnu.property"
+
+/* Values used in NT_GNU_PROPERTY_TYPE_0 notes.  */
+#define GNU_PROPERTY_STACK_SIZE			1
+#define GNU_PROPERTY_NO_COPY_ON_PROTECTED	2
+/* Processor-specific semantics, low.  */
+#define GNU_PROPERTY_LOPROC                     0xc0000000
+/* Processor-specific semantics, high.  */
+#define GNU_PROPERTY_HIPROC                     0xdfffffff
+/* Application-specific semantics, low.  */
+#define GNU_PROPERTY_LOUSER                     0xe0000000
+/* Application-specific semantics, high.  */
+#define GNU_PROPERTY_HIUSER                     0xffffffff
+
+/* X86 specific note values for NT_GNU_PROPERTY_TYPE_0 notes.  */
+#define GNU_PROPERTY_X86_ISA_1_USED		0xc0000000
+#define GNU_PROPERTY_X86_ISA_1_NEEDED		0xc0000001
+
+/* Values for GNU_PROPERTY_X86_ISA notes.  */
+#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)
+
+
+/* Attribute notes generated by GCC for use with static analysis tools.  */
+#define NT_GNU_BUILD_ATTRIBUTE_OPEN	0x100
+#define NT_GNU_BUILD_ATTRIBUTE_FUNC	0x101
+
+/* Default name of section containing NT_GNU_BUILD_ATTRIBUTE notes.  */
+#define GNU_BUILD_ATTRS_SECTION_NAME	".gnu.build.attributes"
+
+/* Special characters at the start of GNU build attribute names.  */
+#define GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC	'*'
+#define GNU_BUILD_ATTRIBUTE_TYPE_STRING		'$'
+#define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE	'+'
+#define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE	'!'
+
+/* Special characters inside GNU build attribute names.  */
+#define GNU_BUILD_ATTRIBUTE_VERSION	1
+#define GNU_BUILD_ATTRIBUTE_STACK_PROT	2
+#define GNU_BUILD_ATTRIBUTE_RELRO	3
+#define GNU_BUILD_ATTRIBUTE_STACK_SIZE	4
+#define GNU_BUILD_ATTRIBUTE_TOOL	5
+#define GNU_BUILD_ATTRIBUTE_ABI		6
+#define GNU_BUILD_ATTRIBUTE_PIC		7
+#define GNU_BUILD_ATTRIBUTE_SHORT_ENUM	8
 
 /* Move records.  */
 typedef struct