Embedded linux-study notes basics

1. A c/c++ file needs to go through 4 steps of preprocessing, compiling, assembling, and linking before it can be turned into an executable file.

a. Preprocessing: Commands starting with # are called preprocessing commands. Insert the file to be processed into the original file, expand the macro definition, etc., and finally output these codes to a .i file. The tool used is: arm-linux-cpp.

b. Compile: translate the .i file into assembly code, the tool is cc1

c. Assembly: Translate the generated assembly code into machine code in a certain format, which is represented as an ELF file (OBJ file), tool: arm-linux-as, disassembly is to convert the machine code into assembly code, which is used during debugging.

d. Connection: connect the OBJ file generated in the previous step with the OBJ file and library file of the system library to generate an executable file, the tool arm-linux-ld


2, arm-linux-ld option

The "-T" option can be used directly to specify the starting address of the code segment, data segment, bss segment, or to specify a connection script for more complex address settings

例 : -Ttext startaddr

       -Tdata startaddr

       -Tbss startaddr

b. The bl jump instruction is a position independent code. When programs such as bootloader and kernel first start to execute, their address is generally not equal to the running address. At the beginning of the program, use position-independent commands such as b, bl, and mov to copy the code from the flash and other devices to the running address of the memory, and then jump to the running address to execute.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325478974&siteId=291194637