NOTE: After getting the feeling there are not too many assembly programmers frequenting this page, I have cross-posted to:
I have been trying to learn assembly code for PPC on a Mac OS 10.5. My question pertains to determining how GCC uses libraries on the Mac to insert instructions to perform functions such as malloc(), write() and printf() in a way that is not (so) machine dependent, as would be using something like syscall. I have started by (first, reading the docs) and by writing simple programs in c and examining the .s files to try to tell how the code is being modified. In examination, I observe several directives (which I believe can also be called psuedo-ops) which are not part of the GAS assembler specification. So I am assuming they are coming from a library somewhere. Examples are .indirect_symbol, .lazy_symbol_pointer, .subsections_via_symbols.
I have read that (probably on 386 PCs) for commands such as printf(), the linker links the object file output from the assembler with a ready-made object file called printf.o, and these are combined to create the executable. I have wanted to examine the files that GAS (or the linker) is using that ultimately generates the machine code that performs these functions higher level functions.
I have searched and hacked at this for two days, and have come up with nothing. I have searched my computer for the existence of files with a .o extension, have searched for Mach-o, dylib, and there is virtually nothing on my hard drive that would appear that is being used by the compiler/assembler/linker. I really don't know what I should be looking for.
I find text in the code such as _malloc, _write, and _printf, so I am assuming that these must be referred to in a library somewhere.
Anyone know where to find out this information?
: I would also like to know, do functions such as write(), read(), etc ultimately use syscall by determing the syscall number of those machine functions?