Skip to content

Commit aa25b6b

Browse files
kettenisEricson2314
authored andcommitted
[LLD] Add support for .openbsd.syscalls
(rebaser's note) adapted from: openbsd/src@42a61ac Collect .openbsd.syscalls sections into a new PT_OPENBSD_SYSCALLS segment. This will be used soon to pin system calls to designated call sites. ok deraadt@
1 parent ba8542c commit aa25b6b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,7 @@ unsigned ScriptParser::readPhdrType() {
16301630
.Case("PT_GNU_RELRO", PT_GNU_RELRO)
16311631
.Case("PT_OPENBSD_MUTABLE", PT_OPENBSD_MUTABLE)
16321632
.Case("PT_OPENBSD_RANDOMIZE", PT_OPENBSD_RANDOMIZE)
1633+
.Case("PT_OPENBSD_SYSCALLS", PT_OPENBSD_SYSCALLS)
16331634
.Case("PT_OPENBSD_WXNEEDED", PT_OPENBSD_WXNEEDED)
16341635
.Case("PT_OPENBSD_BOOTDATA", PT_OPENBSD_BOOTDATA)
16351636
.Default(-1);

lld/ELF/Writer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,11 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
22922292
if (OutputSection *cmd = findSection(".openbsd.randomdata", partNo))
22932293
addHdr(PT_OPENBSD_RANDOMIZE, cmd->getPhdrFlags())->add(cmd);
22942294

2295+
// PT_OPENBSD_SYSCALLS is an OpenBSD-specific feature. That makes
2296+
// the kernel and dynamic linker register system call sites.
2297+
if (OutputSection *cmd = findSection(".openbsd.syscalls", partNo))
2298+
addHdr(PT_OPENBSD_SYSCALLS, cmd->getPhdrFlags())->add(cmd);
2299+
22952300
if (config->zGnustack != GnuStackKind::None) {
22962301
// PT_GNU_STACK is a special section to tell the loader to make the
22972302
// pages for the stack non-executable. If you really want an executable

0 commit comments

Comments
 (0)