x86_64 assembler: only one call per subroutine?
- by zneak
Hello everyone,
I decided yesterday to start doing assembler. Most of it is okay (well, as okay as assembler can be), but I'm getting some problems with gas.
It seems that I can call functions only once. After that, any subsequent call opcode with the same function name will fail. I must be doing something terribly wrong, though I can't see what.
Take this small C function for instance:
void path_free(path_t path)
{
if (path == NULL) return;
free(((point_list_t*)path)->points);
free(path);
}
I "translated" it to assembler like that:
.globl _path_free
_path_free:
push rbp
mov rbp, rsp
cmp rdi, 0
jz byebye
push rdi
mov rdi, qword ptr [rdi]
call _free
pop rdi
sub rsp, 8
call _free
byebye:
leave
ret
This triggers the following error for the second call _free: suffix or operands invalid for ``call''. And if I change it to something else, like free2, everything works (until link time, that is).
Assembler code gcc -S gave me looks very similar to what I've done (except it's in AT&T syntax), so I'm kind of lost.
I'm doing this on Mac OS X under the x86_64 architecture.