aboutsummaryrefslogtreecommitdiff
path: root/03_hello_dynld
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-03-21 17:42:26 +0100
committerjohannst <johannes.stoelp@gmail.com>2021-03-21 17:42:26 +0100
commitcf97ecd5b52c2f7a8953fd1674742d46fd15418a (patch)
tree7a91c0c5a9e3aa7e918c5907c300827562adef15 /03_hello_dynld
parentb8e086f1857f0d7731c64647f81cdf6ee3b463b2 (diff)
downloaddynld-cf97ecd5b52c2f7a8953fd1674742d46fd15418a.tar.gz
dynld-cf97ecd5b52c2f7a8953fd1674742d46fd15418a.zip
use ERROR_ON macro
Diffstat (limited to '03_hello_dynld')
-rw-r--r--03_hello_dynld/dynld.c12
1 files 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 <syscall.h>
#include <auxv.h>
+#include <common.h>
#include <io.h>
#include <stdint.h>
@@ -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];