[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Calling .init and .fini from dynamic libraries
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Calling .init and .fini from dynamic libraries
- From: Dan Brosemer <odin_(_at_)_svartalfheim_(_dot_)_net>
- Date: Sun, 24 Aug 2003 13:40:29 -0400
- Mail-followup-to: tech_(_at_)_openbsd_(_dot_)_org
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
called.
loader.c looks like it calls them in _dl_call_init:
DL_DEB(("doing ctors: [%s]\n", object->load_name));
if (object->dyn.init)
(*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.
http://www.cleannorth.org/~odin/openbsd-patches/csu-3.4.diff
Thanks in advance
-Dan
--
"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
Visit your host, monkey.org