This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: ld-linux and binary instrumentation
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: "Arvind Ayyangar" <arvind dot ayyangar at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Mon, 8 Dec 2008 19:16:39 -0500
- Subject: Re: ld-linux and binary instrumentation
- 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=jdVYpC8j6yo8ND9A6KXS6vDUiwKFjwQvFKIRzjGIdJ4=; b=ScJpkKyzgbDV+OUGMpOpQi5C9Nyfyz+4F8h1uUbYE4FPfvPvLKiapV8NQsWQCuXS7m SRtI5qg36rdaK5hr+Yi4HkkSyatu1ej0TS3HNG289plPfEgvgLpEAL5ECFuDpLqnn32S c+gT0IO3jfd2Z4XEdhphinMJjBP5bM8Fss6Sw=
- 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=fBLFHeDpNdU6vvW2ijdEIM9da15cj73VT2c65FU5MVfsq1FY57pPB0L3PBE9HSlBJX iwMvhcubidCcsDJKVl+a8AI62ZjRYzlxYrq3oUFeWQJNgzhaSKt8zTgr9I85w31xbMeZ VgWwcoPvpB4Pb6mYE/HQl4PO8pyg+kGzv/4M8=
- References: <c34bb56f0812081200v30256928r892218ebc6a3408a@mail.gmail.com>
On Mon, Dec 8, 2008 at 3:00 PM, Arvind Ayyangar
<arvind.ayyangar@gmail.com> wrote:
> hi all,
> I am trying to add an empty section/program header to the dynamic
> loader binary.
> When I try to use this instrumented ld-linux.so.2, the applications
> crashes with a Segmentation
> Fault. However, the same works with all other libraries including libc.
> instrumented version crashes with a Segmentation Fault.
>
> Is there something different in the ld-linux.so.2 shared object, which
> does not allow it to be instrumented ?
Firstly, it's not a shared object, it's a static binary.
Secondly, you may not be able to easily instrument the dynamic loader.
The dynamic loader is responsible for setting up the procedure linkage
table (PLT) used to make library calls. You can't make library calls
until *after* the PLT is setup. If your instrumentation code tries to
call write(...); or printf(...); it will crash.
In summary, the dynamic loader will require special care to
instrument. It can't be treated like a regular binary.
Cheers,
Carlos.