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 Monday 08 December 2008 19:16:39 Carlos O'Donell wrote:
> On Mon, Dec 8, 2008 at 3:00 PM, Arvind Ayyangar 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.

that's why you'll see crazy ugly macros that look similar to standard C lib 
functions but really expand straight into system calls.  if you want to keep 
your sanity, call the kernel directly.  and dont use any dynamic memory.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


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