I have been trying to learn assembly code for PPC on a Mac OS 10.5. I have wanted to see how, when compiling a c program, 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 done this by writing simple programs in c and examining the .s files to try to tell how the code is being modified. In examination of the assembly code output by GCC, 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 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 either the compiler, GAS, or the linker is using that ultimately generates the machine code that performs these operations.
I have searched and hacked at this for three 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.
Can anyone enlighten me on this or know where to find out this information? I have found virtually nothing on the web for Assembly programming for PPC Mac.
ps, 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?
One other thing that puzzles me is that the code branches to routines that have a suffix called "$stub", which I am assuming that means it is a "stub", but these are obviously the routines that are doing the work. My understanding of the definition of "stub" is something that is just a placeholder, and doesn't do any real work.
NOTE This was originally posted on Dev Shed, but after not getting a reply I have posted it here.