diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-04-28 23:08:45 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-04-28 23:08:45 +0200 |
commit | d367355eb4c3569d422034b69737d8dc7022e13e (patch) | |
tree | f9f6768228235f4712466d65edeb0b745d904833 /04_dynld_nostd/libgreet.c | |
parent | cf97ecd5b52c2f7a8953fd1674742d46fd15418a (diff) | |
parent | fc137e7d0263a0fe908ca1a150e34a9c8b9902d4 (diff) | |
download | dynld-d367355eb4c3569d422034b69737d8dc7022e13e.tar.gz dynld-d367355eb4c3569d422034b69737d8dc7022e13e.zip |
Merge branch 'dev04'
Diffstat (limited to '04_dynld_nostd/libgreet.c')
-rw-r--r-- | 04_dynld_nostd/libgreet.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/04_dynld_nostd/libgreet.c b/04_dynld_nostd/libgreet.c new file mode 100644 index 0000000..f90bdbf --- /dev/null +++ b/04_dynld_nostd/libgreet.c @@ -0,0 +1,29 @@ +// Copyright (c) 2020 Johannes Stoelp + +#include <io.h> + +int gCalled = 0; + +const char* get_greet() { + // Reference global variable -> generates RELA relocation (R_X86_64_GLOB_DAT). + ++gCalled; + return "Hello from libgreet.so!"; +} + +const char* get_greet2() { + // Reference global variable -> generates RELA relocation (R_X86_64_GLOB_DAT). + ++gCalled; + return "Hello 2 from libgreet.so!"; +} + +// Definition of `static` function which is referenced from the `INIT` dynamic +// section entry -> generates R_X86_64_RELATIVE relocation. +__attribute__((constructor)) static void libinit() { + pfmt("libgreet.so: libinit\n"); +} + +// Definition of `non static` function which is referenced from the `FINI` +// dynamic section entry -> generates R_X86_64_64 relocation. +__attribute__((destructor)) void libfini() { + pfmt("libgreet.so: libfini\n"); +} |