sunnysideup wrote:One question that I have is the difference between ~/opt/cross/bin and ~/opt/cross/i686-elf/bin.
Only the file names. In $prefix/bin, you get i686-elf-gcc, whereas in $prefix/i686-elf/bin, you get gcc. It's the same GCC, tho.
sunnysideup wrote:Also in this case, is ~/opt/cross/lib the directory where the standard library is supposed to be located?
No, that would be $prefix/i686-elf/lib (and the include files in $prefix/i686-elf/include). The general idea is that $prefix/ contains binaries for the host machine, but $prefix/$machtype contains binaries for the target. Obvious exception in case of $prefix/$machtype/bin.
sunnysideup wrote:And ~/opt/cross/lib/gcc the place where the libgcc objects are present?
Well, yes, that is there. However, it also contains a ton of CRT files, libraries to link in, and GCC-internal header files (like <stddef.h>).
sunnysideup wrote:Alright, I understand that libgcc is a 'private library' that is used by gcc, i.e. It has significance only during the compilation process, when gcc is in use, kind of like a helper for gcc. Is this right?
No. libgcc contains runtime support routines for code generated by GCC. For instance, if you are developing for a 32-bit architecture, and then you divide a 64-bit number by either another 64-bit number or a 32-bit one, the compiler will generate a call to __udivdi3 (or similar), and that is implemented in libgcc. Also if you are developing for an architecture without hardware float conversion support (e.g. PowerPC), and you convert an integer to a floating-point number, the compiler will probably call a support function to do the actual conversion.
sunnysideup wrote:What is the freestanding environment specified here?
A term from the C standard. The C standard recognizes two types of implementation, namely the hosted and the freestanding implementations. The hosted ones have to provide the entire library from Chapter 7 (i.e. printf() and stuff), while the freestanding implementation only has to provide a small number of headers which only declare types and macros, not functions (stuff like <limits.h> and <float.h>). You can put GCC in freestanding mode by supplying the "-ffreestanding" option. An OS kernel is sort of the prototypical application of that, but for instance, if you are developing a standard C library in C, you have to compile it in freestanding mode as well.
Anyway, the gcc manual states explicitly that even in a freestanding environment, these four memory functions must be available, since GCC can generate calls to them in any mode.