aboutsummaryrefslogtreecommitdiff
path: root/04_dynld_nostd/main.c
diff options
context:
space:
mode:
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);
+}