KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I write empty programs to annoy the hell out of stackoverflow coders, NOT. I am just exploring the gnu toolchain. Now the following might be too deep for me, but to continuie the empty program saga I have started to examine the output of the C compiler, the stuff GNU as consumes. gcc version 4.4.0 (TDM-1 mingw32) test.c: int main() { return 0; } gcc -S test.c .file "test.c" .def ___main; .scl 2; .type 32; .endef .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp call ___main movl $0, %eax leave ret Can you explain what happens here? Here is my effort to understand it. I have used the as manual and my minimal x86 ASM knowledge: .file "test.c" is the directive for the logical filename. .def : according to the docs "Begin defining debugging information for a symbol name" . What is a symbol (a function name/variable?) and what kind of debugging information? .scl : docs say "Storage class may flag whether a symbol is static or external" . Is this the same static and external I know from C? And what is that '2'? .type : stores the parameter "as the type attribute of a symbol table entry" , I have no clue. .endef : no problem. .text : Now this is problematic, it seems to be something called section and I have read that its the place for code, but the docs didn't tell me too much. .globl "makes the symbol visible to ld." , the manual is quite clear on this. _main: This might be the starting address (?) for my main function pushl_ : A long (32bit) push
Tags (comma-separated)
Save Edits
Cancel