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。

fpic 和 fPIC的更多相关文章

  1. How can I set ccshared=-fPIC while executing ./configure?

    解决方式如下: make clean ./configure CFLAGS=-fPIC CXXFLAGS=-fPIC

  2. GCC中-fpic解惑(转载)

    参考: 1.<3.18 Options for Code Generation Conventions>2.<Options for Linking>3.<GCC -fP ...

  3. linux下共享库的注意点之-fpic

    在编译共享库必须加上-fpic.这是为什么呢? 首先看一个简单的例子: #include <stdio.h> int fun1() { printf("fun1\n") ...

  4. 关于/usr/local/lib/libz.a(zutil.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC解决办法

    具体报错截图如下: 解决方法: 题外话,我对makefill cmake也是一窍不通因此本人也是不想去积极的解决这个问题,但是当你求助无缘的时候你才会静心去思考.读到这句话的时候也许你已经发现了问题所 ...

  5. gcc编译参数-fPIC的一些问题

    gcc编译参数-fPIC的一些问题 (2012-07-26 15:41:08) 转载▼ 标签: linux compiler gcc -fpic it 分类: NSN_BspDriver ppc_85 ...

  6. Linux共享对象之编译参数fPIC

    最近在看Linux编程的基础知识,打算对一些比较有趣的知识做一些汇总备忘,本文围绕fPIC展开,学习参考见文末. 在Linux系统中,动态链接文件称为动态共享对象(DSO,Dynamic Shared ...

  7. Linux下生成动态链接库是否必须使用 -fPIC 的问题[转]

    在 Linux 下制作动态链接库,“标准” 的做法是编译成位置无关代码(Position Independent Code,PIC),然后链接成一个动态链接库.经常遇到的一个问题是 -fPIC 是不是 ...

  8. error: qrc_qml.obj: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC解决办法

    使用qtcreator加androidndk编译项目时报错: error: qrc_qml.obj: requires unsupported dynamic reloc R_ARM_REL32; r ...

  9. Python 出现需要使用fPIC重新编译的问题

    在已经存在python安装环境的情况下,当安装第三方的包的时候出现报错提示 /usr/bin/ld: .../lib/libpython2.7.a(abstract.o): relocation R_ ...

随机推荐

  1. WAMP 2.5 无法访问局域网的解决方法

    打开Apache配置文件 httpd.conf  (该文件在wamp\bin\apache\apache2.4.9\conf) DocumentRoot "d:/wamp/www/" ...

  2. openresty lua_ssl_trusted_certificate 问题

    lua_ssl_trusted_certificate 语法: lua_ssl_trusted_certificate 默认: no 环境: http, server, location 指定一个 P ...

  3. Django使用富文本编辑器ckediter

    1 - 安装 pip install django-ckeditor 2 - 注册APP ckeditor 3 - 由于djang-ckeditor在ckeditor-init.js文件中使用了JQu ...

  4. Appium自动化(12) - 详解 HardwareActions 类里的方法和源码分析

    如果你还想从头学起Appium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1693896.html 前言 HardwareAction ...

  5. Intel® QAT加速卡之加密、哈希操作流程和示例

    Intel QAT 加密API介绍 文章主要讲述了Intel QAT 加密API接口的说明,以及多种应用场景下的使用方法. 文章目录 Intel QAT 加密API介绍 1. 概述 1.1 会话(se ...

  6. docker-compose up -d nginx 报错

    在阿里云ECS上创建nginx容器时,报错如上图. The solution: In your Dockerfile, before running any apt commands, add the ...

  7. AgileConfig轻量级配置中心1.4.0发布,重构了发布功能

    加入 NCC 先说一个事,AgileConfig 在 7 月底终于通过了 NCC 社区的审核,正式成为了 NCC 大家庭的一员.这对 AgileConfig 来说是一个里程碑,希望加入 NCC 后能更 ...

  8. ABP 极简入门教程(三 权限)

    此处演示为MVC项目,同样权限定义需要到Application中才能在获取API时进行权限验证 一.打开Sample.Core\Authorization\PermissionNames.cs增加授权 ...

  9. ABP 极简入门教程(二 MVC方式显示数据)

    增加显示菜单 Sample.Web.MVC项目中找到startup目录打开SampleNavigationProvider.cs,根据现有内容添加以下内容 .AddItem( new MenuItem ...

  10. [源码解析] 深度学习流水线并行 PipeDream(6)--- 1F1B策略

    [源码解析] 深度学习流水线并行 PipeDream(6)--- 1F1B策略 目录 [源码解析] 深度学习流水线并行 PipeDream(6)--- 1F1B策略 0x00 摘要 0x01 流水线比 ...