Rod Evans wrote:
> # elfdump -d /usr/X11/lib/modules/input//mouse_drv.so
> 
> Dynamic Section:  .dynamic
>      index  tag                value
>        [0]  POSFLAG_1         0x1                 [ LAZY ]
>        [1]  NEEDED            0x7e8               libm.so.2
>        [2]  NEEDED            0x7fb               libc.so.1
>        [3]  INIT              0
>        [4]  FINI              0
> 
> ld.so.1 is blindly taking the address INIT and jumping to it.
> 
> This is typically the offset within the object that contains a _init()
> function.
> 
> I'm surprised ld(1) would generate an entry with 0 in the first place.

I've found the problem - it's actually a bug I introduced trying to follow
your advice!  8-)

After several drivers in my Xorg 7.2 builds failed to run due to missing
symbols, I started building them all with -z defs, using a mapfile as
you had previously suggested to allow them to reference functions defined
in the Xorg server binary itself with entries such as:

{
   global:
     AbortDDX = FUNCTION extern;
     AbortServer = FUNCTION extern;
[...]
}

Since the list of exported symbols in the Xorg binary is large and changes
from release to release, I wrote a script to generate this mapfile from an
nm of the Xorg binary.  Unfortunately, this script included a couple symbols
too many:
     _init = FUNCTION extern;
     _fini = FUNCTION extern;
which ld seems to have translated into the INIT 0 and FINI 0 that elfdump shows.

(Perhaps a small RFE for the linker to tell me I'm doing something stupid?)

After fixing my script to not include any symbol name starting with underscore
in my mapfile, and rebuilding, Xorg can now dlopen all the modules without
segfaulting.

The same problem appears in my 32-bit & 64-bit x86 mapfiles, but those get
built with a valid .init section even without the entry in the mapfile, so
that seems to have hidden the problem there.

Thanks for pointing me at the root cause!

-- 
        -Alan Coopersmith-           alan.coopersmith at sun.com
         Sun Microsystems, Inc. - X Window System Engineering

Reply via email to