For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > July 2004 > How to disable a DLLs init() when using dlopen() ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to disable a DLLs init() when using dlopen() ?
Adrian B.

2004-07-29, 8:57 am

I have a shared lib I'm opening with dlopen() but do not have access
to its source code. It automatically executes an init fn on loading
(and fini() in exiting) which do stuff I want to disable. Is there
any way to do this programatically?

Thanks
AB
Måns Rullgård

2004-07-29, 8:57 am

borg@swirve.com (Adrian B.) writes:

> I have a shared lib I'm opening with dlopen() but do not have access
> to its source code. It automatically executes an init fn on loading
> (and fini() in exiting) which do stuff I want to disable. Is there
> any way to do this programatically?


You could use objcopy to rename those symbols to something harmless.

--
Måns Rullgård
mru@kth.se
Paul Pluzhnikov

2004-07-30, 3:57 am

Måns Rullgård <mru@kth.se> writes:

> borg@swirve.com (Adrian B.) writes:
>

No, not really.
[color=darkred]
> You could use objcopy to rename those symbols to something harmless.


At least on ELF systems, these symbols are not referenced by the
dynamic loader "by name"; rather their address is recorded in the
the PT_DYNAMIC header as DT_INIT and DT_FINI at link time.

Renaming the _init/_fini will not do the OP any good.

OTOH, binary-editing the .dynamic section and setting DT_INIT/DT_FINI
to some other "harmless" address should do the trick.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com