Skip to content

Instantly share code, notes, and snippets.

@thejpster
Created January 14, 2024 19:51
Show Gist options
  • Save thejpster/1b9f6d92eaa295b03cedea4cc8128f9b to your computer and use it in GitHub Desktop.
Save thejpster/1b9f6d92eaa295b03cedea4cc8128f9b to your computer and use it in GitHub Desktop.
Some C code I want to be relocatable
// 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