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。
fpic 和 fPIC的更多相关文章
- How can I set ccshared=-fPIC while executing ./configure?
解决方式如下: make clean ./configure CFLAGS=-fPIC CXXFLAGS=-fPIC
- GCC中-fpic解惑(转载)
参考: 1.<3.18 Options for Code Generation Conventions>2.<Options for Linking>3.<GCC -fP ...
- linux下共享库的注意点之-fpic
在编译共享库必须加上-fpic.这是为什么呢? 首先看一个简单的例子: #include <stdio.h> int fun1() { printf("fun1\n") ...
- 关于/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也是一窍不通因此本人也是不想去积极的解决这个问题,但是当你求助无缘的时候你才会静心去思考.读到这句话的时候也许你已经发现了问题所 ...
- gcc编译参数-fPIC的一些问题
gcc编译参数-fPIC的一些问题 (2012-07-26 15:41:08) 转载▼ 标签: linux compiler gcc -fpic it 分类: NSN_BspDriver ppc_85 ...
- Linux共享对象之编译参数fPIC
最近在看Linux编程的基础知识,打算对一些比较有趣的知识做一些汇总备忘,本文围绕fPIC展开,学习参考见文末. 在Linux系统中,动态链接文件称为动态共享对象(DSO,Dynamic Shared ...
- Linux下生成动态链接库是否必须使用 -fPIC 的问题[转]
在 Linux 下制作动态链接库,“标准” 的做法是编译成位置无关代码(Position Independent Code,PIC),然后链接成一个动态链接库.经常遇到的一个问题是 -fPIC 是不是 ...
- 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 ...
- Python 出现需要使用fPIC重新编译的问题
在已经存在python安装环境的情况下,当安装第三方的包的时候出现报错提示 /usr/bin/ld: .../lib/libpython2.7.a(abstract.o): relocation R_ ...
随机推荐
- 博观约取系列 ~ 探测Bert Finetune对向量空间的影响
熟悉NLP的同学对Bert Finetune一定不陌生,基本啥任务上来都可以Bert Finetune试一把.可是模型微调一定比直接使用预训练模型效果好么?微调究竟对Bert的向量空间产生了哪些影响嘞 ...
- 迭代器生成器阅读【Python3.8官网文档】
目录 1.迭代器 2.生成器 2.1.yield 表达式 2.2.简要理解概念 2.3.生成器-迭代器的方法 2.4.生成器理解 2.5.例子 3.生成器表达式 1.迭代器 for element i ...
- 一篇文章搞懂Nginx
Nginx 的产生 Nginx 同 Apache 一样都是一种 Web 服务器.基于 REST 架构风格,以统一资源描述符(Uniform Resources Identifier)URI 或者统一资 ...
- Hash值和位运算
一.Hash 1.md5是hash算法,不可逆,还原的是暴力穷举的方式解析的:加盐之后穷举也不能还原: 2.压缩映射会有重复,即哈希冲突: 二.ConcurrentHashMap 1.putIfAbs ...
- freeswitch python模块
概述 freeswitch支持多种语言的业务开发,包括C/C++,java,python,js,lua,Golang等等.freeswitch在使用python做业务开发时,有俩种接入方式,一种是ES ...
- javassist 使用笔记
javassist Javassist 是一个开源的分析.编辑和创建Java字节码的类库.其主要的优点,在于简单,而且快速.直接使用 java 编码的形式,而不需要了解虚拟机指令,就能动态改变类的结构 ...
- CentOS获取公网IP
Curl 纯文本格式输出: curl icanhazip.com curl ifconfig.me curl curlmyip.com curl ip.appspot.com curl ipinfo. ...
- 跨 Docker 宿主机网络 overlay 类型
跨 Docker 宿主机网络 overlay 类型 前言 a. 本文主要为 Docker的视频教程 笔记. b. 环境为 三台 CentOS 7.0 虚拟机 (Vmware Workstation 1 ...
- 博客主题——element v2
主题预览 主题下载 gshang.element-v2.rar
- javascript 无限分类
* 根据php无限分类实现js版本的 /** * 根节点 parentid=0, 每个节点都有id, parentid字段 * @param items * @returns {*} */ funct ...