1

IMG_HighAddressプログラムのメイン実行可能イメージのすべてのセクションをリストする (すべてのセクションを反復する) 簡単な pintool を開発し、さらにandを使用してその下限と上限をリストしましたIMG_LowAddress。ピンによると、これらは画像の明確な限界を返します。

驚いたことに、セクションは、これらの関数によって報告された下限と上限をはるかに超えていました。何か間違ったことをしたのでしょうか、それともこれらの関数は不正確ですか?

私の画像読み込み機能:

VOID ImageLoad(IMG img, VOID *v)
{

if (!IMG_IsMainExecutable(img))
    return;

ADDRINT mainExeImageLowAddr = IMG_LowAddress(img);
ADDRINT mainExeImageHighAddr = IMG_HighAddress(img);    

cout << "Image limits " << hex << mainExeImageLowAddr << " - " << mainExeImageHighAddr << endl;

for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
{   
    cout << "Section " << SEC_Name(sec) << " at addresses 0x" << hex << SEC_Address(sec) << " - 0x" << SEC_Address(sec)+SEC_Size(sec)-1 << endl;
}

}

/bin/ls で実行した結果:

Image limits 400000 - 418b23
Section .interp at addresses 0x400200 - 0x40021b
Section .note.ABI-tag at addresses 0x40021c - 0x40023b
Section .note.gnu.build-id at addresses 0x40023c - 0x40025f
Section .dynsym at addresses 0x4002c8 - 0x400eaf
Section .rela.dyn at addresses 0x401618 - 0x4017c7
Section .rela.plt at addresses 0x4017c8 - 0x402157
Section .init at addresses 0x402158 - 0x40216f
Section .plt at addresses 0x402170 - 0x4027df
Section .text at addresses 0x4027e0 - 0x412347
Section .fini at addresses 0x412348 - 0x412355
Section .rodata at addresses 0x412360 - 0x415e86
Section .eh_frame_hdr at addresses 0x415e88 - 0x41653b
Section .eh_frame at addresses 0x416540 - 0x41851b
Section .dynstr at addresses 0x41851c - 0x418b23
Section .ctors at addresses 0x619000 - 0x61900f
Section .dtors at addresses 0x619010 - 0x61901f
Section .jcr at addresses 0x619020 - 0x619027
Section .data.rel.ro at addresses 0x619040 - 0x619a87
Section .dynamic at addresses 0x619a88 - 0x619c57
Section .got at addresses 0x619c58 - 0x619cef
Section .got.plt at addresses 0x619cf0 - 0x61a037
Section .data at addresses 0x61a040 - 0x61a23f
Section .bss at addresses 0x61a240 - 0x61af5f
Section .gnu.conflict at addresses 0x61af60 - 0x61b6f7
Section .gnu_debuglink at addresses 0x0 - 0xf
Section .gnu.prelink_undo at addresses 0x0 - 0x8ff
Section .shstrtab at addresses 0x0 - 0x12d
4

1 に答える 1

2

私は何か間違ったことをした

必ずしも。

Pin は ELF の概念を Windows 固有の概念にマッピングしようとしているように見えますが、1 対 1 のマッピングはありません。

IntelのドキュメントIMG_HighAddressは、次のように記載されています。

Tells the highest address of any code or data loaded by the image.
This is the address of the last byte loaded by the image.

しかし、それは正確にはどういう意味ですか?

ELF イメージのロードは、PT_LOADセグメントによって定義されます。からの出力で、セグメントとセクションからセグメントへのマッピングを確認できますreadelf -Wl a.out

通常、2 つのLOADセグメントがあります。1 つは、、およびその他の読み取り専用セクションをr-xカバーする保護を備え、もう 1 つは、およびその他の書き込み可能セクションをカバーする保護を備えています。.text.rodatarw-.data.bss

(出力から)最初のセグメントIMG_HighAddressのみを記述しているように見えます。LOAD

また、すべてのセクションが使用LOADできるわけではなく、通常、LOAD使用できないセクションはどのセグメントにも含まれていない (実行時にメモリを占有しない)ことにも注意してください。さまざまな.debug*セクションは通常LOADできません。

于 2017-01-10T01:16:34.810 に答える