From cf97ecd5b52c2f7a8953fd1674742d46fd15418a Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 21 Mar 2021 17:42:26 +0100 Subject: use ERROR_ON macro --- 03_hello_dynld/dynld.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/03_hello_dynld/dynld.c b/03_hello_dynld/dynld.c index 1805b33..8a3c003 100644 --- a/03_hello_dynld/dynld.c +++ b/03_hello_dynld/dynld.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -63,15 +64,10 @@ void dl_entry(const uint64_t* prctx) { // program. When this happens the `AT_PHDR` entry tells the // interpreter where to find the program header table in the // memory image. - if (auxv[AT_PHDR] == 0 || auxv[AT_EXECFD] != 0) { - pfmt("[dynld]: ERROR, expected Linux Kernel to map user executable!\n"); - syscall1(__NR_exit, 1); - } + ERROR_ON(auxv[AT_PHDR] == 0 || auxv[AT_EXECFD] != 0, "[dynld]: ERROR, expected Linux Kernel to map user executable!\n"); - if (auxv[AT_ENTRY] == 0) { - pfmt("[dynld]: ERROR, AT_ENTRY not found in auxiliary vector!\n"); - syscall1(__NR_exit, 1); - } + // Entrypoint must be defined. + ERROR_ON(auxv[AT_ENTRY] == 0, "[dynld]: ERROR, AT_ENTRY not found in auxiliary vector!\n"); // Transfer control to user executable. void (*user_entry)() = (void (*)())auxv[AT_ENTRY]; -- cgit v1.2.3