[PATCH] D25616: [llvm-readobj] - Teach readobj to print PT_OPENBSD_RANDOMIZE/PT_OPENBSD_WXNEEDED headers.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 02:07:42 PDT 2016


grimar added inline comments.


================
Comment at: test/tools/llvm-readobj/program-headers.test:9
 RUN:     | FileCheck %s -check-prefix ELF-MIPS64
+RUN: llvm-readobj -program-headers %p/../../Object/Inputs/openbsd-phdrs.elf-x86-64 \
+RUN:     | FileCheck %s -check-prefix OPENBSD-X86-64
----------------
davide wrote:
> You should add a comment explaining how you're generating this code, so that if we need to regenerate in the future we don't have to randomly guess.
Done.


================
Comment at: test/tools/llvm-readobj/program-headers.test:154
+OPENBSD-X86-64-NEXT:     MemSize: 8
+OPENBSD-X86-64-NEXT:     Flags [ (0x4)
+OPENBSD-X86-64-NEXT:       PF_R (0x4)
----------------
davide wrote:
> Remove the `(0x4)`, here and in other parts of the patch.
Ok, though it is not consistent with other places in this file. I also removed all values checking, as
intention of testcase is to check string name of PHDR and nothing else.


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1157-1160
+
+  LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE);
+  LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED);
+
----------------
davide wrote:
> emaste wrote:
> > The grouping seems a bit odd in this switch?
> Agree.
It is grouped (and sorted) at the same way as done in ELF.h:

```
  PT_NULL    = 0, // Unused segment.
  PT_LOAD    = 1, // Loadable segment.
  PT_DYNAMIC = 2, // Dynamic linking information.
  PT_INTERP  = 3, // Interpreter pathname.
  PT_NOTE    = 4, // Auxiliary information.
  PT_SHLIB   = 5, // Reserved.
  PT_PHDR    = 6, // The program header table itself.
  PT_TLS     = 7, // The thread-local storage template.
  PT_LOOS    = 0x60000000, // Lowest operating system-specific pt entry type.
  PT_HIOS    = 0x6fffffff, // Highest operating system-specific pt entry type.
  PT_LOPROC  = 0x70000000, // Lowest processor-specific program hdr entry type.
  PT_HIPROC  = 0x7fffffff, // Highest processor-specific program hdr entry type.

  // x86-64 program header types.
  // These all contain stack unwind tables.
  PT_GNU_EH_FRAME  = 0x6474e550,
  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_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data.
  PT_OPENBSD_WXNEEDED  = 0x65a3dbe7, // Program does W^X violations.
```


https://reviews.llvm.org/D25616





More information about the llvm-commits mailing list