root@talos:~/meowray/globals # cat globals_lib.c #include static int __foo[3] = { 1234, 4321, 8181 }; int *__foozero = &__foo[0]; int *__fooone = &__foo[1]; int *__footwo = &__foo[2]; void dump_from_lib(void); void dump_from_lib() { printf("From lib: %d %d %d\n", __foo[0], __foo[1], __foo[2]); } root@talos:~/meowray/globals # cat globals_main.c #include extern int *__foozero; extern int *__fooone; extern int *__footwo; void dump_from_lib(void); int main (int argc, char *argv[]) { printf("From main: %d %d %d\n", *__foozero, *__fooone, *__footwo); dump_from_lib(); printf("Setting.\n"); *__foozero = 1414; *__fooone = 8312; *__footwo = 1337; printf("From main: %d %d %d\n", *__foozero, *__fooone, *__footwo); dump_from_lib(); return (0); } root@talos:~/meowray/globals # cc -m32 -fuse-ld=/opt/llvm/bin/ld.lld -shared -fPIC -o globals_lib.so globals_lib.c root@talos:~/meowray/globals # cc -m32 -fuse-ld=/opt/llvm/bin/ld.lld -o globals globals_main.c ./globals_lib.so root@talos:~/meowray/globals # cc -m32 -fuse-ld=/usr/local/bin/ld.bfd -o globals_bfd globals_main.c ./globals_lib.so root@talos:~/meowray/globals # ./globals Segmentation fault (core dumped) root@talos:~/meowray/globals # ./globals_bfd From main: 1234 4321 8181 From lib: 1234 4321 8181 Setting. From main: 1414 8312 1337 From lib: 1414 8312 1337