This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] Add support for OpenBSD PT_OPENBSD_MUTABLE segment type
Needs ReviewPublic

Authored by brad on Nov 13 2022, 5:00 PM.

Details

Reviewers
MaskRay
Summary

Add support to the linker for 'PT_OPENBSD_MUTABLE' segment type.

https://github.com/openbsd/src/commit/bd249b5664da50f0178adea78250a7a0d8ea6566

Diff Detail

Event Timeline

brad created this revision.Nov 13 2022, 5:00 PM
brad requested review of this revision.Nov 13 2022, 5:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 13 2022, 5:00 PM

This needs a test. You may merge it with openbsd-randomize.s and possibly rename the test file.
The OpenBSD section/program header types are settled? I think the kernel has no usage yet.
Hope that David's comments in https://lobste.rs/s/wck0g4/openbsd_immutable_userland_mappings are useful ;-)

brad updated this revision to Diff 476658.Nov 18 2022, 9:41 PM
MaskRay added inline comments.Nov 19 2022, 9:09 AM
lld/test/ELF/linkerscript/openbsd-mutable.s
1

This can be shared with openbsd-randomdata

lld/test/ELF/openbsd-mutable.s
1

ditto. llvm-readelf -l is preferred for new tests.

It seems that OpenBSD is adding more and more OS specific program headers. The pace is kinda fast.
It's true that GNU is adding a lot program headers as well but many have gain support from many other OSes....
I think we can wait a bit before committing to add this permanent thing..

If one wants to play with PT_OPENBSD_MUTABLE, in a PHDRS command, a program header can have a numeric type (https://sourceware.org/binutils/docs/ld/PHDRS.html#:~:text=expression)...