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

Calling .init and .fini from dynamic libraries

In trying to port wine (ReWind) to OpenBSD 3.4-beta, I've come to believe
that when loading dynamic libraries, the .init and .fini sections are never

loader.c looks like it calls them in _dl_call_init:

        DL_DEB(("doing ctors: [%s]\n", object->load_name));
        if (object->dyn.init)

but I can't find anything that sets object->dyn.init.  I think it should be
done in resolve.c in _dl_finalize_object.  We have this:

        if (object->Dyn.info[DT_INIT])
                object->Dyn.info[DT_INIT] += loff;
        if (object->Dyn.info[DT_FINI])
                object->Dyn.info[DT_FINI] += loff;

But still, the init and fini function pointers go unset.  Is this assessment
correct?  If so, I'll work on a patch, though it may be a bit over my head.

Also, same sections are not called when loading a normal ELF executable
either.  Thorsten Glasser mentioned this in a ports@ post a while back, and
he mentioned that Dale Rahn had a patch.  I looked for that patch and
couldn't find it, so I thought I'd throw mine out there.  It's heavily based
on changes made to NetBSD when they were trying to get wine running some
time ago.


Thanks in advance

"Burnished gallows set with red
 Caress the fevered, empty mind
 Of man who hangs bloodied and blind
 To reach for wisdom, not for bread."  -- Deoridhe Grimsdaughter