Andes Workshop
http://forum.andestech.com/

bin檔與elf檔的關係(如何知道bin檔的內容)
http://forum.andestech.com/viewtopic.php?f=16&t=570
Page 1 of 1

Author:  cindy [ Fri Apr 20, 2012 6:17 pm ]
Post subject:  bin檔與elf檔的關係(如何知道bin檔的內容)

Readelf有section表
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .nds32_vector PROGBITS 00000000 001000 000100 00 AX 0 0 16
[ 2] .nds32_nmih PROGBITS 00000100 001100 000004 00 A 0 0 4
[ 3] .nds32_wrh PROGBITS 00000104 001104 000004 00 A 0 0 4
[ 4] .nds32_jmptbl PROGBITS 00000108 001108 000040 00 A 0 0 4
[ 5] .nds32_isr PROGBITS 00000148 001148 00017c 00 AX 0 0 4
[ 6] .text PROGBITS 000002c4 0012c4 000ca0 00 AX 0 0 4
[ 7] .rodata PROGBITS 00000f64 001f64 000244 00 A 0 0 4
[ 8] .sdata_w PROGBITS 000011a8 0021a8 000004 00 WA 0 0 4
[ 9] .sbss_w NOBITS 000011ac 0021ac 000028 00 WA 0 0 4
[10] .bss NOBITS 000011d8 0021ac 000008 00 WA 0 0 8
[11] .comment PROGBITS 00000000 0021ac 000096 00 0 0 1

其中Flga標示A的都是佔空間的。
這些標示A的部份,只有sbss_w及bss不在bin檔裡,其他的全部放在bin檔裡。

例如
.nds32_vector,它的file offset為0x1000,所以elf檔裡的0x1000為.nds32_vector的起點,

如下圖:

Attachment:
p1.gif
p1.gif [ 20.43 KiB | Viewed 8235 times ]


然後bin檔裡,它是最前面的,所以bin檔裡是由0x0開始。
Attachment:
p2.gif
p2.gif [ 19.2 KiB | Viewed 8235 times ]


Attachment:
example.7z [12.99 KiB]
Downloaded 1065 times


1. elf中.nds32_vector的offset為什麼是1000?這個offset值是在哪里設置的呢?
Ans: elf檔的0x0~0x1000是檔頭,記錄本elf檔之資訊。
這個offset是自動產生的。
2. binary中offset在0x1000之前的資料是什麼呢?
Ans: binary中..0~0x100是.nds32_vector
0x100~0x104 是.nds32_nmih..依此類推

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/