`
lobin
  • 浏览: 427690 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
阅读更多

ld

对gcc编译器比较熟悉的朋友肯定对ld有了解。这是一个链接器,linux下通过gcc编译c程序的话,链接就是通过ld来完成的。

写道
# ld --help
Usage: ld [options] file...
Options:
-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
-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
--accept-unknown-input-arch Accept input files whose architecture cannot be determined
--no-accept-unknown-input-arch
Reject input files whose architecture is unknown
--as-needed Only set DT_NEEDED for following dynamic libs if used
--no-as-needed Always set DT_NEEDED for dynamic libraries mentioned on
the command line
-assert KEYWORD Ignored for SunOS compatibility
-Bdynamic, -dy, -call_shared
Link against shared libraries
-Bstatic, -dn, -non_shared, -static
Do not link against shared libraries
-Bsymbolic Bind global references locally
-Bsymbolic-functions Bind global function references locally
--check-sections Check section addresses for overlaps (default)
--no-check-sections Do not check section addresses for overlaps
--copy-dt-needed-entries Copy DT_NEEDED links mentioned inside DSOs that follow
--no-copy-dt-needed-entries Do not copy DT_NEEDED links mentioned inside DSOs that follow
--cref Output cross reference table
--defsym SYMBOL=EXPRESSION Define a symbol
--demangle [=STYLE] Demangle symbol names [using STYLE]
--embedded-relocs Generate embedded relocs
--fatal-warnings Treat warnings as errors
--no-fatal-warnings Do not treat warnings as errors (default)
-fini SYMBOL Call SYMBOL at unload-time
--force-exe-suffix Force generation of file with .exe suffix
--gc-sections Remove unused sections (on some targets)
--no-gc-sections Don't remove unused sections (default)
--print-gc-sections List removed unused sections on stderr
--no-print-gc-sections Do not list removed unused sections
--hash-size=<NUMBER> Set default hash table size close to <NUMBER>
--help Print option help
-init SYMBOL Call SYMBOL at load-time
-Map FILE Write a map file
--no-define-common Do not define Common storage
--no-demangle Do not demangle symbol names
--no-keep-memory Use less memory and more disk I/O
--no-undefined Do not allow unresolved references in object files
--allow-shlib-undefined Allow unresolved references in shared libaries
--no-allow-shlib-undefined Do not allow unresolved references in shared libs
--allow-multiple-definition Allow multiple definitions
--no-undefined-version Disallow undefined version
--default-symver Create default symbol version
--default-imported-symver Create default symbol version for imported symbols
--no-warn-mismatch Don't warn about mismatched input files
--no-warn-search-mismatch Don't warn on finding an incompatible library
--no-whole-archive Turn off --whole-archive
--noinhibit-exec Create an output file even if errors occur
-nostdlib Only use library directories specified on
the command line
--oformat TARGET Specify target of output file
-qmagic Ignored for Linux compatibility
--reduce-memory-overheads Reduce memory overheads, possibly taking much longer
--relax Relax branches on certain targets
--retain-symbols-file FILE Keep only symbols listed in FILE
-rpath PATH Set runtime shared library search path
-rpath-link PATH Set link time shared library search path
-shared, -Bshareable Create a shared library
-pie, --pic-executable Create a position independent executable
--sort-common [=ascending|descending]
Sort common symbols by alignment [in specified order]
--sort-section name|alignment
Sort sections by name or maximum alignment
--spare-dynamic-tags COUNT How many tags to reserve in .dynamic section
--split-by-file [=SIZE] Split output sections every SIZE octets
--split-by-reloc [=COUNT] Split output sections every COUNT relocs
--stats Print memory usage statistics
--target-help Display target specific options
--task-link SYMBOL Do task level linking
--traditional-format Use same format as native linker
--section-start SECTION=ADDRESS
Set address of named section
-Tbss ADDRESS Set address of .bss section
-Tdata ADDRESS Set address of .data section
-Ttext ADDRESS Set address of .text section
-Ttext-segment ADDRESS Set address of text segment
--unresolved-symbols=<method>
How to handle unresolved symbols. <method> is:
ignore-all, report-all, ignore-in-object-files,
ignore-in-shared-libs
--verbose Output lots of information during link
--version-script FILE Read version information script
--version-exports-section SYMBOL
Take export symbols list from .exports, using
SYMBOL as the version.
--dynamic-list-data Add data symbols to dynamic list
--dynamic-list-cpp-new Use C++ operator new/delete dynamic list
--dynamic-list-cpp-typeinfo Use C++ typeinfo dynamic list
--dynamic-list FILE Read dynamic list
--warn-common Warn about duplicate common symbols
--warn-constructors Warn if global constructors/destructors are seen
--warn-multiple-gp Warn if the multiple GP values are used
--warn-once Warn only once per undefined symbol
--warn-section-align Warn if start of section changes due to alignment
--warn-shared-textrel Warn if shared object has DT_TEXTREL
--warn-alternate-em Warn if an object has alternate ELF machine code
--warn-unresolved-symbols Report unresolved symbols as warnings
--error-unresolved-symbols Report unresolved symbols as errors
--whole-archive Include all objects from following archives
--wrap SYMBOL Use wrapper functions for SYMBOL
@FILE Read options from FILE
ld: supported targets: elf32-i386 a.out-i386-linux pei-i386 elf64-x86-64 elf64-l1om elf64-little elf64-big elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex trad-core
ld: supported emulations: elf_i386 i386linux elf_x86_64 elf_l1om
ld: emulation specific options:
elf_i386:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
elf_x86_64:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility
elf_l1om:
--build-id[=STYLE] Generate build ID note
--audit=AUDITLIB Specify a library to use for auditing
-P AUDITLIB, --depaudit=AUDITLIB
Specify a library to use for auditing dependencies
-Bgroup Selects group name lookup rules for DSO
--disable-new-dtags Disable new dynamic tags
--enable-new-dtags Enable new dynamic tags
--eh-frame-hdr Create .eh_frame_hdr section
--hash-style=STYLE Set hash style to sysv, gnu or both
-z combreloc Merge dynamic relocs into one section and sort
-z defs Report unresolved symbols in object files.
-z execstack Mark executable as requiring executable stack
-z initfirst Mark DSO to be initialized first at runtime
-z interpose Mark object to interpose all DSOs but executable
-z lazy Mark object lazy runtime binding (default)
-z loadfltr Mark object requiring immediate process
-z muldefs Allow multiple definitions
-z nocombreloc Don't merge dynamic relocs into one section
-z nocopyreloc Don't create copy relocs
-z nodefaultlib Mark object not to use default search paths
-z nodelete Mark DSO non-deletable at runtime
-z nodlopen Mark DSO not available to dlopen
-z nodump Mark DSO not available to dldump
-z noexecstack Mark executable as not requiring executable stack
-z norelro Don't create RELRO program header
-z now Mark object non-lazy runtime binding
-z origin Mark object requiring immediate $ORIGIN
processing at runtime
-z relro Create RELRO program header
-z max-page-size=SIZE Set maximum page size to SIZE
-z common-page-size=SIZE Set common page size to SIZE
-z KEYWORD Ignored for Solaris compatibility

Report bugs to <http://bugzilla.redhat.com/bugzilla/>

 

--oformat TARGET

指定链接输出的文件格式。这里的TARGET指定的是bfdname,表示输出文件是哪种BFD格式。

 

可通过objdump工具查看支持的格式

# objdump -i

BFD header file version version 2.20.51.0.2-5.48.el6 20100205

elf32-i386

 (header little endian, data little endian)

  i386

a.out-i386-linux

 (header little endian, data little endian)

  i386

pei-i386

 (header little endian, data little endian)

  i386

elf64-x86-64

 (header little endian, data little endian)

  i386

elf64-l1om

 (header little endian, data little endian)

  l1om

elf64-little

 (header little endian, data little endian)

  i386

  l1om

elf64-big

 (header big endian, data big endian)

  i386

  l1om

elf32-little

 (header little endian, data little endian)

  i386

  l1om

elf32-big

 (header big endian, data big endian)

  i386

  l1om

srec

 (header endianness unknown, data endianness unknown)

  i386

  l1om

symbolsrec

 (header endianness unknown, data endianness unknown)

  i386

  l1om

verilog

 (header endianness unknown, data endianness unknown)

  i386

  l1om

tekhex

 (header endianness unknown, data endianness unknown)

  i386

  l1om

binary

 (header endianness unknown, data endianness unknown)

  i386

  l1om

ihex

 (header endianness unknown, data endianness unknown)

  i386

  l1om

trad-core

 (header endianness unknown, data endianness unknown)

 

               elf32-i386 a.out-i386-linux pei-i386 elf64-x86-64 elf64-l1om 

          i386 elf32-i386 a.out-i386-linux pei-i386 elf64-x86-64 ---------- 

          l1om ---------- ---------------- -------- ------------ elf64-l1om 

 

               elf64-little elf64-big elf32-little elf32-big srec symbolsrec 

          i386 elf64-little elf64-big elf32-little elf32-big srec symbolsrec 

          l1om elf64-little elf64-big elf32-little elf32-big srec symbolsrec 

 

               verilog tekhex binary ihex trad-core 

          i386 verilog tekhex binary ihex --------- 

          l1om verilog tekhex binary ihex --------- 

在链接脚本文件中指定的OUTPUT_FORMAT和这里命令行上指定--oformat TARGET是一样的意思。

如:

OUTPUT_FORMAT("pe-i386")

如果同时在命令行和链接脚本中都指定了,优先使用命令行的方式。

 

在windows下通过cygwin使用该ld是不支持指定binary的输出格式:

OUTPUT_FORMAT("binary")

或者在命令行中指定--oformat binary

 

ld: cannot perform PE operations on non PE output file 'setup.exe'.

 

如果需要输出binary纯二进制镜像的话,可以通过objcpy生成:

参考另一篇文章:https://www.iteye.com/blog/lobin-2437928

 

 

0
1
分享到:
评论

相关推荐

    三菱LD75定位模块PLC教程 LD75P1 LD75P4 LD75D1 LD75D4定位模块控制伺服步进教程教学+LD75中文手册+程序案例.zip

    三菱L系列PLC教程 LD75P LD75D124定位模块控制伺服步进教程教学+程序案例+手册资料 目录 全套教程260分钟。4个小时学完 LD75 模块接线,参数设置,程序编写 一整套教程 第1集 LD75模块介绍讲解 第2集 LD75模块接线...

    ld3320+stm原理图.rar_LD3320_LD3320语音识别_ld32原理_ld3320原理图_stm32硬件原理图

    《LD3320与STM32硬件交互的深度解析》 在电子设计领域,语音识别技术的应用越来越广泛,尤其是在物联网(IoT)设备中。本文将深入探讨LD3320语音识别芯片与STM32微控制器的硬件连接与交互,通过分析提供的“ld3320+...

    LD结果分析向导

    **LD(Linkage Disequilibrium)结果分析向导** LD,即连锁不平衡,是遗传学中一个关键概念,用于描述在基因组中两个或多个等位基因之间非随机的共分离现象。这种不平衡通常发生在染色体上的基因座,表明它们在群体...

    LD3320模块语音识别驱动

    **LD3320模块语音识别驱动** 在嵌入式系统设计中,语音识别技术已经变得越来越重要,尤其是在物联网和智能家居领域。LD3320是一款高性能、低功耗的语音识别芯片,常用于实现简单命令的语音控制功能。本文将深入探讨...

    三菱L系列PLC教程 LD75P LD75D124定位模块控制伺服步进教程教学 带LD75中文手册.zip

    LD75 模块接线,参数设置,程序编写 一整套教程 第1集 LD75模块介绍讲解 第2集 LD75模块接线讲解 第3集 LD75参数详细设置讲解 第4集 LD75 P系列 程序例子讲解 第5集 LD75 D系列 程序例子讲解 第6集 PSTRT指令例子...

    三菱LD77MS中文手册

    【三菱LD77MS中文手册】是一份详细的技术文档,主要针对三菱的L系列LD77MS型简单运动模块,同时也涵盖了与Q/L系列相关的QD77MS、QD77GF以及LD77MH简单运动模块在同步控制方面的应用。这份手册是定位控制和同步控制...

    ld中文手册完全版(带目录).pdf

    GCC 链接器 ld 的中文手册完全版 GCC 链接器 ld 是 GNU 编译器套件中的一个重要组件,它负责将编译后的目标文件链接成一个可执行文件。在这个手册中,我们将详细介绍 ld 的语法、格式和使用方法。 概述 -------- ...

    0-LD3320A语音识别-SPI接口 资料(绿深旗舰店),ld3320a语音识别模块,C,C++文档

    【标题】"0-LD3320A语音识别-SPI接口 资料(绿深旗舰店)"涉及的核心技术是LD3320A语音识别模块,它是一款基于SPI接口的语音处理芯片,常用于智能家居、人机交互等领域。这款模块支持C和C++编程语言,使得开发者能够...

    LD3320芯片资料

    **LD3320芯片详解** LD3320是一款专为语音识别和处理而设计的高性能、低功耗的集成电路。它集成了多种功能,包括数字信号处理器(DSP)、模数转换器(ADC)、数模转换器(DAC)以及音频编解码器,为嵌入式语音应用...

    LD50计算方法

    ### LD50计算方法详解 #### 一、引言 LD50(Lethal Dose, 50%)是指在一定时间内,通过特定途径使群体中的50%个体出现死亡现象所需的物质剂量,是衡量物质毒性大小的重要指标之一。LD50计算方法在毒理学研究中占有...

    MSp430F5438操作LD3320

    **MSp430F5438操作LD3320** 在嵌入式系统设计中,语音识别是一项关键的技术,它使设备能够理解和响应人类的语言指令。本主题将详细探讨如何使用TI(德州仪器)的微控制器MSP430F5438与LD3320语音识别模块进行集成,...

    LD3320 语音识别模块软硬件资料包括参考设计原理图+STM32软件DEMO源码+技术文档资料.zip

    LD3320 语音识别模块软硬件资料包括参考设计原理图+STM32软件DEMO源码+技术文档资料 void LD3320_main(void) { uint8 nAsrRes=0; LD3320_init(); printf("1、流水灯\r\n"); printf("2、闪烁\r\n"); ...

    GUN+ld中文使用手册

    《GUN+ld中文使用手册》是一份专为程序员和系统管理员编写的详细教程,它深入浅出地介绍了如何在GNU环境下使用ld链接器来构建和管理程序。这份手册不仅覆盖了ld的基本用法,还涵盖了高级特性,是学习和掌握ld链接器...

    LD3320 STm32驱动

    【LD3320简介】 LD3320是一款由STMicroelectronics(意法半导体)公司生产的高性能语音识别芯片,专为低功耗、低成本的嵌入式应用设计。这款芯片集成了数字信号处理(DSP)功能,可以实现离线语音识别,无需依赖...

    LD3320语音识别完整资料(PCB、原理图、程序).zip

    《LD3320语音识别技术深度解析及应用实践》 在现代电子设备中,语音识别技术已经成为人机交互的重要手段。本资料包——"LD3320语音识别完整资料(PCB、原理图、程序).zip",为我们提供了一个基于LD3320语音识别...

    LD3320语音识别模块

    **LD3320语音识别模块**是一款专用于语音识别的集成电路,广泛应用于智能家居、智能玩具、安防系统等领域。此模块基于LD3320芯片,该芯片具有高识别率和低功耗的特点,能够实现特定关键词或命令的语音识别功能。 **...

    B-LD3320语音识别模块程序

    【B-LD3320语音识别模块程序】是一个经过测试并证明功能完善的代码资源,专为使用B-LD3320语音识别模块而设计。这个模块在语音处理领域有着广泛的应用,如智能家居、人机交互、智能安防等场景。下面我们将详细探讨B-...

    LD3320语音控制板(原理图、PCB)AD版

    《LD3320语音控制板:探索与解析》 LD3320是一款专用于语音识别和控制的集成电路,广泛应用于智能家居、智能音箱、车载娱乐系统等领域。本篇文章将深入探讨这款芯片以及与其相关的“LD3320语音控制板”的设计原理和...

    IPM马达的Ld-Lq电感计算

    IPM(内嵌式永磁同步电机)马达的Ld-Lq电感计算是针对电机控制参数的精确测定,其中Ld代表直轴电感,Lq代表交轴电感。在电机控制中,Ld和Lq对电机的性能和转矩控制有着直接的影响。PMSM(永磁同步电机)作为一种高效...

Global site tag (gtag.js) - Google Analytics