交叉编译工具参数笔记

  • arm-linux-gcc:

-v 显示编译的细节
-o 指定输出文件名
-c 预处理、编译和汇编源文件,但是不做连接
-S 编译后即停止
-E 预处理后即停止
-Wall   基本打开了所有需要注意的警告信息
-(小写L)llibrary 连接名为 library 的库文件
-nostartfiles 不连接系统标准启动文件,而标准库文件仍然正常使用
-nostdlib 不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器
-static 在支持动态连接的系统上阻止连接共享库(生成的文件更大)
-shared 生成一个共享的 OBJ 文件,它可以和其他 OBJ 文件连接生成可执行文件(生成库)
-(大写 i )Idir 在头文件的搜索路径列表添加 dir 目录
-Ldir 在“-l(小写L)”选项的搜索路径列表中添加 dir 目录

  • arm-linux-ar:

    c  创建一个库。不管库是否存在,都将创建。

    r   在库中插入模块(替换)。当插入的模块名已经在库中存在,则替换同名的模块。如果若干模块中有一个模块在库中不存在,ar显示一个错误消息,并不替换其他同名模块。默认的情况下,新的成员增加在库的结尾处,可以使用其他任选项来改变增加的位置。

    v  该选项用来显示执行操作选项的附加信息。

 

  • arm-linux-ld:

-Ttext/-Tdata/-Tbss 直接指定代码段、数据段、bss 段的起始地址,后接 16 进制数
-Tlink.lds 指定连接脚本为 link.lds
示例:arm-linux-ld -Ttimer.lds -o timer_elf $^

-Bstatic   Do not link against shared libraries.

-u symbol   Force symbol to be entered in the output file as an undefined symbol. Doing this may, for example, trigger linking of additional modules from standard libraries.

-Map mapfile  Print a link map to the file mapfile.

  • arm-linux-objcpy:

-O bfdname 使用指定的格式来输出文件,bfdname 是 BFD 库中描述的标准格式名
-S 不从源文件中复制定位信息和符号信息到目标文件中去
示例:arm-linux-objcopy -O binary -S elf_file bin_file

  • arm-linux-objdump:

-D 反汇编所有段
-b bfdname 指定目标码格式,不是必须,arm-linux-objdump 能自动识别很多格式
-i 查看支持的目标码格式列表
示例:arm-linux-objdump -D -m arm elf_file > dis_file   arm-linux-objdump -D -b binary -m arm bin_file > dis_file

-x  Display all available header information, including the symbol table and relocation entries. Using -x is equivalent to specifying all of -a -f -h -p -r -t.

原文地址:https://www.cnblogs.com/fox-Benjiaming/p/12331765.html