[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DB3 symbol collisions solved...



On Thu, Nov 16, 2000 at 07:34:39AM +1100, Herbert Xu wrote:
> On Wed, Nov 15, 2000 at 09:38:46AM -0500, Ben Collins wrote:
> > On Wed, Nov 15, 2000 at 08:19:05PM +1100, Herbert Xu wrote:
> >
> > > If I understood this correctly, this means that anything that's compiled
> > > against libdb3-dev and (say) a libsasl7-dev that was linked against
> > > libdb2-dev, will end up just using libdb2.  Is this really OK for all
> > > programs, considering that the soname usually isn't changed unless the ABI
> > > changes as well?
> > 
> > Uh no, you are completely incorrect. If you compile against db3, you will
> > be using db3. The symbols that were common between db2 and db3 are changed
> > in the *runtime* db3 library, to avoid clashing with db2's symbols. So it
> > will actually use those db3 symbols (thanks to some weak aliasing in the
> > runtime lib).
> 
> Sorry but it's still unclear to me.  If I've linked with both libdb3-dev
> and libsasl7-dev which was linked with libdb2-dev, then when I run it,
> it'll load both libdb2 and libdb3.  Since the libdb3 symbols are weak,
> it'll end up only using the ones from libdb2, for both the symbols required
> by libsasl7 and my own program.  Right?
> 
> I just don't see how you can distinguish between the symbols needed by
> libsasl7 and the symbols needed by the program itself.

See, you aren't listening. They are weak *aliases* to the normal "munged"
db3 symbols. Trust me, if it were using the db2 symbols, it would crash,
which is the problem we would have, had this not been implemented.

It works like this. For each symbol common with db2, I define this in a
header:

asm(".weak __bam_adj_log");
asm("__bam_adj_log = db3___bam_adj_log");
#define __bam_adj_log db3___bam_adj_log

Then I include this in the munged library using "CFLAGS+= -include
db3-munge.h", so basically all the symbols get renamed, and include a weak
alias of the old name to the new symbol.

So the weak symbol *only* points to the correct db3 munged symbol, not off
in space to any symbol that happens along.

-- 
 -----------=======-=-======-=========-----------=====------------=-=------
/  Ben Collins  --  ...on that fantastic voyage...  --  Debian GNU/Linux   \
`  bcollins@debian.org  --  bcollins@openldap.org  --  bcollins@linux.com  '
 `---=========------=======-------------=-=-----=-===-======-------=--=---'



Reply to: