diff options
| author | Mark Wielaard <mark@klomp.org> | 2018-11-12 23:34:24 +0100 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2018-11-13 13:46:40 +0100 |
| commit | 72e30c2e0cb49a9a300667fdd5ff09082f717950 (patch) | |
| tree | d8aa22a90873f98e00df21f33c0ae40c520f0de5 /libelf | |
| parent | 7a3f6fe60b8519b5372f5a5521ccbac59411f33f (diff) | |
| download | platform_external_elfutils-72e30c2e0cb49a9a300667fdd5ff09082f717950.tar.gz platform_external_elfutils-72e30c2e0cb49a9a300667fdd5ff09082f717950.tar.bz2 platform_external_elfutils-72e30c2e0cb49a9a300667fdd5ff09082f717950.zip | |
Handle GNU Build Attribute ELF Notes.
GNU Build Attribute ELF Notes are generated by the GCC annobin plugin
and described at https://fedoraproject.org/wiki/Toolchain/Watermark
Unfortunately the constants aren't yet described in the standard glibc
elf.h so they have been added to the elfutils specific elf-knowledge.h.
The notes abuse the name owner field to encode some data not in the
description. This makes it a bit hard to parse. We have to match the
note owner name prefix (to "GA") to be sure the type is valid. We also
cannot rely on the owner name being a valid C string since the attribute
name and value can contain zero (terminators). So pass around namesz
to the ebl note parsing functions.
eu-elflint will recognize and eu-readelf -n will now show the notes:
Note section [27] '.gnu.build.attributes' of 56080 bytes at offset 0x114564:
Owner Data size Type
GA 16 GNU Build Attribute OPEN
Address Range: 0x2f30f - 0x2f30f
VERSION: "3p8"
GA 0 GNU Build Attribute OPEN
TOOL: "gcc 8.2.1 20180801"
GA 0 GNU Build Attribute OPEN
"GOW": 45
GA 0 GNU Build Attribute OPEN
STACK_PROT: 0
GA 0 GNU Build Attribute OPEN
"stack_clash": TRUE
GA 0 GNU Build Attribute OPEN
"cf_protection": 0
GA 0 GNU Build Attribute OPEN
"GLIBCXX_ASSERTIONS": TRUE
GA 0 GNU Build Attribute OPEN
"FORTIFY": 0
GA 0 GNU Build Attribute OPEN
PIC: 3
GA 0 GNU Build Attribute OPEN
SHORT_ENUM: FALSE
GA 0 GNU Build Attribute OPEN
ABI: c001100000012
GA 0 GNU Build Attribute OPEN
"stack_realign": FALSE
A new test was added to run-readelf -n for the existing annobin file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libelf')
| -rw-r--r-- | libelf/ChangeLog | 9 | ||||
| -rw-r--r-- | libelf/elf-knowledge.h | 21 |
2 files changed, 30 insertions, 0 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 53da9a65..2675ba55 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,12 @@ +2018-11-12 Mark Wielaard <mark@klomp.org> + + * elf-knowledge.c (ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX): New define. + (NT_GNU_BUILD_ATTRIBUTE_{OPEN,FUNC}): Likewise. + (GNU_BUILD_ATTRIBUTE_TYPE_{NUMERIC,STRING,BOOL_TRUE,BOOL_FALSE}): + Likewise. + (GNU_BUILD_ATTRIBUTE_{VERSION,STACK_PROT,RELRO,STACK_SIZE,TOOL,ABI, + PIC,SHORT_ENUM}): Likewise. + 2018-11-09 Mark Wielaard <mark@klomp.org> * elf_compress.c (__libelf_reset_rawdata): Make rawdata change diff --git a/libelf/elf-knowledge.h b/libelf/elf-knowledge.h index 64f58878..9d3be0ff 100644 --- a/libelf/elf-knowledge.h +++ b/libelf/elf-knowledge.h @@ -77,4 +77,25 @@ || ((Ehdr)->e_machine == EM_S390 \ && (Ehdr)->e_ident[EI_CLASS] == ELFCLASS64) ? 8 : 4) +/* GNU Annobin notes are not fully standardized and abuses the owner name. */ + +#define ELF_NOTE_GNU_BUILD_ATTRIBUTE_PREFIX "GA" + +#define NT_GNU_BUILD_ATTRIBUTE_OPEN 0x100 +#define NT_GNU_BUILD_ATTRIBUTE_FUNC 0x101 + +#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 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 + #endif /* elf-knowledge.h */ |
