public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* probing a plt
@ 2011-09-02 18:31 Stan Cox
  2011-09-02 21:21 ` Frank Ch. Eigler
  2011-09-06 21:58 ` Stan Cox
  0 siblings, 2 replies; 7+ messages in thread
From: Stan Cox @ 2011-09-02 18:31 UTC (permalink / raw)
  To: systemtap

This is small example showing how a plt may possibly be probed.  The 
implementation is similar to .library in the sense that the plt is 
iterated over and probes added for each plt entry.  Currently the only 
possibility is probing every plt entry in a module.  Suggestions for 
further refinements?

cat 12215.c
main ()
{
   char *abc = "abcdefghijklmnopqrstuvwxyz";
   char *xyz = "zyxwvutsrqpomnlkjihgfedcba";
   int x;
   puts ("a string");
   printf ("length %d %s\n", strlen(abc), abc);
   printf ("length %d %s\n", strlen(xyz), xyz);
   return 0;
}

objdump -d -j .plt 12215.x
12215.x:     file format elf64-x86-64
Disassembly of section .plt:
00000000004003f0 <printf@plt>:
   4003f0:	ff 25 8a 05 20 00    	jmpq   *0x20058a(%rip)        # 600980 
<_GLOBAL_OFFSET_TABLE_+0x18>
   4003f6:	68 00 00 00 00       	pushq  $0x0
   4003fb:	e9 e0 ff ff ff       	jmpq   4003e0 <_init+0x18>
0000000000400400 <puts@plt>:
   400400:	ff 25 82 05 20 00    	jmpq   *0x200582(%rip)        # 600988 
<_GLOBAL_OFFSET_TABLE_+0x20>
   400406:	68 01 00 00 00       	pushq  $0x1
   40040b:	e9 d0 ff ff ff       	jmpq   4003e0 <_init+0x18>
0000000000400410 <__libc_start_main@plt>:
   400410:	ff 25 7a 05 20 00    	jmpq   *0x20057a(%rip)        # 600990 
<_GLOBAL_OFFSET_TABLE_+0x28>
   400416:	68 02 00 00 00       	pushq  $0x2
   40041b:	e9 c0 ff ff ff       	jmpq   4003e0 <_init+0x18>

install/bin/stap --kelf -c ./12215.x -e 'probe process("./12215.x").plt 
{printf ("plt-entry=%s\n",$$name)}' -p2
# probes
process("/work/scox/stap/bugs/12215/12215.x").statement(0x4003f0)? /* 
pc=.absolute+0x4003c8 */ /* <- process("./12215.x").plt? = 
process("./12215.x").statement(4195312)? <- process("./12215.x").plt */
process("/work/scox/stap/bugs/12215/12215.x").statement(0x400400)? /* 
pc=.absolute+0x4003c8 */ /* <- process("./12215.x").plt? = 
process("./12215.x").statement(4195328)? <- process("./12215.x").plt */
process("/work/scox/stap/bugs/12215/12215.x").statement(0x400410)? /* 
pc=.absolute+0x4003c8 */ /* <- process("./12215.x").plt? = 
process("./12215.x").statement(4195344)? <- process("./12215.x").plt */

install/bin/stap --kelf -c ./12215.x -e 'probe process("./12215.x").plt 
{printf ("plt-entry=%s\n",$$name)}'
a string
length 26 abcdefghijklmnopqrstuvwxyz
length 26 zyxwvutsrqpomnlkjihgfedcba
plt-entry=printf
plt-entry=puts
plt-entry=__libc_start_main

(I would expect the __libc_start_main probe to have appeared first and 
the printf probe to have been hit twice, so looking into that.)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-09-09 17:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02 18:31 probing a plt Stan Cox
2011-09-02 21:21 ` Frank Ch. Eigler
2011-09-09 17:59   ` Stan Cox
2011-09-06 21:58 ` Stan Cox
2011-09-07 10:42   ` Mark Wielaard
2011-09-07 16:12     ` Stan Cox
2011-09-07 20:09       ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).