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.
I made it in C to see how it works and I came with something like :
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);
}
I've got strlen NASM function and my strncmp NASM function. in my header.asm I have :
section .text
global strlen:function
global strcmp:function
global strstr:function
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
%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
And when I compile I got the following error :
srcs/strstr.asm:2: error: no special symbol features supported here
srcs/strstr.asm:3: error: no special symbol features supported here
How to proceed to use those functions ?
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
Thanks !!