azan

prayers time calculator written in nasm
git clone git://git.afify.dev/azan
Log | Files | Refs | README | LICENSE

commit ce379ec74e0348325b3a3149fa6207f398ea8da7
parent 69bfc1aac0e4824d298828ca0b091eb2ec0127a6
Author: afify <hassan@afify.dev>
Date:   Sat, 28 Nov 2020 18:44:57 +0300

[feat] OpenBSD pledge

Diffstat:
MREADME.md | 1+
Mazan.s | 5+++++
Mmacros.s | 11+++++++++++
Msyscalls.s | 1+
4 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -5,6 +5,7 @@ azan - standalone nasm - unix portable syscalls - tested on Linux, OpenBSD, FreeBSD and NetBSD +- OpenBSD pledge. - binary size ≈ 7 kb - instructions ≈ 250-400 - branches ≈ 6-20 diff --git a/azan.s b/azan.s @@ -39,6 +39,8 @@ section .rodata usage_len: equ $ - usage_msg version_msg: db "azan-", VERSION, 10, 0 version_len: equ $ - version_msg + pledge_msg: db "pledge", 10, 0 + promises: db "stdio", 0 section .data res_msg: db "X XX:XX", 10, 0 @@ -84,6 +86,7 @@ check_argv: DIE version_msg, version_len get_timestamp: + OPENBSD_PLEDGE mov rax, SYS_gettimeofday ;sys_gettimeofday( mov rdi, tmp0 ;struct timeval *tv, mov rsi, rsi ;struct timezone* tz @@ -456,6 +459,8 @@ print_all_12: PRINT_HM EEXIT EXIT_SUCCESS +die_pledge: + DIE pledge_msg, 8 ; result_hour ;r8 ; result_min ;r9 ; duhr_ts: ;xmm0 diff --git a/macros.s b/macros.s @@ -25,6 +25,17 @@ section .note.openbsd.ident note %endif %endmacro +%macro OPENBSD_PLEDGE 0 +%ifdef OpenBSD + mov rax, SYS_pledge ;pledge( + mov rdi, promises ;const char *promises + xor rsi, rsi ;const char *execpromises + syscall + cmp rax, 0 + jl die_pledge +%endif +%endmacro + %macro EEXIT 1 mov rax, SYS_exit mov rdi, %1 diff --git a/syscalls.s b/syscalls.s @@ -11,6 +11,7 @@ %define SYS_exit 1 %define SYS_write 4 %define SYS_gettimeofday 67 + %define SYS_pledge 108 %elifdef FreeBSD %define SYS_exit 1 %define SYS_write 4