当前位置:网站首页>Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
2022-07-06 08:33:00 【Hongyi】
The author didn't pay special attention to fPIC and fpic The difference between , Recently aarch64 A problem encountered in compiling on the server , Let yourself make a good inquiry of some information , Perhaps ordinary developers are not easy to encounter it , I hope it will be of some help to readers who are destined .
1) When dynamic library is out , Merge libnettle.a The library encountered the following error prompt
/data/compilerdir/bin/opensdk/linux64/lib/libnettle.a(fat-arm64.o): in function `fat_init': /data2/compilerdir/nettle/fat-arm64.c:198:(.text.startup+0x184): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `_nettle_aes192_decrypt_c' defined in .text section in /data/compilerdir/bin/opensdk/linux64/lib/libnettle.a(aes192-decrypt.o)
/usr/bin/ld: /data/compilerdir/nettle/fat-arm64.c:198: warning: too many GOT entries for -fpic, please recompile with -fPIC
collect2: error: ld returned 1 exit status
/data2/compilerdir/bin/libhyscoder.so] Error 1
The key tips are
warning: too many GOT entries for -fpic, please recompile with -fPIC
Verified fpic and fPIC Compare
The same thing : Is to generate location independent code in the dynamic library . Through global offset table (GOT) Access all constant addresses . Dynamically load the program when the program starts GOT entry .
Difference : If the linked executable GOT The size exceeds the maximum value specified by the computer architecture , An error message will be reported in the compilation link , Tips -fpic It doesn't work ; So in this case , Need to use -fPIC recompile .GOT The size varies with the chip architecture ,SPARC Up for 8k, stay AArch64 Up for 28k( What the author meets is it ,GOT Limit exceeded , So wrong reporting ), stay m68k and RS / 6000 Up for 32k. and x86 There is no such restriction on .
Tips
In order to ensure the overall availability of the program during cross platform compilation , Usually, it is suggested to use fPIC
Reference source address
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
The original English text ( If the above address cannot be accessed , You can refer to the following original )
-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.
-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.
边栏推荐
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Image, CV2 read the conversion and size resize change of numpy array of pictures
- Let the bullets fly for a while
- Day29-t77 & t1726-2022-02-13-don't answer by yourself
- 2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers
- Double pointeur en langage C - - modèle classique
- leetcode刷题 (5.29) 哈希表
- tree树的精准查询
- Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
- Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
猜你喜欢
【MySQL】数据库的存储过程与存储函数通关教程(完整版)
Bottom up - physical layer
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
egg. JS getting started navigation: installation, use and learning
MySQL learning record 10getting started with JDBC
marathon-envs项目环境配置(强化学习模仿参考动作)
Ruffian Heng embedded bimonthly, issue 49
tree树的精准查询
Double pointeur en langage C - - modèle classique
The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
随机推荐
2022.02.13 - NC003. Design LRU cache structure
The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
LDAP应用篇(4)Jenkins接入
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Analysis of pointer and array written test questions
egg. JS project deployment online server
从表中名称映射关系修改视频名称
【刷题】牛客网面试必刷TOP101
pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof
visdom可视化实现与检查介绍
Fibonacci sequence
How to conduct interface test? What are the precautions? Nanny level interpretation
China polyether amine Market Forecast and investment strategy report (2022 Edition)
Synchronized solves problems caused by sharing
2022.02.13 - NC004. Print number of loops
Research and investment forecast report of citronellol industry in China (2022 Edition)
角色动画(Character Animation)的现状与趋势
logback1.3. X configuration details and Practice
win10系统中的截图,win+prtSc保存位置
leetcode刷题 (5.28) 哈希表