(note) Arm-linux-gcc/ld/objcopy/objdump parameter summary

Source: Internet
Author: User

Description
GCC is the compiler responsible for compiling C code, and LD is the connector responsible for linking multiple *.o target files into elf executables. The elf executable is a common UNIX executable file type, just like the Windows EXE file. There is a lot of information in the Elf file including the segment information and the header information, which is meaningless to the hardware, so sometimes we use objcopy to convert the elf into a bin file loaded into memory to run, the bin file is a pure binary file, And you can disassemble the elf file by Objdump.

----------------------------------------------------------------------------------------------------------

ARM-LINUX-GCC-WALL-O2-C-o [email protected] $<

-O only activates preprocessing, compilation, and assembly, that is, he only makes the program obj file

-wall Specifies that all warning messages are generated

The-O2 compiler provides compiler-optimized options for the program, which can be used at compile time to improve the execution efficiency of the resulting execution file.

-C means that only the compiler is asked to compile, not link, to generate the file name of the source file, but the suffix from. C or. cc into the. O Target file

-S only activates preprocessing and compilation, which means compiling the files into assembly code

Arm-linux-ld

Directly specify the code snippet , data segment , and start address of the BSS segment

-ttest startaddr

-tdata startaddr

-TBSS startaddr

Example :

Arm-linux-ld–ttext 0x0000000–g Led.o–o led_elf

To set an address using a connection script :

Arm-linux-ld–ttimer.lds–o timer_elf $^

Where Timer.lds is the connection script

Full Connection Script format :

sections{

...

Secname start Aling (aling) (NOLOAD): at (LDADDR)

{contents} > Region:phdr=fill

.....

}

arm-linux-objcopy is used to copy the contents of a target file into another file , which can be converted to a format between different source files

Example :

Arm-linux-objcopy–o binary–s Elf_file Bin_file

Common options :

1.input-file, Outflie

Input and output files , if not outfile, the output file name is input file name

2.-l bfdname or -input-target=bfdname

used to indicate the format of the source file, bfdname is the standard format name described in the BFD library and , if not specified , arm-linux-objcopy own analysis

3.-o The format of the Bfdname output

4.-f bfdname also indicate the source file , the format of the destination file

5.-r sectionname Remove all segments named sectionname from the output file

6.-s does not copy relocation information and symbolic information from the source file into the destination file

7.-g do not copy the debug symbols from the source file to the destination file

Arm-linux-objdump

View the target file (. o file) and library file (. a file) information

arm-linux-objdump-d-M arm led_elf > Led.dis

-D displays all assembly information in the file

-M machine
Specifies the schema used when disassembling the target file, which is useful when the disassembly file itself does not describe the schema information (such as S-records). You can use the-I option to list the schemas that can be specified here

(note) Arm-linux-gcc/ld/objcopy/objdump parameter summary

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.