@@ -37,38 +37,32 @@ def calcPhFlg(flags):
3737
3838def image2elf (filename , output_file , verbose = False ):
3939 image = LoadFirmwareImage ('esp32' , filename )
40- section_map = {
41- 'DROM' : '.flash.rodata' ,
42- 'BYTE_ACCESSIBLE, DRAM, DMA' : '.dram0.data' ,
43- 'RTC_IRAM' : '.rtc.text' , # TODO double-check
44- 'IROM' : '.flash.text'
45- }
4640
4741 # parse image name
4842 image_name = image_base_name (filename )
4943
50- # iram is split into .vectors and .text
51- # however, the .vectors section can be identified by its unique 0x400 size
52-
53- section_data = {}
5444 elf = ELF (e_machine = EM .EM_XTENSA , e_data = ELFDATA .ELFDATA2LSB )
5545 elf .Elf .Ehdr .e_entry = image .entrypoint
5646
57- # TODO bss is not accounted for
58- # 00 .flash.rodata
59- # 01 .dram0.data .dram0.bss
60- # 02 .iram0.vectors .iram0.text
61- # 03 .flash.text
6247 print_verbose (verbose , "Entrypoint " + str (hex (image .entrypoint )))
6348
49+ # maps segment names to ELF sections
50+ section_map = {
51+ 'DROM' : '.flash.rodata' ,
52+ 'BYTE_ACCESSIBLE, DRAM, DMA' : '.dram0.data' ,
53+ 'RTC_IRAM' : '.rtc.text' , # TODO double-check
54+ 'IROM' : '.flash.text'
55+ }
56+
6457 section_ids = {}
58+ section_data = {}
6559
66- # map to hold pre-defined elf section attributes
60+ # map to hold pre-defined ELF section attributes
6761 sect_attr_map = {
6862 '.flash.rodata' : {'ES' :0x00 , 'Flg' :'WA' , 'Lk' :0 , 'Inf' :0 , 'Al' :16 },
6963 '.dram0.data' : {'ES' :0x00 , 'Flg' :'WA' , 'Lk' :0 , 'Inf' :0 , 'Al' :16 },
7064 '.iram0.vectors' : {'ES' :0x00 , 'Flg' :'AX' , 'Lk' :0 , 'Inf' :0 , 'Al' :4 },
71- '.iram0.text' : {'ES' :0x00 , 'Flg' :'WAX' , 'Lk' :0 , 'Inf' :0 , 'Al' :4 },
65+ '.iram0.text' : {'ES' :0x00 , 'Flg' :'WAX' , 'Lk' :0 , 'Inf' :0 , 'Al' :4 }, # TODO WAX? or just AX?
7266 '.flash.text' : {'ES' :0x00 , 'Flg' :'AX' , 'Lk' :0 , 'Inf' :0 , 'Al' :4 }
7367 }
7468 # TODO rtc not accounted for
@@ -89,6 +83,7 @@ def image2elf(filename, output_file, verbose=False):
8983
9084 section_name = ''
9185 # handle special case
86+ # iram is split into .vectors and .text
9287 # .iram0.vectors seems to be the first one.
9388 if segment_name == 'IRAM' :
9489 if iram_seen == False :
0 commit comments