问题描述
我正在一个项目中,该项目涉及解析arm elf文件并从中提取节.
I'm working on a project which involves parsing an arm elf file and extracting the sections from it.
一个elf文件中显然有很多部分没有加载到Flash中,但是我想知道objcopy如何确切地知道要包含在二进制文件中的哪些部分要直接刷新到Flash中?
There are obviously plenty of sections in an elf file which do not get loaded into flash, but I'm wondering how exactly objcopy knows which sections to include in a binary to be flashed directly into flash?
例如,以下是arm elf文件的readelf:
Take for example the following readelf of an arm elf file:
[0] NULL 00000000 000000 000000 00 0 0 0
[ 0] NULL 00000000 000000 000000 00 0 0 0
[1] .isr_vector程序08020000 010000 0001f8 00 WA 0 0 4
[ 1] .isr_vector PROGBITS 08020000 010000 0001f8 00 WA 0 0 4
[2] .firmware_header_ PROGBITS 080201f8 0101f8 000004 00 WA 0 0 4
[ 2] .firmware_header_ PROGBITS 080201f8 0101f8 000004 00 WA 0 0 4
[3] .text凭证08020200 010200 01e11c 00 AX 0 0 64
[ 3] .text PROGBITS 08020200 010200 01e11c 00 AX 0 0 64
[4] .ARM.extab优惠券0803e31c 033a68 000000 00 W 0 0 1
[ 4] .ARM.extab PROGBITS 0803e31c 033a68 000000 00 W 0 0 1
[5] .exidx ARM_EXIDX 0803e31c 02e31c 000008 00 AL 3 0 4
[ 5] .exidx ARM_EXIDX 0803e31c 02e31c 000008 00 AL 3 0 4
[6] .ARM.ARM属性归于ARM_ATTRIBUTES 0803e324 033a68 000030 00 0 0 1
[ 6] .ARM.attributes ARM_ATTRIBUTES 0803e324 033a68 000030 00 0 0 1
[7] .init_array INIT_ARRAY 0803e324 02e324 000008 04 WA 0 0 4
[ 7] .init_array INIT_ARRAY 0803e324 02e324 000008 04 WA 0 0 4
[8] .fini_array FINI_ARRAY 0803e32c 02e32c 000004 04 WA 0 0 4
[ 8] .fini_array FINI_ARRAY 0803e32c 02e32c 000004 04 WA 0 0 4
[9] .firmware_header协议0803e330 02e330 000008 00 WA 0 0 4
[ 9] .firmware_header PROGBITS 0803e330 02e330 000008 00 WA 0 0 4
[10] .data PROGBITS 20000000 030000 0009c8 00 WA 0 0 8
[10] .data PROGBITS 20000000 030000 0009c8 00 WA 0 0 8
[11] .RxDecripSection程序200009c8 0309c8 000080 00 WA 0 0 4
[11] .RxDecripSection PROGBITS 200009c8 0309c8 000080 00 WA 0 0 4
[12] .RxarraySection程序20000a48 030a48 0017d0 00 WA 0 0 4
[12] .RxarraySection PROGBITS 20000a48 030a48 0017d0 00 WA 0 0 4
[13] .TxDescripSection程序20002218 032218 000080 00 WA 0 0 4
[13] .TxDescripSection PROGBITS 20002218 032218 000080 00 WA 0 0 4
[14] .TxarraySection程序20002298 032298 0017d0 00 WA 0 0 4
[14] .TxarraySection PROGBITS 20002298 032298 0017d0 00 WA 0 0 4
[15] .bss NOBITS 20003a68 033a68 045bc0 00 WA 0 0 8
[15] .bss NOBITS 20003a68 033a68 045bc0 00 WA 0 0 8
[16] .heap利润20049628 033a98 000000 00 W 0 0 1
[16] .heap PROGBITS 20049628 033a98 000000 00 W 0 0 1
[17] .reserved_for_sta计划书20049628 033a98 000000 00 W 0 0 1
[17] .reserved_for_sta PROGBITS 20049628 033a98 000000 00 W 0 0 1
[18] .battery_backed_s NOBITS 40024000 034000 00000c 00 WA 0 0 4
[18] .battery_backed_s NOBITS 40024000 034000 00000c 00 WA 0 0 4
[19] .comment PROGBITS 00000000 033a98 000075 01 MS 0 0 1
[19] .comment PROGBITS 00000000 033a98 000075 01 MS 0 0 1
[20] .debug_frame PROGBITS 00000000 033b10 001404 00 0 0 4
[20] .debug_frame PROGBITS 00000000 033b10 001404 00 0 0 4
[21] .stab利润00000000 034f14 000084 0c 22 0 4
[21] .stab PROGBITS 00000000 034f14 000084 0c 22 0 4
[22] .stabstr STRTAB 00000000 034f98 000117 00 0 0 1
[22] .stabstr STRTAB 00000000 034f98 000117 00 0 0 1
[23] .symtab SYMTAB 00000000 0350b0 009010 10 24 1646 4
[23] .symtab SYMTAB 00000000 0350b0 009010 10 24 1646 4
[24] .strtab STRTAB 00000000 03e0c0 003dc8 00 0 0 1
[24] .strtab STRTAB 00000000 03e0c0 003dc8 00 0 0 1
[25] .shstrtab STRTAB 00000000 041e88 000132 00 0 0 1
[25] .shstrtab STRTAB 00000000 041e88 000132 00 0 0 1
现在,显然这些部分中的相当一部分(例如.TxarraySection)没有加载到Flash中.但是,该节类型为PROGBITS,并且具有可写和已分配标志.这与isr_vector相同,后者已加载但具有相同的类型和标志.我在这里想念什么?我应该在程序标题中查找吗?
Now, obviously quite a few of these sections (like .TxarraySection) are not loaded into flash. However, that section type is PROGBITS and it has a writable and allocated flag. This is no different than isr_vector, which is loaded but has the same type and flags. What am I missing here? Should I be looking in the program header?
推荐答案
该地址告诉您该地址在RAM中,因此,除非您的Flash编程器也可以处理SRAM,否则可以通过这种方式消除它们.同样,这也是您处理调试符号的方式,它们的地址为零.
The address tells you that it's in RAM, so unless your flash programmer can also handle SRAM, you can eliminate them that way. Ditto that's how you can handle debug symbols too, their addresses are zero.
这篇关于Arm:objcopy如何知道小精灵的哪些部分要包含在二进制或ihex中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!