To relocate a target file

Source: Internet
Author: User

"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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.