Alan Coopersmith wrote:
> When building the Mesa library with the gcc bundled with Solaris,
> I get a fatal ld error of the form:
> 
> ld: fatal: relocation error: R_386_GOTOFF: file indirect_init.o: symbol 
> __indirect_glNewList: relocation must bind locally

The compiler has generated a GOT based relocation, which must bind to the
object being built - since this relocation is relevant to the current GOT.
However, the symbol is global, which means it could be bound to at runtime
to another object.   If it did, the GOT base use would be compromised.

> Googling for this error suggests that the fix in other projects has been
> to disable gcc's symbol visibility attributes on Solaris, but that doesn't
> seem to help here.   Any suggestions for how to fix?
> 
> The header file defines the function as:
>  #    define HIDDEN  __attribute__((visibility("hidden")))
> [...]
> extern HIDDEN void __indirect_glNewList(GLuint list, GLenum mode);
> 
> The definition in indirect.c looks like:
> void
> __indirect_glNewList(GLuint list, GLenum mode)
> {
> [...]
> }
> 
> The reference in indirect_init.c uses it as a function pointer, not
> a direct call:
> 
>    glAPI->NewList = __indirect_glNewList;
> 
> % elfdump indirect.o | grep glNewList:
> 
>   [34]  0x00000720 0x00000068  FUNC GLOB  D    0 .text  __indirect_glNewList

The hidden attribute is supposed to demote the symbol to local - it's the
equivalent of using a mapfile with the "local: *" scoping directive to
demote non-global symbols.

If the compiler was honoring the hidden attribute I'd expect the
relocatable indirect.o to look like:

    [34]  0x00000720 0x00000068  FUNC GLOB  H     0 .text  __indirect_glNewList
                                            ^
The 'H' stands for STV_HIDDEN.

If the compiler isn't generating the correct symbol definition, you could
demote this symbol with a mapfile:

        {
                local:
                        __indirect_glNewList;
        };


-- 

Rod.

Reply via email to