diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2022-11-14 13:21:51 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2022-11-14 13:21:51 +0000 |
commit | 7d35ebf664211e9f802b841eb13ea10c34f2469b (patch) | |
tree | b7c9e03e4e767fae331e9c701af9dec448a9211a /libexec | |
parent | e09feb26674eff4384f81d0caa3116242bd8eba5 (diff) |
Since the introduction of automatic immutable from the kernel, the munmap()
of ld.so boot.text region is now (silently) failing because the region is
contained within the text LOAD, which is immutable. So create a new btext
LOAD with flags PF_X|PF_R|PF_OPENBSD_MUTABLE, and place all boot.text objects
in there. This LOAD must also be page-aligned so it doesn't skip unmapping
some of the object region, previously it was hilariously unaligned.
ok kettenis and guenther seemed to like it also
This one is for powerpc64 and a modified version of the diff deraadt@ mailed
out to make sure the LOADs are in increasing address order.
this is the alpha version
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/alpha/Makefile.inc | 3 | ||||
-rw-r--r-- | libexec/ld.so/alpha/ld.script | 72 |
2 files changed, 74 insertions, 1 deletions
diff --git a/libexec/ld.so/alpha/Makefile.inc b/libexec/ld.so/alpha/Makefile.inc index a323b1af1f7..f6ea985d30d 100644 --- a/libexec/ld.so/alpha/Makefile.inc +++ b/libexec/ld.so/alpha/Makefile.inc @@ -1,7 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.4 2019/10/20 03:44:49 guenther Exp $ +# $OpenBSD: Makefile.inc,v 1.5 2022/11/14 13:21:50 deraadt Exp $ CFLAGS += -fPIC -mno-fp-regs -mbuild-constants LIBCSRCDIR=${.CURDIR}/../../lib/libc .include "${LIBCSRCDIR}/arch/alpha/Makefile.inc" +LD_SCRIPT = ${.CURDIR}/${MACHINE_CPU}/ld.script RELATIVE_RELOC=R_ALPHA_RELATIVE diff --git a/libexec/ld.so/alpha/ld.script b/libexec/ld.so/alpha/ld.script index e69de29bb2d..5e24bacb3cf 100644 --- a/libexec/ld.so/alpha/ld.script +++ b/libexec/ld.so/alpha/ld.script @@ -0,0 +1,72 @@ +PHDRS +{ + rodata PT_LOAD FILEHDR PHDRS FLAGS (4); + text PT_LOAD; + btext PT_LOAD FLAGS (0x08000005); + data PT_LOAD; + random PT_OPENBSD_RANDOMIZE; + relro PT_GNU_RELRO; + dynamic PT_DYNAMIC; + note PT_NOTE; +} + +SECTIONS +{ + /* RODATA */ + . = 0 + SIZEOF_HEADERS; + .dynsym : { *(.dynsym) } :rodata + .gnu.hash : { *(.gnu.hash) } :rodata + .dynstr : { *(.dynstr) } :rodata + .rodata : { *(.rodata .rodata.*) } :rodata + .eh_frame : { *(.eh_frame) } :rodata + + /* TEXT */ + . = ALIGN(0x10000); + .text : { *(.text .text.*) } :text + . = ALIGN(0x2000); + .boot.text : + { + . = ALIGN(0x2000); + boot_text_start = .; + . = ALIGN(0x2000); + *(.boot.text) + boot_text_end = .; + } :btext + + /* RELRO DATA */ + . = DATA_SEGMENT_ALIGN (0x10000, 0x2000); + .openbsd.randomdata : + { + *(.openbsd.randomdata .openbsd.randomdata.*) + } :data :relro :random + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro + .dynamic : { *(.dynamic) } :data :relro :dynamic + .got : { *(.got.plt) *(.got) } :data :relro + . = DATA_SEGMENT_RELRO_END (0, .); + + /* BOOTDATA */ + . = ALIGN(0x2000); + boot_data_start = .; + .rela.dyn : + { + *(.rela.text .rela.text.*) + *(.rela.rodata .rela.rodata.*) + *(.rela.data .rela.data.*) + *(.rela.got) + *(.rela.bss .rela.bss.*) + } :data +/* XXX .rela.plt is unused but cannot delete: ld.bfd zeros DT_RELASZ then! */ + .rela.plt : { *(.rela.plt) } :data + .hash : { *(.hash) } :data + .note : { *(.note.openbsd.*) } :data :note + .boot.data : { *(.boot.data .boot.data.*) } :data + boot_data_end = .; + + /* DATA */ + . = ALIGN(0x2000); + .data : { *(.data .data.*) } :data + .bss : { *(.dynbss) *(.bss .bss.*) *(COMMON) } :data + . = DATA_SEGMENT_END (.); + + /DISCARD/ : { *(.note.GNU-stack) } +} |