Hi,
I build elf file using TI compiler for Tiva C target.
I have to write a program to manage elf file, one of the operations is to extract binary data, as the command "tiobj2bin file.elf file.bin armofd armhex mkhex4bin" do.
I use libelf to access the elf file.
Elf file I have to handle are such that the output of the command readelf is:
There are 28 section headers, starting at offset 0x225e24: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .bootVecs NOBITS 00000000 00f400 000008 00 0 0 4 [ 2] .vecs NOBITS 20000000 00f0c0 000360 00 WA 0 0 4 [ 3] .resetVecs PROGBITS 00002000 000038 00003c 00 A 0 0 4 [ 4] xdc.meta PROGBITS 00000000 00f400 000119 00 0 0 1 [ 5] .intvecs NOBITS 00000000 000000 000000 00 0 0 1 [ 6] .text PROGBITS 0000203c 000074 00c6f4 00 AX 0 0 4 [ 7] .const PROGBITS 0000e730 00c768 002582 00 A 0 0 4 [ 8] .cinit PROGBITS 00010cb8 00ecf0 0003d0 00 A 0 0 8 [ 9] .pinit NOBITS 00000000 000000 000000 00 0 0 1 [10] .init_array NOBITS 00000000 000000 000000 00 W 0 0 1 [11] .vtable NOBITS 00000000 000000 000000 00 0 0 1 [12] .data NOBITS 2000694c 01594c 0004ec 00 WA 0 0 4 [13] .bss NOBITS 20000400 00f400 00554b 00 WA 0 0 1024 [14] .sysmem NOBITS 00000000 000000 000000 00 0 0 1 [15] .stack NOBITS 2000594c 01494c 001000 00 WA 0 0 4 [16] .debug_info PROGBITS 00000000 00f519 0b3d72 00 0 0 1 [17] .debug_line PROGBITS 00000000 0c328b 01ced6 00 0 0 1 [18] .debug_aranges PROGBITS 00000000 0e0161 002828 00 0 0 1 [19] .debug_frame PROGBITS 00000000 0e2989 009b8d 00 0 0 1 [20] .debug_abbrev PROGBITS 00000000 0ec516 016b59 00 0 0 1 [21] .debug_str PROGBITS 00000000 10306f 07fc55 00 0 0 1 [22] .debug_pubtypes PROGBITS 00000000 182cc4 06d45b 00 0 0 1 [23] .ARM.attributes ARM_ATTRIBUTES 00000000 1f011f 00005b 00 0 0 0 [24] .symtab SYMTAB 00000000 1f017c 0253a0 10 26 8687 0 [25] .TI.section.flags PROGBITS 00000000 21551c 00001a 00 0 0 0 [26] .strtab STRTAB 00000000 215536 01077b 01 S 0 0 0 [27] .shstrtab STRTAB 00000000 225cb1 000110 01 S 0 0 0 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Elf file type is EXEC (Executable file) Entry point 0xc695 There are 3 program headers, starting at offset 2252228 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000038 0x00002000 0x00002000 0x0f088 0x0f088 R E 0x8 LOAD 0x00f0c0 0x20000000 0x20000000 0x00000 0x00360 RW 0x4 LOAD 0x00f400 0x20000400 0x20000400 0x00000 0x06a38 RW 0x400 Section to Segment mapping: Segment Sections... 00 .bootVecs .resetVecs .intvecs .text .const .cinit .pinit .init_array .vtable .sysmem 01 .bootVecs .vecs .intvecs .pinit .init_array .vtable .sysmem 02 .bootVecs .intvecs .pinit .init_array .vtable .data .bss .sysmem .stack
How do I choose section to exctract? Do I need to take into accouny section type and flags? And what about segments?
best regards