Upgrade to Pro — share decks privately, control downloads, hide ads and more …

hookingsharedelflibs

kubo39
December 12, 2014
75

 hookingsharedelflibs

introduction of shared elf libraries.

kubo39

December 12, 2014
Tweet

Transcript

  1. ELF is 何? • Linuxなどの実行ファイルフォーマット • はやい話、a.outの(現在の)内部形式 • gcc/ldとかがはく a.out

    とかをreadelfとかで読んで みるとなんとなくわかる • プログラムの実行に必要な情報が入ってる
  2. 例) ELFヘッダ • 全ての ELF ファイルは ELF ヘッダという構造体か らはじまる •

    ELFヘッダはファイルの中身に関するいろいろな情 報が格納 • セクションヘッダ表とかプログラムヘッダ表とか
  3. ELFヘッダ • ~$ readelf -h ~/dev/kubo39/bossan/lib/bossan/bossan_ext.so • ELF ヘッダ: •

    マジック: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 • クラス: ELF64 • データ: 2 の補数、リトルエンディアン • バージョン: 1 (current) • OS/ABI: UNIX - System V • ABI バージョン: 0 • 型: DYN (共有オブジェクトファイル) • マシン: Advanced Micro Devices X86-64 • バージョン: 0x1 • エントリポイントアドレス: 0x3a70 • プログラムの開始ヘッダ: 64 (バイト) • セクションヘッダ始点: 439784 (バイト) • フラグ: 0x0 • このヘッダのサイズ: 64 (バイト) • プログラムヘッダサイズ: 56 (バイト) • プログラムヘッダ数: 7 • セクションヘッダ: 64 (バイト) • セクションヘッダサイズ: 37 • セクションヘッダ文字列表索引: 34
  4. • readelf -s xxx.so • 番号: 値 サイズ タイプ Bind

    Vis 索引名 • 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND • 1: 0000000000003308 0 SECTION LOCAL DEFAULT 9 • 2: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND __timezone@GLIBC_2.2.5 (2) • 3: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND ruby_snprintf • 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND free@GLIBC_2.2.5 (2) • 5: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND rb_eTypeError • 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strcasecmp@GLIBC_2.2.5 (2) • 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND localtime@GLIBC_2.2.5 (2) • 8: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND rb_raise • 9: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __errno_location@GLIBC_2.2.5 (3) • 10: 0000000000000000 0 FUNC GLOBAL DEFAULT UND unlink@GLIBC_2.2.5 (2) • 11: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab • 12: 0000000000000000 0 FUNC GLOBAL DEFAULT UND writev@GLIBC_2.2.5 (2) • 13: 0000000000000000 0 FUNC GLOBAL DEFAULT UND islower@GLIBC_2.2.5 (2) • 14: 0000000000000000 0 FUNC GLOBAL DEFAULT UND toupper@GLIBC_2.2.5 (2) • 15: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2) • 16: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND rb_cObject • 17: 0000000000000000 0 FUNC GLOBAL DEFAULT UND sigaction@GLIBC_2.2.5 (3) • 18: 0000000000000000 0 FUNC GLOBAL DEFAULT UND setsockopt@GLIBC_2.2.5 (2) • 19: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND rb_require • 20: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fcntl@GLIBC_2.2.5 (3) • 21: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND rb_enc_str_new •