mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[ELF] Support for PT_GNU_PROPERTY in header and tools
The PT_GNU_PROPERTY is generated by a linker to describe the .note.gnu.property section. The Linux kernel uses this program header to locate the .note.gnu.property section. It is described in "The Linux gABI extension" Include support for llvm-readelf, llvm-readobj and the yaml reader and writers. Differential Revision: https://reviews.llvm.org/D70959
This commit is contained in:
parent
a16841d246
commit
eb6dba5c2d
@ -1199,8 +1199,9 @@ enum {
|
||||
PT_SUNW_EH_FRAME = 0x6474e550,
|
||||
PT_SUNW_UNWIND = 0x6464e550,
|
||||
|
||||
PT_GNU_STACK = 0x6474e551, // Indicates stack executability.
|
||||
PT_GNU_RELRO = 0x6474e552, // Read-only after relocation.
|
||||
PT_GNU_STACK = 0x6474e551, // Indicates stack executability.
|
||||
PT_GNU_RELRO = 0x6474e552, // Read-only after relocation.
|
||||
PT_GNU_PROPERTY = 0x6474e553, // .note.gnu.property notes sections.
|
||||
|
||||
PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data.
|
||||
PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations.
|
||||
|
@ -54,6 +54,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_PT>::enumeration(
|
||||
ECase(PT_GNU_EH_FRAME);
|
||||
ECase(PT_GNU_STACK);
|
||||
ECase(PT_GNU_RELRO);
|
||||
ECase(PT_GNU_PROPERTY);
|
||||
#undef ECase
|
||||
IO.enumFallback<Hex32>(Value);
|
||||
}
|
||||
|
14
test/tools/llvm-objdump/elf-pt-gnu-property.test
Normal file
14
test/tools/llvm-objdump/elf-pt-gnu-property.test
Normal file
@ -0,0 +1,14 @@
|
||||
# RUN: yaml2obj %s -o %t
|
||||
# RUN: llvm-objdump -p %t | FileCheck %s
|
||||
|
||||
# CHECK: Program Header:
|
||||
# CHECK-NEXT: {{ }}PROPERTY{{ }}
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_EXEC
|
||||
Machine: EM_AARCH64
|
||||
ProgramHeaders:
|
||||
- Type: PT_GNU_PROPERTY
|
17
test/tools/llvm-readobj/elf-pt-gnu-property.test
Normal file
17
test/tools/llvm-readobj/elf-pt-gnu-property.test
Normal file
@ -0,0 +1,17 @@
|
||||
# RUN: yaml2obj %s -o %t
|
||||
# RUN: llvm-readelf --program-headers %t | FileCheck %s --check-prefix=GNU
|
||||
# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=LLVM
|
||||
|
||||
# GNU: {{ }}GNU_PROPERTY{{ }}
|
||||
|
||||
# LLVM: ProgramHeader {
|
||||
# LLVM-NEXT: Type: PT_GNU_PROPERTY (0x6474E553)
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_EXEC
|
||||
Machine: EM_AARCH64
|
||||
ProgramHeaders:
|
||||
- Type: PT_GNU_PROPERTY
|
@ -40,6 +40,7 @@ ProgramHeaders:
|
||||
- Type: PT_GNU_EH_FRAME
|
||||
- Type: PT_GNU_STACK
|
||||
- Type: PT_GNU_RELRO
|
||||
- Type: PT_GNU_PROPERTY
|
||||
|
||||
#CHECK: ProgramHeaders [
|
||||
#CHECK-NEXT: ProgramHeader {
|
||||
@ -76,6 +77,9 @@ ProgramHeaders:
|
||||
#CHECK-NEXT: ProgramHeader {
|
||||
#CHECK-NEXT: Type: PT_GNU_RELRO (0x6474E552)
|
||||
#CHECK: }
|
||||
#CHECK-NEXT: ProgramHeader {
|
||||
#CHECK-NEXT: Type: PT_GNU_PROPERTY (0x6474E553)
|
||||
#CHECK: }
|
||||
#CHECK-NEXT:]
|
||||
|
||||
## Check we do not allow referencing sections that do not exist.
|
||||
|
@ -204,6 +204,9 @@ template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) {
|
||||
case ELF::PT_GNU_RELRO:
|
||||
outs() << " RELRO ";
|
||||
break;
|
||||
case ELF::PT_GNU_PROPERTY:
|
||||
outs() << " PROPERTY ";
|
||||
break;
|
||||
case ELF::PT_GNU_STACK:
|
||||
outs() << " STACK ";
|
||||
break;
|
||||
|
@ -1446,6 +1446,7 @@ static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
|
||||
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_STACK);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_RELRO);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_PROPERTY);
|
||||
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED);
|
||||
@ -1470,6 +1471,7 @@ static std::string getElfPtType(unsigned Arch, unsigned Type) {
|
||||
LLVM_READOBJ_PHDR_ENUM(ELF, PT_SUNW_UNWIND)
|
||||
LLVM_READOBJ_PHDR_ENUM(ELF, PT_GNU_STACK)
|
||||
LLVM_READOBJ_PHDR_ENUM(ELF, PT_GNU_RELRO)
|
||||
LLVM_READOBJ_PHDR_ENUM(ELF, PT_GNU_PROPERTY)
|
||||
default:
|
||||
// All machine specific PT_* types
|
||||
switch (Arch) {
|
||||
|
Loading…
Reference in New Issue
Block a user