diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-06-22 16:01:49 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-06-22 16:01:49 +0000 |
commit | fa18f6ca6b031524008b883b49f74acaa747c181 (patch) | |
tree | 501162ac6c02f29a9d3b25c2a06945726961b4d0 /sys/conf | |
parent | 2877e53dabcef0c0e1b0d6bd80f594148bd8692c (diff) |
Generate a gap.link script, and use that to generate gap.o. On multi-ABI
architectures we must also link against a gapdummy.o to repair the ABI
of the resulting .o file. Woe is me.
Also repair install: target to update the linkkit & hash when a kernel
is installed.
ok rpe tb mlarkin and tested by others also
Diffstat (limited to 'sys/conf')
-rw-r--r-- | sys/conf/makegap.sh | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/sys/conf/makegap.sh b/sys/conf/makegap.sh index da50aa602f8..d57cbc07002 100644 --- a/sys/conf/makegap.sh +++ b/sys/conf/makegap.sh @@ -1,32 +1,62 @@ #!/bin/sh - -PADBYTE=$1 - -cat << __EOF__ -#include <machine/param.h> -#include <machine/asm.h> - - .text - .balign PAGE_SIZE, $PADBYTE - .space $RANDOM, $PADBYTE - .balign PAGE_SIZE, $PADBYTE - - .globl endboot -endboot: - .space PAGE_SIZE, $PADBYTE - .space $RANDOM % PAGE_SIZE, $PADBYTE - .balign 16, $PADBYTE - - /* - * Randomly bias future data, bss, and rodata objects, - * does not help for objects in locore0.S though - */ - .data - .space $RANDOM % PAGE_SIZE, $PADBYTE - - .section .bss - .space $RANDOM % PAGE_SIZE - - .section .rodata - .space $RANDOM % PAGE_SIZE, $PADBYTE +umask 007 + +PAGE_SIZE=`sysctl -n hw.pagesize` +PAD=$1 +GAPDUMMY=$2 + +RANDOM1=$((RANDOM % (3 * PAGE_SIZE))) +RANDOM2=$((RANDOM % PAGE_SIZE)) +RANDOM3=$((RANDOM % PAGE_SIZE)) +RANDOM4=$((RANDOM % PAGE_SIZE)) +RANDOM5=$((RANDOM % PAGE_SIZE)) + +cat > gap.link << __EOF__ + +PHDRS { + text PT_LOAD FILEHDR PHDRS; + rodata PT_LOAD; + data PT_LOAD; + bss PT_LOAD; +} + +SECTIONS { + .text : ALIGN($PAGE_SIZE) { + LONG($PAD); + . += $RANDOM1; + . = ALIGN($PAGE_SIZE); + endboot = .; + PROVIDE (endboot = .); + . = ALIGN($PAGE_SIZE); + . += $RANDOM2; + . = ALIGN(16); + *(.text .text.*) + } :text =$PAD + + .rodata : { + LONG($PAD); + . += $RANDOM3; + . = ALIGN(16); + *(.rodata .rodata.*) + } :rodata =$PAD + + .data : { + LONG($PAD); + . = . + $RANDOM4; /* fragment of page */ + . = ALIGN(16); + *(.data .data.*) + } :data =$PAD + + .bss : { + . = . + $RANDOM5; /* fragment of page */ + . = ALIGN(16); + *(.bss .bss.*) + } :bss + + note.ABI-tag 0 : { *(.note.ABI-tag) } + .MIPS.options : { *(.MIPS.options) } +} __EOF__ + +ld -r gap.link $GAPDUMMY -o gap.o |