Friday I was taking two 3rd party static libraries, add an API layer around it, and repackage it into a shared library. This shared library will allow us to be vendor agnostic and swap in and out with other implementations as necessary.
All was working as planned until I ran into the following compile warning: (The so library still compiled.)
libc.a(malloc.o)(.text+0xe0): R_ARM_TLS_LE32
relocation not permitted in shared object
When I tried to include library statically, it pulled in the static C library into my shared library. The static C library contains relocations that cannot be used in a shared library.
Some online article suggested recompiling the gcc with the "--disable-libmudflap" will fix the problem.
For me, I just need to link the libc dynamic instead of shared. So in my LDFLAGS, I added -Wl -Bstatic in front of my two static libs and -Wl -Bdynamic afterward. Problem solved.
Hello. I ran into this same error, and after trying your suggestion (and some other approaches). None of the approaches worked for me. I found I only had to remove the '-static' flag from the compiler flags and no other flags were required. I initially thought I need '-static' for compilation, but it turns out I did not.
ReplyDeleteNot sure if this applies to your project, but it was much easier than the alternative approaches.
I searched thousands of places for an answer, and for 2 days I didn't find anything plausible.. and here in a 2012 answer of yours, I find something very simple.. which was just removing the "static" when compiling, \o/ , verrry thanks
DeleteSame here bduhbya, removing the -static flag from my LDFLAGS fixed the relocation issue. Need some more thought onto why...
ReplyDelete