Compile shared library from asm code with current sources
2
votes
1
answer
5707
views
I just did some basic functions in asm that I compile in a shared library.
Like :
BITS 64
global foo
section .text
foo:
mov rax, 1
ret
I compiled with :
nasm -f elf64 foo.S -o foo.o && gcc -shared foo.o -o libfoo.so
I have a main of test :
#include
int foo();
int main()
{
printf("%d\n", foo());
return (0);
}
If I compiled it with the foo.o directly, everything works well. But if I compiled like this :
gcc main.c -L. -lfoo
I would get this error :
/usr/.../bin/ld: warning: type and size of dynamic symbol `foo' are not defined
I thought it was because the prototype is not declared, but I recompiled foo.o with a lib.h file containing the prototype, and the same problem occurs.
Is that I must complete another section of the elf file?
Thank you.
Asked by OOM
(133 rep)
Mar 23, 2016, 04:46 PM
Last activity: Oct 1, 2018, 09:29 PM
Last activity: Oct 1, 2018, 09:29 PM