gcc
Cheatsheet
Most useful commands (especially for me:)
Create position independent code( -fPIC)
Use compile line macros (-Dmacro)
Convert warnings to errors (-Werror)
Gcc options through a file using @option usefull if you use many options. Example file:
Strip the content
Add debugging information
Generate Makefile
Specify architecture
Without rbp register
Get pretty assembly output
Get compiling stages
Get pre-processed output from file.c -> file.i
Compilation from file.i -> file.s
Assembly
Linking
Get all intermediate files using (-save-temps)
Linking with shared libraries (-l)
Produce only compiled code
This enables all the warnings about constructions that some users consider questionable. Compile every program with this flag.
Include source code in asm output:
Special commands
Disable stack protection. Usefull when you learn buffer overflow.
Use fpu registers. Usefull when you learn x87 FPU Coproccesor commands
Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper. Can get information about where include files was searched.
Don't produce a position independent executable. There is problem when compiling some programs.
Debian switched to PIC/PIE binaries in 64-bits mode & GCC in your case is trying to link your object as PIC
For more details see https://stackoverflow.com/questions/48071280/nasm-symbol-printf-causes-overflow-in-r-x86-64-pc32-relocation
Do not search the standard system directories for header files. Only the directories explicitly specified with flags.
Create simple static library http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
Print the full absolute name of the library
Compiler Level
https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html
dump AST info
最后更新于