R_ARM_THM_CALL error

1,538 views
Skip to first unread message

鹏飞 吴

unread,
Apr 13, 2010, 7:00:40 AM4/13/10
to android-ndk
hi~ I build c/c++ by using ndk toolchain. I get errors as following:
arm-eabi/lib/libc.a(atexit.o): In function `__cxa_finalize':
bionic/libc/stdlib/atexit.c:145: relocation truncated to fit:
R_ARM_THM_CALL against symbol `memcpy' defined in .plt section in obj/
Release/main.o
bionic/libc/stdlib/atexit.c:146: relocation truncated to fit:
R_ARM_THM_CALL against symbol `mprotect' defined in .plt section in
obj/Release/main.o
ionic/libc/stdlib/atexit.c:148: relocation truncated to fit:
R_ARM_THM_CALL against symbol `mprotect' defined in .plt section in
obj/Release/main.o
....
..
I have no idea about these errors. Could someone help me?

Mustapha Tachouct

unread,
Apr 13, 2010, 10:59:11 AM4/13/10
to andro...@googlegroups.com
Hi,

"R_ARM_THM_CALL" is used for the relocation process in ELF file format (*.o . or *.so) for ARM platform. 'memcpy' and 'mprotect' symbols are maybe multiple defined.

Mustapha


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


David Turner

unread,
Apr 13, 2010, 7:13:23 PM4/13/10
to andro...@googlegroups.com
How are you generating code that statically links to the C library ? What are your linker flags ?

For the record, your final library is too large to accomodate the thumb BL/BLX instructions in the C library that, for some odd reason, the linker tries to resolve to exported symbols in your own code.

鹏飞 吴

unread,
Apr 14, 2010, 9:46:22 PM4/14/10
to android-ndk
I use ndk-r3's tool-chain to compile my code, and I have generated
static library.But when linking these static libraries to executable
file, I get above errors.
My compile flags are:
-fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-
enums -fomit-frame-pointer
My linker flags are:-nostdlib -Bdynamic
-Wl,-T,armelf.x
-Wl,-dynamic-linker,/system/bin/linker
..\..\android-toolchain\BUILD\arm-eabi\lib\crtbegin_dynamic.o
..\..\android-toolchain\BUILD\arm-eabi\lib\crtend.o

How can I resolve this problem?

> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr­oups.com>


> > .
> > For more options, visit this group at

> >http://groups.google.com/group/android-ndk?hl=en.- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

David Turner

unread,
Apr 15, 2010, 12:53:57 AM4/15/10
to andro...@googlegroups.com
You should not be trying to use the toolchain directly like this, you are not giving enough information anyway.

To solve your problem, try using -fPIC instead of -fpic, another option is to build 32-bit ARM machine code, instead of 16-bit Thumb one.
What is strange is that the bug is trying to resolve C library functions to .plt entries to another library, I really don't know why but I suspect your final link command is all strange.

Finally, you seem to want to generate a static executable. This is not really supported in Android.

Really, you should use the NDK build system instead.

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

吴鹏飞

unread,
Apr 22, 2010, 11:06:46 PM4/22/10
to andro...@googlegroups.com
Now, I use NDK build system instead and there is no such problem any more.
yes. It's unwise to use the toolchain directly.

2010/4/15 David Turner <di...@android.com>
Reply all
Reply to author
Forward
0 new messages