This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Teach readobj to print PT_OPENBSD_RANDOMIZE/PT_OPENBSD_WXNEEDED headers.
ClosedPublic

Authored by grimar on Oct 14 2016, 6:53 AM.

Diff Detail

Event Timeline

grimar updated this revision to Diff 74678.Oct 14 2016, 6:53 AM
grimar retitled this revision from to [llvm-readobj] - Teach readobj to print PT_OPENBSD_RANDOMIZE/PT_OPENBSD_WXNEEDED headers..
grimar updated this object.
grimar added reviewers: rafael, davide, echristo.
grimar added subscribers: llvm-commits, grimar, evgeny777, ruiu.
emaste added a subscriber: emaste.Oct 14 2016, 11:03 AM

For reference I have now also added them to ELF Tool Chain's readelf in r3496.

tools/llvm-readobj/ELFDumper.cpp
1157–1160

The grouping seems a bit odd in this switch?

davide added inline comments.Oct 14 2016, 11:07 AM
test/tools/llvm-readobj/program-headers.test
9

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.

154

Remove the (0x4), here and in other parts of the patch.

tools/llvm-readobj/ELFDumper.cpp
1157–1160

Agree.

grimar updated this revision to Diff 74820.Oct 17 2016, 2:07 AM
  • Addressed review comments.
test/tools/llvm-readobj/program-headers.test
9

Done.

154

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.

tools/llvm-readobj/ELFDumper.cpp
1157–1160

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.
davide accepted this revision.Oct 17 2016, 7:46 PM
davide edited edge metadata.

LGTM modulo nit.

test/tools/llvm-readobj/program-headers.test
33

test.s is an empty file.
linker.script:

154

cool.

This revision is now accepted and ready to land.Oct 17 2016, 7:46 PM
This revision was automatically updated to reflect the committed changes.