Index: llvm/include/llvm/BinaryFormat/ELF.h =================================================================== --- llvm/include/llvm/BinaryFormat/ELF.h +++ llvm/include/llvm/BinaryFormat/ELF.h @@ -1199,8 +1199,9 @@ 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. Index: llvm/lib/ObjectYAML/ELFYAML.cpp =================================================================== --- llvm/lib/ObjectYAML/ELFYAML.cpp +++ llvm/lib/ObjectYAML/ELFYAML.cpp @@ -54,6 +54,7 @@ ECase(PT_GNU_EH_FRAME); ECase(PT_GNU_STACK); ECase(PT_GNU_RELRO); + ECase(PT_GNU_PROPERTY); #undef ECase IO.enumFallback(Value); } Index: llvm/test/tools/llvm-objdump/elf-pt-gnu-property.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-objdump/elf-pt-gnu-property.test @@ -0,0 +1,31 @@ +## Test that -p can print PT_GNU_PROPERTY + +# RUN: yaml2obj %s > %t +# RUN: llvm-objdump -p %t | FileCheck %s + +# CHECK: Program Header: +# CHECK-NEXT: GNU_PROPERTY off 0x0000000000000078 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3 +# CHECK-NEXT: filesz 0x0000000000000020 memsz 0x0000000000000020 flags --- + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_AARCH64 +Sections: + - Name: .note.gnu.property + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000000000 + AddressAlign: 0x0000000000000008 + Notes: + - Name: GNU + Desc: 000000C0040000000300000000000000 + Type: 0x00000005 +ProgramHeaders: + - Type: PT_GNU_PROPERTY + Align: 8 + Sections: + - Section: .note.gnu.property +... Index: llvm/test/tools/llvm-readobj/elf-pt-gnu-property.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-readobj/elf-pt-gnu-property.test @@ -0,0 +1,41 @@ +## Test that we can print PT_GNU_PROPERTY + +# RUN: yaml2obj %s > %t +# RUN: llvm-readelf --program-headers %t | FileCheck %s --check-prefix=ELF +# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=OBJ + +# ELF: GNU_PROPERTY 0x000078 0x0000000000000000 0x0000000000000000 0x000020 0x000020 0x8 + +# OBJ: ProgramHeader { +# OBJ-NEXT: Type: PT_GNU_PROPERTY (0x6474E553) +# OBJ-NEXT: Offset: 0x78 +# OBJ-NEXT: VirtualAddress: 0x0 +# OBJ-NEXT: PhysicalAddress: 0x0 +# OBJ-NEXT: FileSize: 32 +# OBJ-NEXT: MemSize: 32 +# OBJ-NEXT: Flags [ (0x0) +# OBJ-NEXT: ] +# OBJ-NEXT: Alignment: 8 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_AARCH64 +Sections: + - Name: .note.gnu.property + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000000000 + AddressAlign: 0x0000000000000008 + Notes: + - Name: GNU + Desc: 000000C0040000000300000000000000 + Type: 0x00000005 +ProgramHeaders: + - Type: PT_GNU_PROPERTY + Align: 8 + Sections: + - Section: .note.gnu.property +... Index: llvm/test/tools/yaml2obj/ELF/program-header.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/program-header.yaml +++ llvm/test/tools/yaml2obj/ELF/program-header.yaml @@ -40,6 +40,7 @@ - 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 @@ #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. Index: llvm/tools/llvm-objdump/ELFDump.cpp =================================================================== --- llvm/tools/llvm-objdump/ELFDump.cpp +++ llvm/tools/llvm-objdump/ELFDump.cpp @@ -204,6 +204,9 @@ case ELF::PT_GNU_RELRO: outs() << " RELRO "; break; + case ELF::PT_GNU_PROPERTY: + outs() << " GNU_PROPERTY "; + break; case ELF::PT_GNU_STACK: outs() << " STACK "; break; Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -1446,6 +1446,7 @@ 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 @@ 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) {