sync with OpenBSD -current

This commit is contained in:
purplerain 2023-12-10 13:25:40 +00:00
parent 4c73aa256c
commit 086d8cf2c2
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
118 changed files with 975 additions and 393 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.5 2020/02/18 12:19:11 kettenis Exp $ */
/* $OpenBSD: SYS.h,v 1.6 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2016 Dale Rahn
@ -29,18 +29,25 @@
#include <machine/asm.h>
#include <sys/syscall.h>
#define SYSTRAP(x) \
ldr x8, =SYS_ ## x ;\
svc 0 ;\
dsb nsh ;\
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define SYSTRAP(x) \
ldr x8, =SYS_ ## x ;\
99: svc 0 ;\
PINSYSCALL(SYS_ ## x, 99b) ;\
dsb nsh ;\
isb
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\
SYSTRAP(n) ;\
cneg x0, x0, cs /* r0 = -errno */ ;\
RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\
SYSTRAP(n) ;\
cneg x0, x0, cs /* r0 = -errno */ ;\
RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\
ret

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000001);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -39,11 +40,20 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.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, .);
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
/* BOOTDATA */
. = ALIGN(0x1000);
boot_data_start = .;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.3 2023/12/06 06:15:33 miod Exp $ */
/* $OpenBSD: SYS.h,v 1.4 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2001 Niklas Hallqvist
@ -61,10 +61,17 @@
* further register saving.
*/
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define DL_SYSCALL(c) \
LEAF_NOPROFILE(_dl_##c, irrelevant); \
ldiq v0, SYS_##c; \
call_pal PAL_OSF1_callsys; \
99: call_pal PAL_OSF1_callsys; \
PINSYSCALL(SYS_##c, 99b); \
beq a3, 1f; \
subq zero, v0, v0; /* return -errno */ \
1: \

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -39,6 +40,10 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.3 2023/04/25 04:11:10 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.4 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2002,2004 Dale Rahn
@ -30,19 +30,26 @@
#include <sys/syscall.h>
#include <machine/asm.h>
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n), @function ;\
.align 16,0xcc ;\
__CONCAT(_dl_,n): ;\
endbr64 ;\
RETGUARD_SETUP(_dl_##n, r11) ;\
RETGUARD_PUSH(r11) ;\
movl $(__CONCAT(SYS_,n)), %eax ;\
movq %rcx, %r10 ;\
syscall ;\
jnc 1f ;\
neg %rax ;\
1: RETGUARD_POP(r11) ;\
RETGUARD_CHECK(_dl_##n, r11) ;\
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n), @function ;\
.align 16,0xcc ;\
__CONCAT(_dl_,n): ;\
endbr64 ;\
RETGUARD_SETUP(_dl_##n, r11) ;\
RETGUARD_PUSH(r11) ;\
movl $(__CONCAT(SYS_,n)), %eax ;\
movq %rcx, %r10 ;\
99: syscall ;\
PINSYSCALL(__CONCAT(SYS_,n), 99b) ;\
jnc 1f ;\
neg %rax ;\
1: RETGUARD_POP(r11) ;\
RETGUARD_CHECK(_dl_##n, r11) ;\
ret

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -43,6 +44,11 @@ SECTIONS
.got : { *(.got.plt) *(.got) } :data :relro
. = DATA_SEGMENT_RELRO_END (0, .);
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
/* BOOTDATA */
. = ALIGN(0x1000);
boot_data_start = .;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.3 2020/03/13 09:31:26 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.4 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@ -29,18 +29,25 @@
#include <machine/asm.h>
#include <sys/syscall.h>
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define SYSTRAP(x) \
ldr r12, =SYS_ ## x; \
swi 0; \
dsb nsh; \
ldr r12, =SYS_ ## x ;\
99: swi 0 ;\
PINSYSCALL(SYS_ ## x, 99b) ;\
dsb nsh ;\
isb
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
SYSTRAP(n) ;\
bcs .L_cerr ;\
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
SYSTRAP(n) ;\
bcs .L_cerr ;\
mov pc, lr
.L_cerr:

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -40,6 +41,11 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2004 Michael Shalayeff
@ -33,17 +33,24 @@
#include <machine/vmparam.h>
#undef _LOCORE
#define DL_SYSCALL(x) \
ENTRY(__CONCAT(_dl_,x),0) !\
stw rp, HPPA_FRAME_ERP(sr0,sp) !\
ldil L%SYSCALLGATE, r1 !\
ble 4(sr7, r1) !\
ldi __CONCAT(SYS_,x), t1 !\
comb,<> r0, t1, _dl_sysexit !\
ldw HPPA_FRAME_ERP(sr0,sp), rp !\
bv r0(rp) !\
nop !\
_dl_sysexit !\
bv r0(rp) !\
sub r0, ret0, ret0 !\
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits !\
.long label !\
.long sysno !\
.popsection
#define DL_SYSCALL(x) \
ENTRY(__CONCAT(_dl_,x),0) !\
stw rp, HPPA_FRAME_ERP(sr0,sp) !\
ldil L%SYSCALLGATE, r1 !\
99: ble 4(sr7, r1) !\
PINSYSCALL(__CONCAT(SYS_,x), 99b) !\
ldi __CONCAT(SYS_,x), t1 !\
comb,<> r0, t1, _dl_sysexit !\
ldw HPPA_FRAME_ERP(sr0,sp), rp !\
bv r0(rp) !\
nop !\
_dl_sysexit !\
bv r0(rp) !\
sub r0, ret0, ret0 !\
EXIT(__CONCAT(_dl_,x))

View file

@ -6,6 +6,7 @@ PHDRS
pltgot PT_LOAD;
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -45,6 +46,10 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
. = DATA_SEGMENT_RELRO_END (0, .);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@ -30,6 +30,12 @@
#include <sys/syscall.h>
#include <machine/asm.h>
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define DL_SYSCALL(n) \
.section ".text" ;\
.align 16,0xcc ;\
@ -37,7 +43,8 @@
.type __CONCAT(_dl_,n),@function ;\
__CONCAT(_dl_,n): ;\
movl $__CONCAT(SYS_, n),%eax; ;\
int $0x80 ;\
99: int $0x80 ;\
PINSYSCALL(__CONCAT(SYS_, n), 99b) ;\
jb .L_cerr ;\
ret

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -38,6 +39,11 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.4 2019/10/23 19:55:09 guenther Exp $ */
/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2013 Miodrag Vallat.
@ -44,22 +44,29 @@
#include <machine/asm.h>
#include <sys/syscall.h>
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define __CONCAT(p,x) p##x
#define __ENTRY(p,x) ENTRY(__CONCAT(p,x))
#define __SYSCALLNAME(p,x) __CONCAT(p,x)
#define __DO_SYSCALL(x) \
or %r13, %r0, __SYSCALLNAME(SYS_,x); \
tb0 0, %r0, 450
#define __DO_SYSCALL(x) \
or %r13, %r0, __SYSCALLNAME(SYS_,x) ;\
99: tb0 0, %r0, 450 ;\
PINSYSCALL(__SYSCALLNAME(SYS_,x), 99b)
/*
* m88k syscall return ABI requires the same amount of ASM
* whether or not the syscall can possibly fail, so there's
* no benefit to a DL_SYSCALL_NOERR() macro.
*/
#define DL_SYSCALL(n) \
__ENTRY(_dl_,n); \
__DO_SYSCALL(n); \
subu %r2, %r0, %r2; /* return -errno; */ \
jmp %r1; \
#define DL_SYSCALL(n) \
__ENTRY(_dl_,n) ;\
__DO_SYSCALL(n) ;\
subu %r2, %r0, %r2 /* return -errno; */ ;\
jmp %r1 ;\
END(_dl_##n)

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
scalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -36,6 +37,9 @@ SECTIONS
. = DATA_SEGMENT_ALIGN (0x10000, 0x1000);
.openbsd.randomdata : { *(.openbsd.randomdata .openbsd.randomdata.*) }
:data :relro :random
.openbsd.syscalls : { *(.openbsd.syscalls .openbsd.syscalls.*) }
:syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.1 2017/08/27 21:59:52 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@ -29,14 +29,21 @@
#include <sys/syscall.h>
#include <machine/asm.h>
#define DL_SYSCALL(c) \
NLEAF(_dl_##c,0) \
li v0,SYS_##c; \
syscall; \
bnez a3, 1f; \
j ra; \
1: ; \
subu v0, zero, v0; \
j ra ; \
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define DL_SYSCALL(c) \
NLEAF(_dl_##c,0) \
li v0,SYS_##c; \
99: syscall; \
PINSYSCALL(SYS_##c, 99b); \
bnez a3, 1f; \
j ra; \
1: ; \
subu v0, zero, v0; \
j ra; \
END(_dl_##c)

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -39,6 +40,11 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
_gp = ALIGN(16) + 0x7ff0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.4 2020/11/28 19:49:30 gkoehler Exp $ */
/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@ -29,14 +29,21 @@
#include <sys/syscall.h>
#include <machine/asm.h>
#define DL_SYSCALL(n) \
ENTRY(_dl_##n) \
RETGUARD_SETUP(_dl_##n, %r11, %r12) ;\
li 0, SYS_##n ;\
sc ;\
cmpwi 0, 0 ;\
beq+ .L_end##n ;\
neg 3, 3 ;\
.L_end##n: ;\
RETGUARD_CHECK(_dl_##n, %r11, %r12) ;\
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define DL_SYSCALL(n) \
ENTRY(_dl_##n) \
RETGUARD_SETUP(_dl_##n, %r11, %r12) ;\
li 0, SYS_##n ;\
99: sc ;\
PINSYSCALL(SYS_##n, 99b) ;\
cmpwi 0, 0 ;\
beq+ .L_end##n ;\
neg 3, 3 ;\
.L_end##n: ;\
RETGUARD_CHECK(_dl_##n, %r11, %r12) ;\
blr

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -39,6 +40,11 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.2 2020/10/16 23:42:53 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.3 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@ -29,14 +29,21 @@
#include <sys/syscall.h>
#include <machine/asm.h>
#define DL_SYSCALL(n) \
ENTRY(_dl_##n) \
RETGUARD_SETUP(_dl_##n, %r11) ;\
li %r0, SYS_##n ;\
sc ;\
cmpdi %r0, 0 ;\
beq .L_end##n ;\
neg %r3, %r3 ;\
.L_end##n: ;\
RETGUARD_CHECK(_dl_##n, %r11) ;\
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define DL_SYSCALL(n) \
ENTRY(_dl_##n) \
RETGUARD_SETUP(_dl_##n, %r11) ;\
li %r0, SYS_##n ;\
99: sc ;\
PINSYSCALL(SYS_##n, 99b) ;\
cmpdi %r0, 0 ;\
beq .L_end##n ;\
neg %r3, %r3 ;\
.L_end##n: ;\
RETGUARD_CHECK(_dl_##n, %r11) ;\
blr

View file

@ -5,6 +5,7 @@ PHDRS
text PT_LOAD FLAGS (1);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -38,6 +39,11 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.1 2021/04/28 15:16:26 drahn Exp $ */
/* $OpenBSD: SYS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@openbsd.org>
@ -29,19 +29,26 @@
#include <machine/asm.h>
#include <sys/syscall.h>
#define SYSTRAP(x) \
li t0, SYS_ ## x ;\
ecall ;\
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define SYSTRAP(x) \
li t0, SYS_ ## x ;\
99: ecall ;\
PINSYSCALL(SYS_ ## x, 99b)
/* XXX fence */
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\
SYSTRAP(n) ;\
beqz t0, 1f ;\
sub a0, zero, a0 /* r0 = -errno */ ;\
1: ;\
RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
RETGUARD_SETUP(__CONCAT(_dl_,n), x15) ;\
SYSTRAP(n) ;\
beqz t0, 1f ;\
sub a0, zero, a0 /* r0 = -errno */ ;\
1: ;\
RETGUARD_CHECK(__CONCAT(_dl_,n), x15) ;\
ret

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -39,6 +40,11 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.2 2022/09/02 06:19:05 miod Exp $ */
/* $OpenBSD: SYS.h,v 1.3 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2006 Dale Rahn
@ -29,6 +29,12 @@
#include <machine/asm.h>
#include <sys/syscall.h>
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#ifdef __ASSEMBLER__
/*
* If the system call number fits in a 8-bit signed value (i.e. fits in 7 bits),
@ -38,10 +44,12 @@
.macro systrap num
.iflt \num - 128
mov # \num, r0
trapa #0x80
99: trapa #0x80
PINSYSCALL(\num, 99b)
.else
mov.l 903f, r0
trapa #0x80
99: trapa #0x80
PINSYSCALL(\num, 99b)
bra 904f
nop
.align 2
@ -51,17 +59,17 @@
.endm
#endif
#define SYSTRAP(x) \
systrap SYS_ ## x
#define SYSTRAP(x) \
systrap SYS_ ## x
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
SYSTRAP(n) ;\
bf .L_cerr ;\
nop ;\
rts ;\
#define DL_SYSCALL(n) \
.global __CONCAT(_dl_,n) ;\
.type __CONCAT(_dl_,n)%function ;\
__CONCAT(_dl_,n): ;\
SYSTRAP(n) ;\
bf .L_cerr ;\
nop ;\
rts ;\
nop
.L_cerr:

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -35,6 +36,7 @@ SECTIONS
. = DATA_SEGMENT_ALIGN (0x10000, 0x1000);
.openbsd.randomdata : { *(.openbsd.randomdata .openbsd.randomdata.*) }
:data :relro :random
.openbsd.syscalls : { *(.openbsd.syscalls .openbsd.syscalls.*) } :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro

View file

@ -1,4 +1,4 @@
/* $OpenBSD: SYS.h,v 1.4 2021/12/14 07:20:16 deraadt Exp $ */
/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:50 deraadt Exp $ */
/* $NetBSD: rtld_start.S,v 1.5 2001/08/14 22:17:48 eeh Exp $ */
/*
@ -68,14 +68,21 @@
#include <machine/trap.h>
#include <machine/asm.h>
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits ;\
.long label ;\
.long sysno ;\
.popsection
#define __CONCAT(x,y) x##y
#define DL_SYSCALL(n) \
_ENTRY(__CONCAT(_dl_,n)) \
mov __CONCAT(SYS_,n) | SYSCALL_G2RFLAG, %g1 ;\
add %o7, 8, %g2 ;\
t ST_SYSCALL ;\
retl ;\
#define DL_SYSCALL(n) \
_ENTRY(__CONCAT(_dl_,n)) \
mov __CONCAT(SYS_,n) | SYSCALL_G2RFLAG, %g1 ;\
add %o7, 8, %g2 ;\
99: t ST_SYSCALL ;\
PINSYSCALL(__CONCAT(SYS_,n), 99b) ;\
retl ;\
sub %g0, %o0, %o0

View file

@ -5,6 +5,7 @@ PHDRS
btext PT_LOAD FLAGS (0x08000005);
data PT_LOAD;
random PT_OPENBSD_RANDOMIZE;
syscalls PT_OPENBSD_SYSCALLS;
relro PT_GNU_RELRO;
dynamic PT_DYNAMIC;
note PT_NOTE;
@ -39,6 +40,10 @@ SECTIONS
{
*(.openbsd.randomdata .openbsd.randomdata.*)
} :data :relro :random
.openbsd.syscalls :
{
*(.openbsd.syscalls .openbsd.syscalls.*)
} :syscalls
.data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got.plt) *(.got) } :data :relro