From 114d335bf90df7f5dba4550ed918edb6a9090782 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Tue, 6 Dec 2016 17:55:52 +0000 Subject: [PATCH] [llvm-readobj] - Teach readobj to print PT_OPENBSD_BOOTDATA header These are OpenBSD specific program headers. OpenBSD commit: https://github.com/openbsd/src/commit/d39116912b9536bd77326260dc5c6e593fd4ee24 It is required for fixing PR31288. Differential revision: https://reviews.llvm.org/D27456 llvm-svn: 288831 --- .../test/Object/Inputs/openbsd-phdrs.elf-x86-64 | Bin 544 -> 600 bytes .../tools/llvm-readobj/program-headers.test | 16 +++++++++++++++- llvm/tools/llvm-readobj/ELFDumper.cpp | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/llvm/test/Object/Inputs/openbsd-phdrs.elf-x86-64 b/llvm/test/Object/Inputs/openbsd-phdrs.elf-x86-64 index 757d49055a7625034cc970bba49867027c4d3c8e..dab75bf96692c59c9bd2856c307e3a6c2fcd9280 100644 GIT binary patch delta 80 zcmZ3$a)V`phF}CE0~|OoSTL|mv{dI(fC?%wPRy!fc_zIib+RI(&cp{Z7%eAPGTJjK TFizgZXvb**RmM2Ekx?E1RNoJI delta 64 zcmcb?vVdiRhM)o?0~|OoSTHb8v{dJM0Tp_|FfprcvI64-M#jk-8SR-~Fiif$XvfGf I*^o&c0D+1PkN^Mx diff --git a/llvm/test/tools/llvm-readobj/program-headers.test b/llvm/test/tools/llvm-readobj/program-headers.test index 9bcd133bc442..e507442029be 100644 --- a/llvm/test/tools/llvm-readobj/program-headers.test +++ b/llvm/test/tools/llvm-readobj/program-headers.test @@ -13,7 +13,10 @@ RUN: | FileCheck %s -check-prefix ELF-MIPS64 ## ## test.s is an empty file. ## linker.script: -## PHDRS { text PT_LOAD FILEHDR PHDRS; foo 0x65a3dbe6; bar 0x65a3dbe7; } +## PHDRS { text PT_LOAD FILEHDR PHDRS; foo 0x65a3dbe6; bar 0x65a3dbe7; zed 0x65a41be6; } +## Where 0x65a3dbe6 is the value of PT_OPENBSD_RANDOMIZE, +## 0x65a3dbe7 is the value of PT_OPENBSD_WXNEEDED, +## 0x65a41be6 is the value of PT_OPENBSD_BOOTDATA ## SECTIONS { . = SIZEOF_HEADERS; .all : { *(.*) } : text } RUN: llvm-readobj -program-headers %p/../../Object/Inputs/openbsd-phdrs.elf-x86-64 \ RUN: | FileCheck %s -check-prefix OPENBSD-X86-64 @@ -175,3 +178,14 @@ OPENBSD-X86-64-NEXT: Flags [ OPENBSD-X86-64-NEXT: ] OPENBSD-X86-64-NEXT: Alignment: OPENBSD-X86-64-NEXT: } +OPENBSD-X86-64-NEXT: ProgramHeader { +OPENBSD-X86-64-NEXT: Type: PT_OPENBSD_BOOTDATA +OPENBSD-X86-64-NEXT: Offset: +OPENBSD-X86-64-NEXT: VirtualAddress: +OPENBSD-X86-64-NEXT: PhysicalAddress: +OPENBSD-X86-64-NEXT: FileSize: +OPENBSD-X86-64-NEXT: MemSize: +OPENBSD-X86-64-NEXT: Flags [ +OPENBSD-X86-64-NEXT: ] +OPENBSD-X86-64-NEXT: Alignment: +OPENBSD-X86-64-NEXT: } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 5d7f92212adb..dbeb03df9f45 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -1160,6 +1160,7 @@ static const char *getElfSegmentType(unsigned Arch, unsigned Type) { LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE); LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED); + LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_BOOTDATA); default: return ""; }