This example shows an example of (abridged) output for the elf file from one
program:
(mem3.c
)
14: char *phrase = "The quick brown fox jumps over the lazy dog"; 15: 16: signed char peppers[] = {'p','e','p','p','e','r','s',-5,0}; 17: 18: unsigned short bins[96]; 19: 20: double v[4] = {1.0, 2.0, 3.0, 4.0}; 21: 22: void do_hist(char *str, int len, short bins[96]); 23: void show_bins(short bins[96]); 24: double cum_sum(double v[], int len); 25: 26: int main()
pic32-readelf -S mem3.elf > mem3.sections.txt
There are 100 section headers, starting at offset 0xb72d8: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .reset PROGBITS bfc00000 0b0000 000010 00 AX 0 0 1 [ 2] .bev_excpt PROGBITS bfc00380 0b0380 000010 00 AX 0 0 1 [ 3] .dbg_excpt PROGBITS bfc00480 0b0390 000000 00 W 0 0 1 [ 4] .dbg_code PROGBITS bfc02000 0b0390 000000 00 W 0 0 1 [ 5] .app_excpt PROGBITS 9fc01180 0a1180 000010 00 AX 0 0 1 [ 6] .vector_0 PROGBITS 9fc01200 0b0390 000000 00 W 0 0 1 [69] .vector_63 PROGBITS 9fc019e0 0b0390 000000 00 W 0 0 1 [70] .startup PROGBITS 9fc00490 0a0490 0001e0 00 AX 0 0 1 [71] .text PROGBITS 9d000000 010000 074268 00 AX 0 0 4 [72] .rodata PROGBITS 9d074268 084268 0002d0 00 A 0 0 8 [73] .sdata2 PROGBITS 9d074538 0b0390 000000 00 W 0 0 1 [74] .sbss2 PROGBITS 9d074538 0b0390 000000 00 W 0 0 1 [75] .eh_frame PROGBITS 9d074538 084538 000050 00 A 0 0 4 [76] .dbg_data PROGBITS a0000000 0b0390 000000 00 W 0 0 1 [77] .data PROGBITS a0000000 090000 000124 00 WA 0 0 8 [78] .sdata PROGBITS a0000124 090124 000008 00 WAp 0 0 4 [79] .sbss NOBITS a000012c 0a1190 000004 00 WAp 0 0 4 [80] .bss NOBITS a0000130 0a1190 0001cc 00 WA 0 0 4 [81] .heap PROGBITS a00002fc 0b0390 000000 00 W 0 0 1 [82] .stack NOBITS a00002fc 0a1190 000400 00 WA 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific)
pic32-readelf -s mem3.elf > mem3.symbols.txt
Symbol table '.symtab' contains 1203 entries: Num: Value Size Type Bind Vis Ndx Name 310: a0008120 0 NOTYPE GLOBAL DEFAULT ABS _gp 734: a0000010 32 OBJECT GLOBAL DEFAULT 77 v 818: 9d000018 496 FUNC GLOBAL DEFAULT 71 main 849: a0000124 4 OBJECT GLOBAL DEFAULT 78 phrase 955: a0000000 9 OBJECT GLOBAL DEFAULT 77 peppers 1020: a000023c 192 OBJECT GLOBAL DEFAULT 80 bins
14: char *phrase = "The quick brown fox jumps over the lazy dog";
The pointer phrase
, defined in line 14, was
assigned to .sdata
(0xa0000124). The following console command
dumps the contents of .sdata
(a short section). The
contents or value of phrase
is 0x9d074268, which
is the start of the .rodata
. There,
in turn you find the string "The quick brown fox ..."
pic32-readelf -x 78 mem3.elf Hex dump of section '.sdata': 0xa0000124 a0000050 9d074268 hB..P...
18: unsigned short bins[96];
The symbol bins
(see line 18) is allocated
to .bss
, which is an area the start-up code initializes
to zero.
20: double v[4] = {1.0, 2.0, 3.0, 4.0};
The symbol v
(see line 20) is located in
.data
at 0xa0000010:
0xa0000010 00000000 v[0] = 1.0; 0xa0000014 3ff00000 0xa0000018 00000000 v[1] = 2.0; 0xa000001c 40000000 0xa0000020 00000000 v[2] = 3.0; 0xa0000020 40080000 0xa0000020 00000000 v[3] = 4.0; 0xa0000020 40100000
pic32-readelf -x 72 mem3.elf > mem3.rodata.dump.txt
The 32-bit words, in hex below, are ordered from right to left. The printable ASCII characters are ordered from left to right.
Hex dump of section '.rodata': 0x9d074268 206e776f 7262206b 63697571 20656854 The quick brown 0x9d074278 74207265 766f2073 706d756a 20786f66 fox jumps over t 0x9d074288 70706570 00676f64 20797a61 6c206568 he lazy dog.pepp 0x9d074298 69727473 0000000a 7025203d 20737265 ers = %p....stri 0x9d0742a8 0000000a 64252068 74676e65 6c20676e ng length %d.... 0x9d0742b8 203a7365 74796220 65766974 6167656e negative bytes: 0x9d0742c8 0a702520 3d206573 61726870 000a6425 %d..phrase = %p. 0x9d0742d8 00000a70 25203d20 736e6962 00000000 ....bins = %p... 0x9d0742e8 6874676e 656c2076 000a7025 203d2076 v = %p..v length 0x9d0742f8 676f7250 000a6725 00000000 0a642520 %d.....%g..Prog 0x9d074308 202e6465 74616e69 6d726574 206d6172 ram terminated. 0x9d074318 7420646e 6120544c 4148206b 63696c43 Click HALT and t 0x9d074328 6f747320 6f742054 45534552 206e6568 hen RESET to sto 0x9d074338 72746e6f 636f7263 696d2065 68742070 p the microcontr 0x9d074348 25206325 00000000 0a202e72 656c6c6f oller. .....%c % 0x9d074358 70207372 65746361 72616863 000a6434 4d..characters p 0x9d074368 626d756e 000a7325 0a3a746e 65736572 resent:.%s..numb 0x9d074378 73726574 63617261 68632066 6f207265 er of characters 0x9d074388 9d000854 9d0007a0 0000000a 6425203a : %d........T...
pic32-readelf -x 77 mem3.elf > mem3.data.dump.txt
The 32-bit words, in hex below, are ordered from right to left. The printable ASCII characters are ordered from left to right.
16: signed char peppers[] = {'p','e','p','p','e','r','s',-5,0};
The ASCII string peppers starts 0x70 (p), 0x65 (e), 0x70 (p), 0x70 (p) at address 0xa000_0000:
Hex dump of section '.data': 0xa0000000 00000000 00000000 fb737265 70706570 peppers......... 0xa0000010 40000000 00000000 3ff00000 00000000 .......?.......@ 0xa0000020 40100000 00000000 40080000 00000000 .......@.......@ 0xa0000030 00000000 00000000 ffffffff 00000000 ................ 0xa0000040 00000000 00000000 00000000 00000000 ................
Maintained by John Loomis, last updated 26 August 2008