Do you run this code in kernel, not haiku_loader? I had similar issue. -fpic -shared
is needed for compiling kernel. You can disassemble kernel binary and look how constants and global variables are compiled. Also take a look at relocations. Check that required relocations are implemented here.
2 Likes