* -fPIC (position independent code), used to generate code can be executed anywhere in the kernel, usually used to generate shared library.
* -shared -o libfoo.so, generate shared library directly, convenience provided by GCC.
* LD_LIBRARY_PATH, specify the additional path to shared library, other than regular /lib, /usr/lib ... directories.
GCC options:
* General Options:
-c (compilation only)
-S (generate assembly code)
* Language Options:
-ansi (ansi C90 standard)
-std=c89, gnu89, c99, gnu89 (use various ANSI C standards, or GNU C standards)
-fno-builtin (do not use the built-in version of printf/memcpy/etc in gcc, use external library version)
* Warning Levels:
-pedantic (strictly follow C standard, give warnings, or -pedantic-errors)
-Wformat (one of many warnings to check the code)
-Wall (a wide range of warnings)
* Debugging:
-g
* Optimization:
-O0, -O3
-Os
* Hardware options:
-march
-msoft-float
-mbig-endian, -mlittle-endian
-mabi
GNU Binutils
Assembler:
as -o foo.o foo.s
Linker:
ELF: Executable and Linking Format
crtbegin.o, crtend.o
Linking script: /usr/lib/ldscripts
Objcpy and objdump:
objdump -x -d -S hello_world
Kernel and toolchain:
* inline assembly
__asm__ __volatile__
* __attribute__, section, alignment, alias
* custom linker script, arch/