probing a plt

Stan Cox scox@redhat.com
Fri Sep 2 18:31:00 GMT 2011


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.)



More information about the Systemtap mailing list