Author Topic: export error  (Read 10568 times)

Offline nulik

  • Jr. Member
  • *
  • Posts: 2
export error
« on: February 01, 2016, 07:46:51 PM »
Hi.
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.
What is wrong here?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: export error
« Reply #1 on: February 01, 2016, 08:25:15 PM »
Hi Nulik,

As the Friendly Manual should tell you, "export" is a format-specific directive. It's to "export" a symbol from a .dll in the Windows world. It doesn't mean anything in "-f elf64". "global", however, should be what you want. Try that again and get back to us with exactly what happens.
Code: [Select]
global find_nl_sse
... shouldn't need a leading underscore, I don't think...

Best,
Frank


Offline nulik

  • Jr. Member
  • *
  • Posts: 2
Re: export error
« Reply #2 on: February 02, 2016, 12:14:27 AM »
no it does not need _ (underscore)
works perfectly, thanks!