zoukankan      html  css  js  c++  java
  • fpic 和 fPIC

    fpic 和 fPIC 区别

    Code Gen Options (Using the GNU Compiler Collection (GCC))

    综下所述,生成适用于共享库的位置无关代码(PIC)时,为了避免对全局偏移表(GOT)的大小进行任何限制,还是使用 -fPIC 参数吧。

    Code Gen Options (Using the GNU Compiler Collection (GCC))

    -fpic
    

    Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that -fpic does not work; in that case, recompile with -fPIC instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k on the m68k and RS/6000. The x86 has no such limit.)

    Position-independent code requires special support, and therefore works only on certain machines. For the x86, GCC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent.

    When this flag is set, the macros __pic__ and __PIC__ are defined to 1.

    如果目标机器支持,生成适用于共享库的位置无关代码 (PIC)。此类代码通过全局偏移表 (GOT) 访问所有常量地址。动态加载器在程序启动时解析 GOT 条目(动态加载器不是 GCC 的一部分;它是操作系统的一部分)。如果链接的可执行文件的 GOT 大小超过机器特定的最大大小,您会从链接器收到一条错误消息,指出 -fpic不起作用;在这种情况下,用-fPIC替代进行重新编译。(这些最大值在 SPARC 上是 8k,在 AArch64 上是 28k,在 m68k 和 RS/6000 上是 32k。x86 没有这样的限制。)

    位置无关代码需要特殊支持,因此只能在某些机器上工作。对于 x86,GCC 支持 System V 的 PIC,但不支持 Sun 386i。为 IBM RS/6000 生成的代码始终与位置无关。

    设置此标志后,宏__pic____PIC__ 定义为 1。

    -fPIC
    

    If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on AArch64, m68k, PowerPC and SPARC.

    Position-independent code requires special support, and therefore works only on certain machines.

    When this flag is set, the macros __pic__ and __PIC__ are defined to 2.

    如果目标机器支持,则发出位置无关代码,适用于动态链接并避免对全局偏移表的大小进行任何限制。此选项在 AArch64、m68k、PowerPC 和 SPARC 上有所不同。

    位置无关代码需要特殊支持,因此只能在某些机器上工作。

    设置此标志后,宏__pic____PIC__ 定义为 2。

  • 相关阅读:
    C#中的委托,匿名方法和Lambda表达式
    Java 8 Lambda表达式探险
    Lambda表达式有何用处?如何使用?
    有参数的程序,可以被调用
    怎样用VB编写.DLL动态链接库文件
    Oracle 存储过程包
    EB(存储单位)
    排序之快速排序(上)
    排序之冒泡排序
    排序之堆排序
  • 原文地址:https://www.cnblogs.com/ltimaginea/p/14905474.html
Copyright © 2011-2022 走看看