This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: redefining dynamic symbols??? -- why I want to.

On Wed, Jul 17, 2002 at 06:51:24AM -0700, Jorge Luis Williams wrote:
> > On Wed, Jul 17, 2002 at 05:49:52AM -0700, Jorge Luis Williams wrote:
> >> > You'd need to examine the existing code in objcopy that does
> >> > --redefine-sym and switch symbol table reading and writing to use
> >> > the dynamic symbol table.
> >> >
> >>
> >> I thought about doing this, however I was under the understanding that
> >> this wouldn't work because I would also need to recompute the .hash
> >> section
> >
> > Ouch.  I didn't think of that.  You'll find you need to copy/write
> > quite a lot of code to do what you want.  Much easier to recompile
> > whatever applications/shared libs you're trying to tweak.
> >
> Damn -- I'm trying to avoid translating and recompiling c code. Let me
> explain what I'm trying to do -- maybe there's a fancy ld flag that will
> work.
> I  have three libraries lib_b, lib_c, lib_c_copy. lib_c and lib_c_copy
> both define the same dynamic symbols. In fact they are true copies --
> generated from the same code.
> exe_a is dynamicly linked to lib_c and lib_b
> lib_b is dynamicly linked to lib_c_copy
> It seems that when I run exe_a both exe_a and lib_b use the same copy of
> lib_c which causes some problems for what I'm trying to do.   I've tried
> linker flag -Bsymbolic which I understood would prevent this from
> happening, but this doesn't seem to work.

No. -Bsymbolic offects symbols defined in a DSO.

> Another technique is statically linking exe_a to lib_c and lib_b to
> lib_c_copy. This works under linux -- however it's not enough to fool the
> dynamic linker/loader under solaris as here we still use the same copy of
> lib_c.

You can get the same effect on Linux, but it is not the default. Try

# gcc -o exe_a .... -l_c
# gcc -shared -Wl,-Bsymbolic -o .... -l_c

It should work. If not, file a bug report with a small testcase.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]