This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Added support of PT_OPENBSD_RANDOMIZE
ClosedPublic

Authored by grimar on Oct 11 2016, 5:43 AM.

Details

Summary

This is 30646.

PT_OPENBSD_RANDOMIZE
The array element specifies the location and size of a part of the memory image of the program that must be filled with random data before any code in the object is executed. The memory region specified by a segment of this type may overlap the region specified by a PT_GNU_RELRO segment, in which case the intersection will be filled with random data before being marked read-only.

Reference links:
http://man.openbsd.org/OpenBSD-current/man5/elf.5
https://github.com/openbsd/src/commit/c494713c450d98da3f2e1451ee8c7fb675a7c461

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 74236.Oct 11 2016, 5:43 AM
grimar retitled this revision from to [ELF] - Added support of PT_OPENBSD_RANDOMIZE.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
ruiu edited edge metadata.Oct 11 2016, 11:07 AM

I wonder if you tried the new tests with ld.bfd with the openbsd-local patch to see that the tests are valid.

In D25469#567487, @ruiu wrote:

I wonder if you tried the new tests with ld.bfd with the openbsd-local patch to see that the tests are valid.

Just tries to do that. Used binutils-2.17.50 and applied changes from next 2 patches:
https://github.com/openbsd/src/commit/c494713c450d98da3f2e1451ee8c7fb675a7c461
https://github.com/openbsd/src/commit/ce234db7935b2890e0880e442d2a68b8f25b2c93

Link result I observed was similar to result shown in my testcases.

ruiu accepted this revision.Oct 13 2016, 3:32 PM
ruiu edited edge metadata.

LGTM

test/ELF/linkerscript/openbsd-randomize.s
9 ↗(On Diff #74236)

You want to improve llvm-readobj to print out the name of this hex value.

test/ELF/openbsd_randomize.s
1 ↗(On Diff #74236)

Rename openbsd_randomize.s -> openbsd-randomize.s.

This revision is now accepted and ready to land.Oct 13 2016, 3:32 PM
This revision was automatically updated to reflect the committed changes.
grimar added inline comments.Oct 14 2016, 6:12 AM
test/ELF/linkerscript/openbsd-randomize.s
9 ↗(On Diff #74236)

Yep, I'll do that soon.