My function is not exported by NASM assembler and therefore I can not link it with my C program. I am using the export
directive like the manual says, but it is not recognized. What is wrong? Here is how I do it:
[niko@dev1 test]$ cat ssefuncs.S
use64
section .data
NEW_LINE_4_SSE db '1111111111111111'
section .text
export find_nl_sse
find_nl_sse:
mov rax,NEW_LINE_4_SSE
movntdqa xmm0,[esi]
pcmpestri xmm0,[rax],0x0
ret
[niko@dev1 test]$ nasm -f elf64 -o ssefuncs.o ssefuncs.S
ssefuncs.S:7: error: parser: instruction expected
[niko@dev1 test]$
If I omit the export
, recompile the assembly and try to link, the resulting code won't link with my C program:
[niko@dev1 test]$ gcc -o bench3 ssefuncs.o bench3.o
bench3.o: In function `main':
/home/niko/quaztech/qstar/test/bench3.c:34: undefined reference to `find_nl_sse'
collect2: error: ld returned 1 exit status
[niko@dev1 test]$
I also tried to add the global
directive but I get the same error. Why NASM documentation is so misleading?
export find_nl_sse
beforesection .text
also tryglobal
instead ofexport
. 2. in asm name it_find_nl_sse
and in Cfind_nl_sse
.global
andexport
do different thinigs.