Reputation: 840
How can I simply call an external symbol in a library function written in 32bit x86 assembler? This works under x86-64 (NASM):
extern ExternSymbol
MyFunc:
...
call ExternSymbol WRT ..plt
The same code compiled for 32bit x86 jumps to address 0x0.
Upvotes: 2
Views: 2335
Reputation: 58762
You must be doing something wrong, as it works for me like this:
$ cat >libfoo.c
int foo() { return 42; }
$ gcc -m32 -shared -o libfoo.so libfoo.c
$ cat >main.asm
[bits 32]
extern foo
global _start
_start:
call foo wrt ..plt
mov ebx, eax
mov eax, 1
int 80h
$ nasm -f elf32 main.asm
$ gcc -nostdlib -m32 -L. -lfoo main.o
$ LD_LIBRARY_PATH=. ./a.out
$ echo $?
42
Upvotes: 2