Ok, so I can call the function as fastcall CC, declaring it with __attribute__((fastcall)). How to define a function as fastcall?
Like, I have a caller code:
unsigned long func(unsigned long i) __attribute__((fastcall));
void caller() {
register unsigned long i = 0;
while ( i != 0xFFFFFFD0 ) {
i = func(i);
}
}
And function:
unsigned long func(unsigned long i) {
return i++;
}
This code func()compiles as cdecl , it pulls i from the stack, not from ecx (this is i386).
If I write unsigned long func(unsigned long i) __attribute__((fastcall));to func.c it just won’t compile saying
error: expected ‘,’ or ‘;’ before ‘{’ token
If I declare this in func.c in the same way as in caller.c, it will complain differently:
error: previous declaration of ‘func’ was here
source
share