aboutsummaryrefslogtreecommitdiff
path: root/04_dynld_nostd/libgreet.c
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-04-25 23:38:36 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-04-25 23:38:36 +0200
commit05f740db6fe966d32256d4ed3b897f7b3e051fff (patch)
treeeedf0ef4e68a3a2ecfd06f714cc77bcbd0e8e2b1 /04_dynld_nostd/libgreet.c
parent6f7efd7075fcea29922536d8fb1ad810182437cd (diff)
downloaddynld-05f740db6fe966d32256d4ed3b897f7b3e051fff.tar.gz
dynld-05f740db6fe966d32256d4ed3b897f7b3e051fff.zip
added support for R_X86_64_64/R_X86_64_RELATIVE relocations + added init/fini
Diffstat (limited to '04_dynld_nostd/libgreet.c')
-rw-r--r--04_dynld_nostd/libgreet.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/04_dynld_nostd/libgreet.c b/04_dynld_nostd/libgreet.c
index 439e236..e697690 100644
--- a/04_dynld_nostd/libgreet.c
+++ b/04_dynld_nostd/libgreet.c
@@ -1,5 +1,7 @@
// Copyright (c) 2020 Johannes Stoelp
+#include <io.h>
+
int gCalled = 0;
const char* get_greet() {
@@ -11,3 +13,11 @@ const char* get_greet2() {
++gCalled;
return "Hello 2 from libgreet.so!";
}
+
+__attribute__((constructor)) static void libinit() { /* static -> generates R_X86_64_RELATIVE relocation */
+ pfmt("libgreet.so: libinit\n");
+}
+
+__attribute__((destructor)) void libfini() { /* non static -> generates R_X86_64_64 relocation */
+ pfmt("libgreet.so: libfini\n");
+}