Standardized GCC ABI?[SOLVED]
Posted: Sun Dec 12, 2010 12:53 am
Ok, so im chuggin along writing nice assembly code for some bits of my toy-kernel and realize something VERY interesting ... it seems that when I build a '.c' code file with:
I expect the resulting code to be:
But something strange happens and I get this:
It seems that GCC is applying one ABI standard when compiling programs for your native operating system; consequently, when writing for another OS ... my kernel ... it acts like its never had the previous ABI and it starts using the minuscule amount of stack space I have for passing arguments! What the heck?! Is there a way to use the same ABI specs for cross compiling?
.... edit ....
You know what, now that I think about it ... it kinda makes sense. When doing 64-Bit assembly you have 16 GP registers and in 32-Bit you only have 8 and some are for specific uses. But does anybody know where to find a website that actually documents the the way functions communicate with each other in 32-bit mode?
Code: Select all
int some3( int im_expectin_int ){ return im_expectin_int; }
gcc -m32 -g -ffreestanding -nostdlib -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -nostdinc -fno-builtin -nostartfiles -nodefaultlibs -S -O0 -c file.c -o file.S
Code: Select all
.globl some3
.type some3, @function
some3:
pushl %ebp
movl %esp, %ebp
// Expecting the %edi register to be the standard 1st argument, like always
movl %edi, %eax
// Cleanup
movl %ebp, %esp
popl %ebp
ret
Code: Select all
.globl some3
.type some3, @function
some3:
pushl %ebp
movl %esp, %ebp
// Wait WHAAAAT?
movl 8(%ebp), %eax
popl %ebp
ret
.... edit ....
You know what, now that I think about it ... it kinda makes sense. When doing 64-Bit assembly you have 16 GP registers and in 32-Bit you only have 8 and some are for specific uses. But does anybody know where to find a website that actually documents the the way functions communicate with each other in 32-bit mode?