How to link libc.a to a shared library in arm-linux use arm-none-linux-gnueabi-gcc

In a project, my colleague creates a static library, such as liba.a, associated with the application.

In liba.a, it overwrites libc malloc () for its owner version.

I am creating a shared library, libs.so, which is also associated with the application.

The problem is that my libs.so is associated with the application, malloc (), which is used in my libs.so, will be in liba.a, and not in the standard libc.so, this causes problems.

Then, I want the libc.a static link to my libs.so, I used the -static -shared -fPIC flags for gcc.

But I always get arm-2012.03 / bin /../ lib / gcc / arm-none-linux-gnueabi / 4.6.3 /../../../../ arm-none-linux- gnueabi / bin / ld: arm-2012.03 / bin /../ arm-none-linux-gnueabi / libc / usr / lib / libc.a (dl-tsd.o) (. text + 0x14): R_ARM_TLS_LE32 movement is not allowed in the shared object .

Does anyone have an idea about this?

Thank.

+5
source share
1 answer

You cannot, because the code that goes in the shared library must be compiled with -fPIC, and the code in the static libraries should not. If you were able to do this, the resulting executable would eventually contact libc several times, which would be very fragile anyway and most likely crash sooner or later, so you shouldn't do this anyway. Therefore:

. , , , .

, GNU libc -GPL- , LGPL . , . Linux bugfixed ; libc , .

+2

All Articles