Skip to content

Commit ec84a75

Browse files
Dzarda7radimkarnis
authored andcommitted
fix(elf2image): handle PREINIT_ARRAY section type in ESP32-P4 elf file properly
ESP32-P4 ELF files can contain PREINIT_ARRAY sections that were not being properly included in the output binary, causing applications to fail. ESP32-P4 is unique in having a .flash.init_array section in its linker script that collects .preinit_array input sections. Since input sections have different types (PREINIT_ARRAY and INIT_ARRAY), PREINIT_ARRAY is processed first but was not handled correctly by esptool, resulting in its exclusion from the output binary. Other ESP32 variants don't experience this issue because their .preinit_array sections are located in .flash.rodata with PROGBITS type, which is already properly handled.
1 parent 2a92320 commit ec84a75

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

esptool/bin_image.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,14 @@ class ELFFile(object):
12861286
SEC_TYPE_NOBITS = 0x08 # e.g. .bss section
12871287
SEC_TYPE_INITARRAY = 0x0E
12881288
SEC_TYPE_FINIARRAY = 0x0F
1289-
1290-
PROG_SEC_TYPES = (SEC_TYPE_PROGBITS, SEC_TYPE_INITARRAY, SEC_TYPE_FINIARRAY)
1289+
SEC_TYPE_PREINITARRAY = 0x10
1290+
1291+
PROG_SEC_TYPES = (
1292+
SEC_TYPE_PROGBITS,
1293+
SEC_TYPE_INITARRAY,
1294+
SEC_TYPE_FINIARRAY,
1295+
SEC_TYPE_PREINITARRAY,
1296+
)
12911297

12921298
LEN_SEC_HEADER = 0x28
12931299

0 commit comments

Comments
 (0)