Options for Linking(For GCC version 11.2.0)

-nostdinc  (3.16 Options for Directory Search)

    Do not search the standard system directories for header files. Only the directories
explicitly specified with ‘-I’, ‘-iquote’, ‘-isystem’, and/or ‘-idirafter’options (and the directory of the current file, if appropriate) are searched.

-nostartfiles  (3.15 Options for Linking)

    Do not use the standard system startup files when linking. The standard system
libraries are used normally, unless ‘-nostdlib’, ‘-nolibc’, or ‘-nodefaultlibs’ is used.

-nodefaultlibs  (3.15 Options for Linking)

    Do not use the standard system libraries when linking. Only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries, such as ‘-static-libgcc’ or ‘-shared-libgcc’, are ignored. The standard startup files are used normally, unless ‘-nostartfiles’ is used.

    The compiler may generate calls to memcmp, memset, memcpy and memmove.These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified.

 -nostdlib  (3.15 Options for Linking)

    Do not use the standard system startup files or libraries when linking. No startup files and only the libraries you specify are passed to the linker, and options specifying linkage of the system libraries, such as ‘-static-libgcc’ or ‘-shared-libgcc’, are ignored.
    The compiler may generate calls to memcmp, memset, memcpy and memmove. These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified. One of the standard libraries bypassed by ‘-nostdlib’ and ‘-nodefaultlibs’ is ‘libgcc.a’, a library of internal subroutines which GCC uses to overcome shortcomings of particular machines, or special needs for some languages. (See Section “Interfacing to GCC Output” in GNU Compiler Collection (GCC) Internals, for more discussion of ‘libgcc.a’.) In most cases, you need ‘libgcc.a’ even when you want to avoid other standard libraries. In other words, when you specify ‘-nostdlib’ or ‘-nodefaultlibs’ you should usually specify ‘-lgcc’ as well. This ensures that you have no unresolved references to internal GCC library subroutines. (An example of such an internal subroutine is __main, used to ensure C++ constructors are called; see Section “collect2” in GNU Compiler Collection (GCC) Internals.)

-ffunction-sections, -fdata-sections  (3.11 Options That Control Optimization)

    Place each function or data item into its own section in the output file if the target supports arbitrary sections. The name of the function or the name of the data item determines the section’s name in the output file.
    Use these options on systems where the linker can perform optimizations to improve locality of reference in the instruction space. Most systems using the ELF object format have linkers with such optimizations. On AIX, the linker rearranges sections (CSECTs) based on the call graph. The performance impact varies.
    Together with a linker garbage collection (linker ‘--gc-sections’ option) these options may lead to smaller statically-linked executables (after stripping).
    On ELF/DWARF systems these options do not degenerate the quality of the debug information. There could be issues with other object files/debug info formats.
    Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker create larger object and executable files and are also slower. These options affect code generation. They prevent optimizations by the compiler and assembler using relative locations inside a translation unit since the locations are unknown until  link time. Anexample of such an optimization is relaxing calls to short call instructions.

-specs=file  (3.2 Options Controlling the Kind of Output)

Process file after the compiler reads in the standard ‘specs’ file, in order to override the defaults which the gcc driver program uses when determining what switches to pass to cc1, cc1plus, as, ld, etc. More than one ‘-specs=file’ can be specified on the command line, and they are processed in order, from left to right. See Section 3.20 [Spec Files], page 472, for information about the format of the file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值