Everything you asked is outside the work the compiler does.
The compiler's main objective is to take (preprocessed) high-level code, and translate it to assembly code. Example:
$ cat hello.c
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello, World!\n");
return 0;
}
$ gcc -S -o hello.s hello.c
$ cat hello.s
.file "hello.c"
.section .rodata
.LC0:
.string "Hello, World!"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $4, %esp
movl $.LC0, (%esp)
call puts
movl $0, %eax
addl $4, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.2.1 (SUSE Linux)"
.section .note.GNU-stack,"",@progbits
The assembler then uses that to create an object file (the output of 'gcc -c').
The linker takes the object file and connects it with various libraries to create an executable.
The loader reads the executable, and loads the referenced libraries, if available, and maps them into virtual memory.
The 'gcc' command, by default, hides these steps from the user, and invokes the complete toolchain (for a C program: cpp [C Pre-Processor], cc [C Compiler], as [Assembler], and ld [Linker])
Further reading: Compiler, Assembler, Linker, Virtual memory, and a series of blog posts on Linkers
---------- Post updated at 11:37 ---------- Previous update was at 11:18 ----------
Addendum: if you compile the program above (hello.c) using
gcc -v -save-temps -o hello hello.c
you'll see all the "compilation" steps, and the intermediate steps will be saved to hello.i (preprocessed), hello.s (compiled), hello.o (assembled), and hello (linked).