unexpected reloc type问题分析
1.现象,程序在启动的时候报如下错误
error while loading shared libraries: /home/test/lib/libtest.so: unexpected reloc type 0x03
2.分析,可以通过readelf进行查看依赖的目标文件是否存在non-pic情况,对比新旧版本
readelf -d libtest.so|grep TEXTREL
PIC:Position Independent Code.
有TEXTREL说明该目标文件是non-PIC, 没有则是PIC的,PIC的动态链接库不会含有任何代码段重定位表,TEXTREL即代码段重定位表
指令跳转 数据访问
模块内部: 相对跳转和调用 相对地址访问
模块外部: 间接跳转和调用(GOT) 间接访问(GOT)
注:-fPIC和-fpic区别在于-fpic产生的代码小,执行速度快。但是-fpic在某些平台上会有限制,因为地址无关代码是硬件平台相关的。比如全局符号的数量、代码长度等。-fPIC则没有这种限制。
non-PIC在使用-fPIC选项会出现问题
libtest.so.new
Dynamic section at offset 0x19d928 contains 37 entries:
Tag Type Name/Value
0x00000003 (PLTGOT) 0x1a2280
0x00000002 (PLTRELSZ) 11936 (bytes)
0x00000017 (JMPREL) 0x211b8
0x00000014 (PLTREL) REL
0x00000011 (REL) 0x1e020
0x00000012 (RELSZ) 12696 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffa (RELCOUNT) 341
0x00000006 (SYMTAB) 0x158
0x0000000b (SYMENT) 16 (bytes)
0x00000005 (STRTAB) 0xa3a8
0x0000000a (STRSZ) 55275 (bytes)
0x6ffffef5 (GNU_HASH) 0x17b94
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libglib-2.0.so.0]
0x00000001 (NEEDED) Shared library: [librt.so.1]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
...
0x0000000c (INIT) 0x24058
0x0000000d (FINI) 0xe2138
0x00000019 (INIT_ARRAY) 0x19f328
0x0000001b (INIT_ARRAYSZ) 16 (bytes)
0x0000001a (FINI_ARRAY) 0x19f338
0x0000001c (FINI_ARRAYSZ) 4 (bytes)
0x00000016 (TEXTREL) 0x0
0x0000001e (FLAGS) TEXTREL
0x6ffffff0 (VERSYM) 0x1caf8
0x6ffffffc (VERDEF) 0x1df44
0x6ffffffd (VERDEFNUM) 1
0x6ffffffe (VERNEED) 0x1df60
0x6fffffff (VERNEEDNUM) 5
0x00000000 (NULL) 0x0
libtest.so.old
Dynamic section at offset 0x1915c0 contains 35 entries:
Tag Type Name/Value
0x00000003 (PLTGOT) 0x195f18
0x00000002 (PLTRELSZ) 11968 (bytes)
0x00000017 (JMPREL) 0x20630
0x00000014 (PLTREL) REL
0x00000011 (REL) 0x1d4b0
0x00000012 (RELSZ) 12672 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffa (RELCOUNT) 341
0x00000006 (SYMTAB) 0x158
0x0000000b (SYMENT) 16 (bytes)
0x00000005 (STRTAB) 0x9e38
0x0000000a (STRSZ) 54259 (bytes)
0x6ffffef5 (GNU_HASH) 0x1722c
...
0x0000000c (INIT) 0x234f0
0x0000000d (FINI) 0xd482c
0x00000019 (INIT_ARRAY) 0x192fb0
0x0000001b (INIT_ARRAYSZ) 16 (bytes)
0x0000001a (FINI_ARRAY) 0x192fc0
0x0000001c (FINI_ARRAYSZ) 4 (bytes)
0x6ffffff0 (VERSYM) 0x1c038
0x6ffffffc (VERDEF) 0x1d3d4
0x6ffffffd (VERDEFNUM) 1
0x6ffffffe (VERNEED) 0x1d3f0
0x6fffffff (VERNEEDNUM) 5
0x00000000 (NULL) 0x0
执行如下命令查看目标文件的重定向类型,存在R_ARM_REL32说明定向存在偏移,
如果存在该重定向类型,还可以看到涉及的function,从这个function判断该功能出自哪个库
readelf -r libtest.so|grep R_ARM_REL32
如果使用-fPIC,这个函数的重定向类型是R_ARM_GLOB_DAT
3.解决,用新的编译工具使用-fPIC(-fpic -pie)选项重新编译相关依赖库文件,依赖库目标文件避免出现TEXTREL标识。
unexpected reloc type问题分析的更多相关文章
- Spring Cloud / Spring Boot There was an unexpected error (type=Unauthorized, status=401). Full authentication is required to access this resource.
访问EndPoint时会出现没有权限 There was an unexpected error (type=Unauthorized, status=401). Full authenticat ...
- spring security There was an unexpected error (type=Forbidden, status=403).
https://blog.csdn.net/qq_27093097/article/details/83190240 spring security There was an unexpected e ...
- There was an unexpected error (type=Method Not Allowed, status=405). Request method 'POST' not supported
背景:点击提交按钮ajax请求接口时,报出错误[ Whitelabel Error Page This application has no explicit mapping for /error, ...
- SpringBoot-provider-JPA Not a managed type 问题分析及解决办法
spring boot jpa-java.lang.IllegalArgumentException: Not a managed type异常问题解决方法 JPA实体类没有被扫描到,导致这样的情况有 ...
- 启动Springboot 报错 Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Sat Jan 12 15:50:25 CST 2019 There was an unexpected error (type=Not
解决方案:http://www.cnblogs.com/michaelShao/p/6675186.html
- 【FFMPEG】【ARM-Linux开发】arm上安装FFMPEG
交叉编译工具下载地址 : https://launchpad.net/linaro-toolchain-binaries/+download 其中我下载的是 : gcc-linaro-arm-linu ...
- jQuery静态方法type使用和源码分析
jQuery.type方法是检测数据类型的工具方法,在分析其用法之前先总结下js给我们提供了那些监测数据类型的方法: 一.typeof 操作符 下面是测试代码 var data=[],a='123', ...
- 8、SpringMVC源码分析(3):分析ModelAndView的形成过程
首先,我们还是从DispatcherServlet.doDispatch(HttpServletRequest request, HttpServletResponse response) throw ...
- 7、SpringMVC源码分析(2):分析HandlerAdapter.handle方法,了解handler方法的调用细节以及@ModelAttribute注解
从上一篇 SpringMVC源码分析(1) 中我们了解到在DispatcherServlet.doDispatch方法中会通过 mv = ha.handle(processedRequest, res ...
随机推荐
- 【学习笔记】2017年7月18日MySQL测试:模拟QQ数据库
模拟测试: QQ数据库管理 一.创建数据库并添加关系和测试数据 ##创建QQ数据库,完成简单的测试 #创建数据库 DROP DATABASE IF EXISTS MyQQ; CREATE DATABA ...
- SharePoint Designer - View
1. 数据视图 可以将图片.新闻等列表(如: Announcement)用以下视图显示,具体做法可以参考这篇文章,但需要强调几个地方: 1.1 选择了视图样式后,需要点击“自定义” --> &q ...
- 【2015 Week Task】
2015 第17周 task:项目语音识别技术整理 2015 第18周 task:项目key技术整理
- 创建Spark镜像文件
创建Spark镜像文件 1.将spark容器提交到新的镜像中 $>docker commit 01a25bdf1499 myrepos:centos-spark 2.将centos-spark镜 ...
- May 22nd 2017 Week 21st Monday
The biggest adventure you can take is to live the life of your dreams. 你能经历的最大的冒险,就是过上你梦想的生活. Just l ...
- May 16th 2017 Week 20th Tuesday
The most fearful enemy is not having a firm conviction. 最可怕的敌人,就是没有坚强的信念. A firm conviction or belie ...
- Git warning push.default is unset
warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple ...
- mobile easyui兼容实体数据(tree插件为例)
ORM的实体类和数据库的类是一一对应的,如果有多级的嵌套循环json返回到前台为了方便展示可以使用mobile easyui,但是mobile easyui又需要特定的属性才可以,比如id,text, ...
- 成都夏季招聘会IT行业缺口大!
上个周末成都的夏季招聘会在新会展中心举行,我们传智播客的专业市场调查员也深入当中.了解IT行业招聘情况,我们发如今IT软件行业专区招聘的公司特别多,可是去应聘的人却非常少.这意味着IT行业正处于供不应 ...
- [ZJOI2012]小蓝的好友
https://www.luogu.org/problemnew/show/P2611 题解 \(n\times m\)肯定过不去.. 我们把给定的点看做障碍点,考虑先补集转化为求全空矩阵. 然后我们 ...