diff options
Diffstat (limited to '04_dynld_nostd/libgreet.c')
-rw-r--r-- | 04_dynld_nostd/libgreet.c | 10 |
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"); +} |