From 05f740db6fe966d32256d4ed3b897f7b3e051fff Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 25 Apr 2021 23:38:36 +0200 Subject: added support for R_X86_64_64/R_X86_64_RELATIVE relocations + added init/fini --- 04_dynld_nostd/libgreet.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to '04_dynld_nostd/libgreet.c') 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 + 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"); +} -- cgit v1.2.3