This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Register a signal handler in _dl_start to handle SIGSEGV for dynamic linker
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: wuxi <wu dot andrew dot xi at gmail dot com>
- Cc: glibc-help <libc-help at sourceware dot org>
- Date: Tue, 2 Sep 2008 08:08:11 -0400
- Subject: Re: Register a signal handler in _dl_start to handle SIGSEGV for dynamic linker
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=VP79bX12P+yz4ay0gF1C6ZsmMEAv7NvnhYoYf37IJVA=; b=NX0kWc+0JytdI/P8rSTsXoapc/JCoC/4Uv2XArEdzLEh+RdQEqvqZ2Ioav7ZO6xS7x ZKG8KgzcCza+osyEaO/OtaAM6M7/lvrRaYEs/oIrtjGMeHHa5/c5KrznTbsoH900bCC4 1Qpu/2Br1aVcTwwYvi/4C3fZYLpMawmsK3gww=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=pruNkmTl44n0LPJ3Nos5Q+TvCqqItrbJvGboLUtgGeJYmyThuH5TfoynzHuZQrhycN rEvEU3gmry3NP6O7PH8YcHmPyDZpQmqxL6/xuspgW/V6nNvQ95juGT4aIAg4PxwcRlXQ nQCfcvPCUxhk9LXYpD4jxxIl7nFmp6XEQRm/c=
- References: <48BC85CA.20609@gmail.com>
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.