aboutsummaryrefslogtreecommitdiff
path: root/04_dynld_nostd/main.c
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-04-28 23:08:45 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-04-28 23:08:45 +0200
commitd367355eb4c3569d422034b69737d8dc7022e13e (patch)
treef9f6768228235f4712466d65edeb0b745d904833 /04_dynld_nostd/main.c
parentcf97ecd5b52c2f7a8953fd1674742d46fd15418a (diff)
parentfc137e7d0263a0fe908ca1a150e34a9c8b9902d4 (diff)
downloaddynld-d367355eb4c3569d422034b69737d8dc7022e13e.tar.gz
dynld-d367355eb4c3569d422034b69737d8dc7022e13e.zip
Merge branch 'dev04'
Diffstat (limited to '04_dynld_nostd/main.c')
-rw-r--r--04_dynld_nostd/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/04_dynld_nostd/main.c b/04_dynld_nostd/main.c
new file mode 100644
index 0000000..6efa5fc
--- /dev/null
+++ b/04_dynld_nostd/main.c
@@ -0,0 +1,19 @@
+// Copyright (c) 2020 Johannes Stoelp
+
+#include <io.h>
+
+// API of `libgreet.so`.
+extern const char* get_greet();
+extern const char* get_greet2();
+extern int gCalled;
+
+void _start() {
+ pfmt("Running _start() @ %s\n", __FILE__);
+
+ // Call function from libgreet.so -> generates PLT relocations (R_X86_64_JUMP_SLOT).
+ pfmt("get_greet() -> %s\n", get_greet());
+ pfmt("get_greet2() -> %s\n", get_greet2());
+
+ // Reference global variable from libgreet.so -> generates RELA relocation (R_X86_64_COPY).
+ pfmt("libgreet.so called %d times\n", gCalled);
+}