I have the following:
BITS 64__NR_getuid equ 102global sys_getuidsection .textsys_getuid: xor eax, eax mov al, __NR_getuid syscall ret
This is compiled with:
nasm -f elf64 -o getuid.o getuid.asmld -shared -o libgetuid.so getuid.o
However sys_getuid
isn't exported. Witness:
#include <stdio.h>extern int sys_getuid();int main(){ printf("UID = %d\n", sys_getuid()); return 0;}
gcc -o junk -L. -lgetuid junk.c/usr/bin/ld: /tmp/ccHOc4iR.o: in function `main':junk.c:(.text+0xa): undefined reference to `sys_getuid'collect2: error: ld returned 1 exit status
How do I export the symbol?
I clearly don't need any relocation information for this library, so I should be able to do this like so.