title: How to use external function in assembly (x86)
body: <p>I'm working on assembly language (NASM), and I am currently rewriting some functions such as strlen and strncmp for example, and I'm trying do redo strstr.</p>
  
  <p>I made it in C to see how it works and I came with something like :</p>
  
  <pre><code>char    *my_strstr(char *str, char *match)
  {
      int i = -1;
      int len = strlen(match);
      while (str[++i] != '\0')
            if (strncmp((str + i), match, len) == 0)
               return (str + i);
      return (NULL);
  }
  </code></pre>
  
  <p>I've got strlen NASM function and my strncmp NASM function.
  in my header.asm I have :</p>
  
  <pre><code>section .text
      global strlen:function
      global strcmp:function
      global strstr:function
  </code></pre>
  
  <p>And now the file where I want to call those both function that I did earlier (no check for NULL str either) It probably not work but... that's not the problem</p>
  
  <pre><code>    %include "src/header.asm"
      extern strlen
      extern strncmp
  
  strstr:
      ;; bla bla bla
      call strlen
      mov  rdx, rax ; the return value of strlen is in rax right ?
      ;; bla bla bla
      call strncmp ;
      cmp rax, 0h ; the return value still is in rax right ?
      je bla bla bla
      ;; bla bla bla
  </code></pre>
  
  <p>And when I compile I got the following error :</p>
  
  <pre><code>srcs/strstr.asm:2: error: no special symbol features supported here
  srcs/strstr.asm:3: error: no special symbol features supported here
  </code></pre>
  
  <p>How to proceed to use those functions ?</p>
  
  <p>I use my dynamic library libasm.so (containing those functions) used by my C files. The standard library doesn't exist anymore, the compilation bypass the stdlib. My compilation command is : gcc main.c -Wl,-rpath=. -L. -lasm -fno-builtin</p>
  
  <p>Thanks !!</p>