This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld-linux and binary instrumentation


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]