From 6572425462375a3289b3870f5ed5359f7557a9bd Mon Sep 17 00:00:00 2001 From: Alexander Ivchenko Date: Tue, 29 May 2018 14:49:51 +0000 Subject: [llvm-readobj] Support GNU_PROPERTY_X86_FEATURE_1_AND notes in .note.gnu.property This patch allows parsing GNU_PROPERTY_X86_FEATURE_1_AND notes in .note.gnu.property sections. These notes indicate that the object file is built to support Intel CET. patch by mike.dvoretsky Differential Revision: https://reviews.llvm.org/D47473 llvm-svn: 333424 --- llvm/tools/llvm-readobj/ELFDumper.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'llvm/tools/llvm-readobj') diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 6ca28e273cc..4acd9be547b 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -3457,7 +3457,7 @@ static void printGNUProperty(raw_ostream &OS, uint32_t Type, uint32_t DataSize, case GNU_PROPERTY_STACK_SIZE: { OS << " stack size: "; if (DataSize == sizeof(typename ELFT::uint)) - OS << format("0x%x\n", + OS << format("0x%lx\n", (uint64_t)(*(const typename ELFT::Addr *)Data.data())); else OS << format("\n", DataSize); @@ -3469,6 +3469,36 @@ static void printGNUProperty(raw_ostream &OS, uint32_t Type, uint32_t DataSize, OS << format(" ", DataSize); OS << "\n"; break; + case GNU_PROPERTY_X86_FEATURE_1_AND: + OS << " X86 features: "; + if (DataSize != 4 && DataSize != 8) { + OS << format("\n", DataSize); + break; + } + uint64_t CFProtection = + (DataSize == 4) + ? support::endian::read32(Data.data()) + : support::endian::read64(Data.data()); + if (CFProtection == 0) { + OS << "none\n"; + break; + } + if (CFProtection & GNU_PROPERTY_X86_FEATURE_1_IBT) { + OS << "IBT"; + CFProtection &= ~GNU_PROPERTY_X86_FEATURE_1_IBT; + if (CFProtection) + OS << ", "; + } + if (CFProtection & GNU_PROPERTY_X86_FEATURE_1_SHSTK) { + OS << "SHSTK"; + CFProtection &= ~GNU_PROPERTY_X86_FEATURE_1_SHSTK; + if (CFProtection) + OS << ", "; + } + if (CFProtection) + OS << format("", CFProtection); + OS << "\n"; + break; } } -- cgit v1.2.3