Re: Many Text Relocations in my Shared Object
From: Gregg Altschul (galtschul_at_factset.com)
Date: 9 Sep 2004 15:29:26 -0700
Seongbae Park <Seongbae.Park@Sun.COM> wrote in message news:<chq0ql$skh$1@news1nwk.SFbay.Sun.COM>...
> Gregg Altschul <email@example.com> wrote:
> > I have a Shared Object which its sole purpose is to create objects of
> > a certain type and return a pointer to the object to the user.
> > Therefore, the user becomes the owner of this object and is resposible
> > for deleting it. It utilizes the factory pattern to create the
> > objects. The problem is that I am finding it nearly impossible to get
> > rid of my Text Relocations. I'm using the -Kpic and -ztext options
> > (which, of course, makes my link-edit fail). Here's the code:
> The code is not self contained, so I can not reproduce your problem.
> > If I get rid of the MsgFactoryImpl instance in IterMapFactory.cxx then
> > all of my text relocations go away altogether. If I leave that line in
> > and comment out the getNewMsg function in the MsgFactory and
> > MsgFactoryImpl classes in MsgFactory.h then I get only a few text
> > relocations.
> > I thoroughly appreciate any help I can get.
> I believe all text relocations would be resolved
> when you link your shared object if compiled with -KPIC/-Kpic
> i.e. .o (even if compiled with -KPIC/-Kpic) would have text relocations,
> but those will get resolved during linking for .so.
> What kind of text relocations do you see in your .so ?
> Did you use CC to link your program ?
Well, I've got good news. It wasn't clear to me that I had to compile
ALL my code with -Kpic/-KPIC in order to get rid of all text
relocations. I gave it a try and my text relocations went away :). I
am, though, left with one small question: If I'm compiling all my
static libraries that eventually get compiled into my shared objects
with 'Kpic/-KPIC, what happens when the same .a's are compiled into