0

IMG 負荷を検出するにはどうすればよいですか? 各関数の前に割り込みを配置するために、プログラムがメモリにロードされるタイミングを検出しようとしています。PIN の IMG_AddInstrumentFunction のようなことをしようとしています。

私は道に迷っており、それに関する情報が見つかりません。

どうも

4

1 に答える 1

1

これはまさに r_brk の目的です。include/link.h を参照してください。

  struct r_debug
  {
    .....
    /* This is the address of a function internal to the run-time linker,
       that will always be called when the linker begins to map in a
       library or unmap it, and again when the mapping change is complete.
       The debugger can set a breakpoint at this address if it wants to
       notice shared object mapping changes.  */
    ElfW(Addr) r_brk;
    ....
   };

彼らは続けて、debugee でこの値を見つける方法を説明しています。

/* This symbol refers to the "dynamic structure" in the `.dynamic' section
   of whatever module refers to `_DYNAMIC'.  So, to find its own
   `struct r_debug', a program could do:
     for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn)
       if (dyn->d_tag == DT_DEBUG)
     r_debug = (struct r_debug *) dyn->d_un.d_ptr;
   */
于 2014-01-15T21:30:39.577 に答える