Created
January 14, 2024 19:51
-
-
Save thejpster/1b9f6d92eaa295b03cedea4cc8128f9b to your computer and use it in GitHub Desktop.
Some C code I want to be relocatable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file is Public Domain, or CC0 where that is not allowed | |
static int GLOBAL_VALUE = 5; | |
__attribute__((noinline)) | |
int reloc_get(void) { | |
return GLOBAL_VALUE; | |
} | |
int reloc_add(int a) { | |
int x = reloc_get(); | |
return x + a; | |
} | |
void reloc_update(int foo) { | |
GLOBAL_VALUE = foo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment