Skip to content

Commit 449b3ec

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 0d15857 commit 449b3ec

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
@@ -2284,6 +2284,11 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
22842284
if (OutputSection *cmd = findSection(".openbsd.randomdata", partNo))
22852285
addHdr(PT_OPENBSD_RANDOMIZE, cmd->getPhdrFlags())->add(cmd);
22862286

2287+
// PT_OPENBSD_SYSCALLS is an OpenBSD-specific feature. That makes
2288+
// the kernel and dynamic linker register system call sites.
2289+
if (OutputSection *cmd = findSection(".openbsd.syscalls", partNo))
2290+
addHdr(PT_OPENBSD_SYSCALLS, cmd->getPhdrFlags())->add(cmd);
2291+
22872292
if (config->zGnustack != GnuStackKind::None) {
22882293
// PT_GNU_STACK is a special section to tell the loader to make the
22892294
// pages for the stack non-executable. If you really want an executable

0 commit comments

Comments
 (0)