unexpected reloc type 0x03

£可爱£侵袭症+ 提交于 2019-12-05 16:34:54

From https://lists.linaro.org/pipermail/linaro-toolchain/2012-November/002939.html :

Relocation type 3 is R_ARM_REL32 which is a static relocation not allowed in shared objects. How did you create the shared lib? Make sure you compile all the code going into it with -fPIC.

In other words, you are using -fPIC when linking your program, but perhaps not when building your shared library.

Regarding:

./a.out 
./a.out: error while loading shared libraries: ../../lib-arm/libCustomLibrary.so: unexpected reloc type 0x03

I think you need to show the relevant source code for libCustomLibrary.so. You can see which symbol is causing the problem with:

LD_DEBUG=all ./a.out

After the verbose output, the last symbol mentioned will be the problem. For example, testing Cryptogams SHA, which is hand written asm, in a shared object results in:

10419:     relocation processing: /home/test/libcryptopp-8.3.0.so.8 (lazy)
10419:     symbol=CRYPTOGAMS_armcaps;  lookup in file=/home/test/libcryptopp.so.8 [0]
10419:     binding file /home/test/libcryptopp.so.8 [0]: normal symbol `CRYPTOGAMS_armcaps'
/home/test/: error while loading shared libraries: /home/test/libcryptopp.so.8: unexpected reloc type 0x03

So I know the problem is with the CRYPTOGAMS_armcaps symbol. You can confirm with objdump -r. R_ARM_REL32 is symbol type 0x03.

$ objdump -r sha1-armv4.o

sha1-armv4.o:     file format elf32-littlearm

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
000004d0 R_ARM_REL32       CRYPTOGAMS_armcaps

Then you can go back to the source file and fix the problem with the symbol.

Also, from Crypto++ Issue 846, ARM and "unexpected reloc type 0x03" loading shared object, I know it is not as simple as using -fPIC. Everything was built with -fPIC and the problem still surfaced.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!