Register a signal handler in _dl_start to handle SIGSEGV for dynamic linker
Carlos O'Donell
carlos@systemhalted.org
Tue Sep 2 12:08:00 GMT 2008
On Mon, Sep 1, 2008 at 8:16 PM, wuxi <wu.andrew.xi@gmail.com> wrote:
> My problem is, when I hook signal handler at _dl_start (very start of the
> dynamic linker, according to my study of code) to enable taint tracking for
> dynamic linker, the special signal handler seems not work - that is, when I
> run ld.so, it reports Segment fault directly without trapping into my own
> signal handler. However, I dump the code and discover the hook function has
> been called before such access.
When asking a complex question please *also* post your patch to the
code. This allows the reviewer to read the patch, read your question,
and see if anything is missing.
> So, am I missing something here to register a signal handler for dynamic
> linker?
Yes. You should not be making function calls into libc *before* the
dynamic loader has relocated itself.
You must only install a signal handler after
elf/rtld.c (_dl_start) line 539 in libc cvs head
e.g. bootstrap_map.l_relocated = 1;
Before this line it is not safe to make function calls into libc.
Cheers,
Carlos.
More information about the Libc-help
mailing list