"0" gcc process of converting source code into executable code
- (1)C preprocessor CPP extension source code, insert all the files specified with the # include command, and expand the declared macros;
- (2) compiler CCL generated two source code assembly code: *.S;
- (3) Assembler as converts assembly code into binary target code: *.O; (The target code is a form of machine code that contains the binary representation of all instructions, but not the global value of the address)
- (4) The linker ld merges the target code with the code implementing the library function, resulting in the executable code file;
"1" first step, source speech
"2" Generate the target file p107.o and disassemble it
2.1) Gcc-o1-c p107.c "produces the target file p107.o (note that there is no link at this time)
2.2) objdump-d p107.o >> p107-obj-dis.s disassembly target file p107.o get P107-OBJ-DIS.S as follows:
"3" generates executable file p107 and disassemble it
3.1) Gcc-o1-o p107 p107.o p107-main.c Generate executable p107 (note that this is the link process)
3.2) objdump-d p107 >> p107-exe-dis.s disassembly executable p107, get P107-EXE-DIS.S assembly file, the file content is as follows:
"4" Compare P107-OBJ-DIS.S and P107-EXE-DIS.S
"Summary"In a word, reposition the target file is the assembler uses the compiler output assembly language output of the binary target file, to know that the target file uses a relative physical (memory) address, the purpose of relocation is to disguise the physical address to the absolute physical address. (Bingo)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
To relocate a target file