Link to home
Start Free TrialLog in
Avatar of w00te
w00teFlag for United States of America

asked on

C++ Text segment relocation error - writing to read only memory

Hey guys,

So... On a pretty beefy project (~15,000 files), I had to start using a new static library.  The static library uses other libraries, etc.  Anyway, everything is in, compliling, etc.

Here's my problem now.  When I run my unit tests on the module using the new library I get a text segment relocation warning followed by a symbol reference and a note of it trying to write to read only memory.

The unit tests literally have nothing whatsoever to do with the portion of the module using the new library (in fact that part isnt even instantiated, the tests are run on a singleton with no dependencies on the part using the library).

Anyway, I'm guessing something about the static libraries is crashing the executable prior to getting to my code, but I don't understand what.  So...

(1) what is a text relocation warning/error?
(2) why would a reference and inclusion to a static library possibly cause one?
(3) why is my executable doing anything with the library when none of its functions or objeects are referenced in the test whatsoever?
(4) why do I ge this error at run instead of compile/link time.

I know that I didn't provide enough information to get specific solutions, but I"m hopeing getting some answers to those 4 questions will help me work this out.  Thanks :)

-w00te
Avatar of w00te
w00te
Flag of United States of America image

ASKER

PS: The makefile for the test executable does include everything the makefile for the real executable includes, whether or not its used.  That's why the library is part of the build in the first place.

-w00te
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of w00te

ASKER

Thanks guys.  I've been going through the libraries and looking for fPIC compiler options and it seems to be everywhere (I ran into into suggestion online yesterday). Our code base and makefiles makes it a little tough to track everywhere so it may take a while assuming that really is the problem. Were cross compiling to a special unix like system so I'm hoping it's not something strange about the system itself. Anyway, I think this is a god solution for the text relocation issue in general so I'm accepting it.  Thanks for the thoughts :)

-w00te