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. 关于IDEA无法加载main方法的bug

    问题现象 main方法没有run按钮 问题解决 发现args显示灰色未调用,原来是之前莫名其妙调用了sun包下的String 删除调用问题解决!

  2. openresty lua-resty-redis 封装 a wrapper for lua-resty-redis 优雅一点点

    搜了一下别人的封装代码,感觉不够优雅,主要是 set_keepalive 的调用时机不太好 我自己下面的代码是利用 coroutine, 每次当前 phase 结束后自动调用 set_keepaliv ...

  3. Docker小白到实战之Dockerfile解析及实战演示,果然顺手

    前言 使用第三方镜像肯定不是学习Docker的最终目的,最想要的还是自己构建镜像:将自己的程序.文件.环境等构建成自己想要的应用镜像,方便后续部署.启动和维护:而Dockerfile就是专门做这个事的 ...

  4. Django——Paginator分页功能练习

    1.路由urls.py from django.contrib import admin from django.urls import path from app01.views import in ...

  5. Docker下制作一个容器镜像

    操作过程描述: (1)先基于centos的镜像启动一个centos容器 (2)在这个容器中安装nginx (3)然后把这个已经安装了nginx的容器制作成一个docker的镜像 操作:docker c ...

  6. Python中正则表达式简介

    目录 一.什么是正则表达式 二.正则表达式的基础知识 1. 原子 1)普通字符作为原子 2)非打印字符作为原子 3) 通用字符作为原子 4) 原子表 2. 元字符 1)任意匹配元字符 2)边界限制元字 ...

  7. Linux proc文件系统小记

    序言: 当linux系统存在多个网口时(也可以是一个网口配置两个IP),每个网口配置不同的IP地址,并且分别连接到不同的电脑上,电脑分别配置与相连的网口统一网段的IP且将电脑网关设置为linux的网口 ...

  8. IPsec 9个包分析(主模式+快速模式)

    第一阶段:ISAKMP协商阶段 1.1 第一包 包1:发起端协商SA,使用的是UDP协议,端口号是500,上层协议是ISAKMP,该协议提供的是一个框架,里面的负载Next payload类似模块,可 ...

  9. Reader字符输入流和InputStreamReader和FileReader

    1.FileReader  extends InputStreamReader extends Reader 其中,Reader字符输入流和InputStreamReader和FileReader为字 ...

  10. CommonsBeanutils1 分析笔记

    1.PropertyUtils.getProperty commons-beanutils-1.9.2.jar 包下的 PropertyUtils#getProperty方法相对于getXxx方法,取 ...