Linux编程——交叉编译器基本指令介绍

2023-05-16

Linux编程——交叉编译器基本指令介绍

arm-linux-gnueabihf-gcc
arm-linux-gnueabihf-ld
arm-linux-gnueabihf-objcopy
arm-linux-gnueabihf-objdump

1.arm-linux-gnueabihf-gcc
简介:编译文件用
作用:具体使用中使用 -g -c (编译文件.s) -o (可执行文件.o)

-g:为使用GDB进行调试
-c:编译源文件但不进行链接
-o:指定编译产生的文件

```bash
  -pass-exit-codes         Exit with highest error code from a phase
  --help                   Display this information
  --target-help            Display target specific command line options
  --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...]
                           Display specific types of command line options
  (Use '-v --help' to display command line options of sub-processes)
  --version                Display compiler version information
  -dumpspecs               Display all of the built in spec strings
  -dumpversion             Display the version of the compiler
  -dumpmachine             Display the compiler's target processor
  -print-search-dirs       Display the directories in the compiler's search path
  -print-libgcc-file-name  Display the name of the compiler's companion library
  -print-file-name=<lib>   Display the full path to library <lib>
  -print-prog-name=<prog>  Display the full path to compiler component <prog>
  -print-multiarch         Display the target's normalized GNU triplet, used as
                           a component in the library path
  -print-multi-directory   Display the root directory for versions of libgcc
  -print-multi-lib         Display the mapping between command line options and
                           multiple library search directories
  -print-multi-os-directory Display the relative path to OS libraries
  -print-sysroot           Display the target libraries directory
  -print-sysroot-headers-suffix Display the sysroot suffix used to find headers
  -Wa,<options>            Pass comma-separated <options> on to the assembler
  -Wp,<options>            Pass comma-separated <options> on to the preprocessor
  -Wl,<options>            Pass comma-separated <options> on to the linker
  -Xassembler <arg>        Pass <arg> on to the assembler
  -Xpreprocessor <arg>     Pass <arg> on to the preprocessor
  -Xlinker <arg>           Pass <arg> on to the linker
  -save-temps              Do not delete intermediate files
  -save-temps=<arg>        Do not delete intermediate files
  -no-canonical-prefixes   Do not canonicalize paths when building relative
                           prefixes to other gcc components
  -pipe                    Use pipes rather than intermediate files
  -time                    Time the execution of each subprocess
  -specs=<file>            Override built-in specs with the contents of <file>
  -std=<standard>          Assume that the input sources are for <standard>
  --sysroot=<directory>    Use <directory> as the root directory for headers
                           and libraries
  -B <directory>           Add <directory> to the compiler's search paths
  -v                       Display the programs invoked by the compiler
  -###                     Like -v but options quoted and commands not executed
  -E                       Preprocess only; do not compile, assemble or link
  -S                       Compile only; do not assemble or link
  -c                       Compile and assemble, but do not link
  -o <file>                Place the output into <file>
  -pie                     Create a position independent executable
  -shared                  Create a shared library
  -x <language>            Specify the language of the following input files
                           Permissible languages include: c c++ assembler none
                           'none' means revert to the default behavior of
                           guessing the language based on the file's extension

参考写法:

arm-linux-gnueabihf-gcc -g -c led.s -o led.o

使用指令前:
在这里插入图片描述

使用指令后:
在这里插入图片描述

2.arm-linux-gnueabihf-ld
简介:链接文件用
作用:将生成的.o类文件链接到一个指定的链接地址

-Ttext (地址):指定链接地址,后期可以编写.lds链接
-o:选择指定生成的.elf文件名
  -a KEYWORD                  Shared library control for HP/UX compatibility
  -A ARCH, --architecture ARCH
                              Set architecture
  -b TARGET, --format TARGET  Specify target for following input files
  -c FILE, --mri-script FILE  Read MRI format linker script
  -d, -dc, -dp                Force common symbols to be defined
  -e ADDRESS, --entry ADDRESS Set start address
  -E, --export-dynamic        Export all dynamic symbols
  --no-export-dynamic         Undo the effect of --export-dynamic
  -EB                         Link big-endian objects
  -EL                         Link little-endian objects
  -f SHLIB, --auxiliary SHLIB Auxiliary filter for shared object symbol table
  -F SHLIB, --filter SHLIB    Filter for shared object symbol table
  -g                          Ignored
  -G SIZE, --gpsize SIZE      Small data size (if no size, same as --shared)
  -h FILENAME, -soname FILENAME
                              Set internal name of shared library
  -I PROGRAM, --dynamic-linker PROGRAM
                              Set PROGRAM as the dynamic linker to use
  -l LIBNAME, --library LIBNAME
                              Search for library LIBNAME
  -L DIRECTORY, --library-path DIRECTORY
                              Add DIRECTORY to library search path
  --sysroot=<DIRECTORY>       Override the default sysroot location
  -m EMULATION                Set emulation
  -M, --print-map             Print map file on standard output
  -n, --nmagic                Do not page align data
  -N, --omagic                Do not page align data, do not make text readonly
  --no-omagic                 Page align data, make text readonly
  -o FILE, --output FILE      Set output file name
  -O                          Optimize output file
  -plugin PLUGIN              Load named plugin
  -plugin-opt ARG             Send arg to last-loaded plugin
  -flto                       Ignored for GCC LTO option compatibility
  -flto-partition=            Ignored for GCC LTO option compatibility
  -fuse-ld=                   Ignored for GCC linker option compatibility
  -Qy                         Ignored for SVR4 compatibility
  -q, --emit-relocs           Generate relocations in final output
  -r, -i, --relocatable       Generate relocatable output
  -R FILE, --just-symbols FILE
                              Just link symbols (if directory, same as --rpath)
  -s, --strip-all             Strip all symbols
  -S, --strip-debug           Strip debugging symbols
  --strip-discarded           Strip symbols in discarded sections
  --no-strip-discarded        Do not strip symbols in discarded sections
  -t, --trace                 Trace file opens
  -T FILE, --script FILE      Read linker script
  --default-script FILE, -dT  Read default linker script
  -u SYMBOL, --undefined SYMBOL
                              Start with undefined reference to SYMBOL
  --unique [=SECTION]         Don't merge input [SECTION | orphan] sections
  -Ur                         Build global constructor/destructor tables
  -v, --version               Print version information
  -V                          Print version and emulation information
  -x, --discard-all           Discard all local symbols
  -X, --discard-locals        Discard temporary local symbols (default)
  --discard-none              Don't discard any local symbols
  -y SYMBOL, --trace-symbol SYMBOL
                              Trace mentions of SYMBOL
  -Y PATH                     Default search path for Solaris compatibility
  -(, --start-group           Start a group
  -), --end-group             End a group
 ..............

参考写法:

arm-linux-gnueabihf-ld -Ttext 0x87800000 led.o -o led.elf

使用指令前:
在这里插入图片描述

使用指令后:
在这里插入图片描述

PS:本次使用的开发板IMX6ULL存储的地址为外部的DDR起始地址为0X80000000,但因为后期的开发需要都写到0x87800000
(内部的RAM地址为0x900000~0x91FFFF)
3.arm-linux-gnueabihf-objcopy
简介:格式转换工具
作用:将.elf文件转换为.bin文件

-O binary:-O表示输出的格式命令 binary为输出二级制
-S:不要复制源文件中的重定位信息和符号信息
-g:不复制源文件中的调试信息
  -I --input-target <bfdname>      Assume input file is in format <bfdname>
  -O --output-target <bfdname>     Create an output file in format <bfdname>
  -B --binary-architecture <arch>  Set output arch, when input is arch-less
  -F --target <bfdname>            Set both input and output format to <bfdname>
     --debugging                   Convert debugging information, if possible
  -p --preserve-dates              Copy modified/access timestamps to the output
  -D --enable-deterministic-archives
                                   Produce deterministic output when stripping archives
  -U --disable-deterministic-archives
                                   Disable -D behavior (default)
  -j --only-section <name>         Only copy section <name> into the output
     --add-gnu-debuglink=<file>    Add section .gnu_debuglink linking to <file>
  -R --remove-section <name>       Remove section <name> from the output
  -S --strip-all                   Remove all symbol and relocation information
  -g --strip-debug                 Remove all debugging symbols & sections
     --strip-dwo                   Remove all DWO sections
     --strip-unneeded              Remove all symbols not needed by relocations
  -N --strip-symbol <name>         Do not copy symbol <name>
     --strip-unneeded-symbol <name>
                                   Do not copy symbol <name> unless needed by
                                     relocations
     --only-keep-debug             Strip everything but the debug information
     --extract-dwo                 Copy only DWO sections
     --extract-symbol              Remove section contents but keep symbols
  -K --keep-symbol <name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)
     --localize-hidden             Turn all ELF hidden symbols into locals
  -L --localize-symbol <name>      Force symbol <name> to be marked as a local
     --globalize-symbol <name>     Force symbol <name> to be marked as a global
  -G --keep-global-symbol <name>   Localize all symbols except <name>
  -W --weaken-symbol <name>        Force symbol <name> to be marked as a weak
     --weaken                      Force all global symbols to be marked as weak
  -w --wildcard                    Permit wildcard in symbol comparison
  -x --discard-all                 Remove all non-global symbols
  -X --discard-locals              Remove any compiler-generated symbols

参考写法:

arm-linux-gnueabihf-objcopy -O binary -S -g led.elf led.bin

使用指令前:
在这里插入图片描述

使用指令后:
在这里插入图片描述

4.arm-linux-gnueabihf-objdump
简介:elf反汇编
作用:反汇编.elf到.dis

-D :反汇编全部的段落
  -a --archive-headers    Display archive header information
  -f --file-headers       Display the contents of the overall file header
  -p --private-headers    Display object format specific file header contents
  -P --private=OPT,OPT... Display object format specific contents
  -h --[section-]headers  Display the contents of the section headers
  -x --all-headers        Display the contents of all headers
  -d --disassemble        Display assembler contents of executable sections
  -D --disassemble-all    Display assembler contents of all sections
  -S --source             Intermix source code with disassembly
  -s --full-contents      Display the full contents of all sections requested
  -g --debugging          Display debug information in object file
  -e --debugging-tags     Display debug information using ctags style
  -G --stabs              Display (in raw form) any STABS info in the file
  -W[lLiaprmfFsoRt] or
  --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
          =frames-interp,=str,=loc,=Ranges,=pubtypes,
          =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,
          =addr,=cu_index]
                           Display DWARF info in the file
  -t, --syms               Display the contents of the symbol table(s)
  -T, --dynamic-syms       Display the contents of the dynamic symbol table
  -r, --reloc              Display the relocation entries in the file
  -R, --dynamic-reloc      Display the dynamic relocation entries in the file
  @<file>                  Read options from <file>
  -v, --version            Display this program's version number
  -i, --info               List object formats and architectures supported
  -H, --help               Display this information

参考写法:

arm-linux-gnueabihf-objdump -D led.elf > led.dis

使用指令前:
在这里插入图片描述

使用指令后:
在这里插入图片描述
在这里插入图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux编程——交叉编译器基本指令介绍 的相关文章

随机推荐

  • ros中使用opencv处理图像

    cv bridge toCvCopy xff1a ROS下的sensor msgs ImageConstPtr xff0c 和图像压缩类型 xff08 例如 xff1a sensor msgs image encodings RGB8 xf
  • PX4飞行日志分析与.ulg文件格式转换

    文章目录 一 FlightPlot安装及使用二 ulg文件格式转换 xff08 windows环境 xff09 一 FlightPlot安装及使用 span class token number 1 span xff09 下载FlightP
  • 【深入理解Java虚拟机 笔记】Java的类加载过程

    类加载的过程如下图所示 xff1a 一 加载阶段 注意 xff1a 这里的 加载 阶段是整个 类加载 过程的一个阶段 xff0c 两个词的含义是不一样的 这个阶段主要做3件事 xff1a 1 通过类的全限定名获取二进制字节流 xff1b 2
  • 【深入理解Java虚拟机 笔记】垃圾回收算法

    前言 当前垃圾回收集器大多都是遵循分代收集理论进行设计的 xff0c 先聊聊什么是分代收集 xff1a xff08 1 xff09 弱分代假说 xff1a 绝大多数对象都是朝生夕灭的 xff1b xff08 2 xff09 强分代假说 xf
  • 【日记 2021-05-01】 leetcode练习&& Linux修改文件权限

    题目 xff1a 1335 工作计划的最低难度 题目内容 xff1a 你需要制定一份 d 天的工作计划表 工作之间存在依赖 xff0c 要想执行第 i 项工作 xff0c 你必须完成全部 j 项工作 xff08 0 lt 61 j lt i
  • 【Leetcode 刷题笔记】16. 3Sum Closest

    题目 方案一 xff1a 穷举法 o n 3 span class token keyword class span span class token class name Solution span span class token pu
  • 【Debugging】SpringSecurity iframe 页面不显示

    问题描述 如下图所示 xff0c 配置了SpringSecurity后 xff0c 网页就加载不出来了 xff0c 多次检查代码都没有问题 xff0c 折腾了好久 xff01 xff01 xff01 解决方案 在SpringSecurity
  • 【日记 2021-05-14】树莓派获取环境亮度(光照度)

    什么是亮度 xff1f 光照度指被照射物体单位面积上所接受可见光的光通量 xff0c 单位是勒克斯 Lux 或流明每平方米 lm m2 xff0c 是用来描述光的亮度的 我们平时最关心的我家灯到底够不够亮 xff0c 具体数值可以用照度计测
  • 【Java】语法糖

    什么是语法糖 xff1f 语法糖就是指 java 编译器把 java 源码编译为 class 字节码的过程中 xff0c 自动生成和转换的一些代码 有哪些语法糖 xff1f 默认构造函数 xff1a 当一个类没有显式的提供构造函数时 xff
  • 【Java多线程】FutureTask的使用示例

    炎热的夏天 xff0c 一位少侠到客栈吃杯茶 xff0c 客栈准备茶水有如下两种方式 xff1a 单线程 先擦桌子 xff0c 花费3秒 xff1b 再准备茶水 xff0c 花费3秒 xff1b 共花费6秒 xff01 多线程 擦桌子和准备
  • 旷视研究院博士图鉴|Be that challenger

    图为旷视研究院日常工作一景 旷视研究院有这样一批挑战者 他们是 PhD xff0c 更是 Researcher 他们 深入探索科技发展的前沿阵地 笃信自己的科研价值 渴望见证一行行代码的快速落地 期待与同样优秀的人碰撞思维 做自己所爱的事
  • 【Java多线程】CompletableFuture的使用示例

    刘备 关羽和张飞三兄弟在家吧喝酒 xff0c 突然发现忘带钱了 xff0c 于是差下人回去取钱 为了不影响三兄弟喝酒的气氛 xff0c 刘备吩咐下人钱取来后交给旁边侍候的赵云即可 span class token keyword publi
  • 【Java基础】Arrays.sort()使用示例

    狗有名字 体重和年龄3个属性 xff1a span class token keyword public span span class token keyword class span span class token class nam
  • 【Spring】aop的使用示例

    场景 去饭店吃饭的时候 xff0c 在进入饭店时门卫会为你开门 xff0c 并问候说 欢迎光临 xff0c 当你吃完离开时 xff0c 门卫会说 请慢走 xff0c 欢迎下次光临 此场景下涉及如下两个角色 xff1a 顾客 xff08 cu
  • 关于从Github上下载历史版本

    第一步 打开一个仓库 xff0c 可以看到此时在主分支下 xff0c 点击1位置查看历史版本 第二步 现在可以查看到所有的版本 xff08 提交 xff09 信息 xff0c 单击2位置进入该版本 第三步 单击3位置浏览并打开该版本 第四步
  • 数据结构——结构体

    结构体是一种复合数据类型 xff0c 定义了一组变量列表 xff0c 这些变量将放在一个内存块中的名称下 它允许通过使用指向结构的一个指针来访问不同的变量 struct structure name data type member1 da
  • python 归并排序

    归并排序 xff08 Merge Sort xff09 是一种典型的递归法排序 它把复杂的 排序过程分解成一个简单的合并子序列的过程 至于怎么得到这个子 序列 xff0c 就得自己调用自己了 归并排序首先要做的就是将数列分成左右两部分 xf
  • ROS学习笔记—— rospy

    所有资料均来自于 https www icourse163 org learn ISCAS 1002580008 learn announce 和 https github com DroidAITech ROS Academy for B
  • XCOM(串口监视器,无单片机)+ESP8266显示心知天气天气信息

    XCOM xff08 串口监视器 xff0c 无单片机 xff09 43 ESP8266显示心知天气天气信息 ESP8266 AT指令显示 这是第一次写博客 xff0c 写的内容尽量通俗易懂贴近生活 PS 写的不好务必不要打我 ESP826
  • Linux编程——交叉编译器基本指令介绍

    Linux编程 交叉编译器基本指令介绍 arm span class token operator span linux span class token operator span gnueabihf span class token o