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
PIC:Position Independent Code.
有TEXTREL说明该目标文件是non-PIC, 没有则是PIC的
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_REL说明定向存在偏移,
如果存在该重定向类型,还可以看到涉及的function,从这个function判断该功能出自哪个库
readelf -r libtest.so|grep R_ARM_REL

如果使用-fPIC可能这个函数的重定向是R_ARM_GLOB_DAT

3.解决,用新的编译工具使用-fPIC(-fpic -pie)选项重新编译相关依赖库文件,依赖库目标文件避免出现TEXTREL标识。

原文地址:https://www.cnblogs.com/sciapex/p/9662811.html

时间: 2024-08-30 05:22:29

unexpected reloc type问题分析的相关文章

lucene升级至5.1版本出现 :IllegalStateException: IllegalStateException: unexpected docvalues type NONE"

这前使用的lucene4.7版本,程序正常,现在升级到5.1时,索引文件正常,但在搜索的时候,出现:IllegalStateException: unexpected docvalues type NONE" on fields  Use UninvertingReader or index with docvalues. 后才知道,是因为Sort排序对索引字段有了新的要求,即使用DocValuesField的字段才能进行排序. 查询doc文档,最终解决方法如下: 原来的代码:dfDocumen

There was an unexpected error (type=Not Found, status=404).

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Mon Jan 22 09:30:31 CST 2018 There was an unexpected error (type=Not Found, status=404). No message available 网址Url  输错了, 我的具体如下 http://l

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 error (type=Forbidden, status=403). 原创一大波攻城狮来袭 发布于2018-10-20 00:59:58 阅读数 2904  收藏 展开 原因是定义的角色名称不匹配 路径权限规则匹配中配置的是:ADMIN 这里程序猿不可以配置ROLE_开头的角色 不然直接报BUG 自

springboot 集成jsp问题: There was an unexpected error (type=Not Found, status=404). /WEB-INF/jsp/index.jsp

关于spring boot 集成 jsp 出现的如下问题: There was an unexpected error (type=Not Found, status=404). /WEB-INF/jsp/index.jsp 解决的方法总结如下:  聚合模块(POM)下,如果出现如上故障 : 1.先检查有无漏掉导入 tomcat-embed-jasper  jsp引擎,springboot 内置的tomcat中没有此依赖,如果没有,idea控制台就会输出如下错误代码:   而前台页面则报的错误如

c# 反射时GetType方法查找Type的分析

反射是高级语言里面很强大的一种机制.C#也给我们提供了强大的反射机制.反射使用起来非常简单,最常见的步骤是: 1,定义一个Type 对象, Type myType; 2,通过字符串或者其它流初始化该对象,MyType = Type.GetType("MyClass"); 在Type.GetType()方法执行时,系统怎么根据字符串查找正确的类的定义呢?看下面代码 [c-sharp] view plain copy using System; using System.Collectio

jQuery静态方法type使用和源码分析

jQuery.type方法是检测数据类型的工具方法,在分析其用法之前先总结下js给我们提供了那些监测数据类型的方法: 一.typeof 操作符 下面是测试代码 var data=[],a='123',b=0,c=true,d={1:23},e=[123],f=function(){},g=null,h=undefined,i=Math,j=/$.+^/,k= new Date(); data.push(a,b,c,d,e,f,g,h,i,j,k); for(var key=0;key<data.

spring boot应用启动原理分析

spring boot quick start 在spring boot里,很吸引人的一个特性是可以直接把应用打包成为一个jar/war,然后这个jar/war是可以直接启动的,不需要另外配置一个Web Server. 如果之前没有使用过spring boot可以通过下面的demo来感受下. 下面以这个工程为例,演示如何启动Spring boot项目: git clone [email protected]:hengyunabc/spring-boot-demo.git mvn spring-b

8、SpringMVC源码分析(3):分析ModelAndView的形成过程

首先,我们还是从DispatcherServlet.doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception方法开始,看看这个牛逼的ModelAndView是怎么开始的,又是怎么结束的: 1 protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Except

7、SpringMVC源码分析(2):分析HandlerAdapter.handle方法,了解handler方法的调用细节以及@ModelAttribute注解

从上一篇 SpringMVC源码分析(1) 中我们了解到在DispatcherServlet.doDispatch方法中会通过 mv = ha.handle(processedRequest, response, mappedHandler.getHandler()) 这样的方式来执行request的handler方法. 先来分析一下ha.handle方法的调用过程:HandlerAdapter接口有一个抽象实现类AbstractHandlerMethodAdapter,在该抽象类中通过具体方法