Commit 2120612e authored by Peter Smith's avatar Peter Smith
Browse files

[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
parent 678f1284
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1201,6 +1201,7 @@ enum {

  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.
+1 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
# 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 −0
Original line number Diff line number Diff line
# 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
+4 −0
Original line number Diff line number Diff line
@@ -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.
Loading