linking of inline static methods

H . J . Lu hjl@lucon.org
Wed Jun 28 13:45:00 GMT 2000


On Wed, Jun 28, 2000 at 10:30:25PM +0200, Martin v. Loewis wrote:
> > I don't think there is any bug in ld. In general, you don't use
> > -Bsymbolic unless you know what you are doing. -Bsymbolic turns the
> > global symbol references into local ones if there is a definition in
> > the shared library. That is your problem.
> 
> I believe this is not the problem. On the assembler level, there is
> only one definition of the symbol, namely in a file that goes into the
> shared library. When linking, you suddenly get two definitions. One in
> the shared library, and one in the executable. As a result, they will
> be considered different under -Bsymbolic - that part is not
> questioned. 
> 
> What I don't understand is why the object needs to be copied into the
> executable. Specifically, for the library, I get
> 
> 00001930 D _16TestInlineStatic.staticVar
> 
> and for the executable, I get
> 
> 0804984c B _16TestInlineStatic.staticVar
> 
> together with a relocation
> 
> 0804984c R_386_COPY        _16TestInlineStatic.staticVar
> 
> Why is it needed to copy the variable into the program image at run
> time? Couldn't it live in the shared library just fine?

Welcome to ia32. The copy relocation doesn't exist in many ABIs. But
it is in the ia32 ABI. That is how the ia32 ABI works. Please read the
ia32 ABI if you want.


H.J.


More information about the Gcc mailing list