I have an elf file with this sections:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .rtc.text PROGBITS 400c0000 14e3c92 000000 00 W 0 0 1
[ 2] .iram0.vectors PROGBITS 40080000 000074 000400 00 AX 0 0 4
[ 3] devices PROGBITS 3ffb0000 13b2780 000090 00 WA 0 0 4
[ 4] _k_mem_slab_area PROGBITS 3ffb0090 13b2810 000038 00 WA 0 0 4
[ 5] _k_sem_area PROGBITS 3ffb00c8 13b2848 000048 00 WA 0 0 4
[ 6] _k_mutex_area PROGBITS 3ffb0110 13b2890 000014 00 WA 0 0 4
[ 7] _net_buf_pool_are PROGBITS 3ffb0124 13b28a4 000050 00 WA 0 0 4
[ 8] net_if PROGBITS 3ffb0180 13b2900 0000a0 00 WA 0 0 32
[ 9] net_if_dev PROGBITS 3ffb0220 13b29a0 000020 00 WA 0 0 4
[10] initlevel PROGBITS 40080400 000474 000080 00 A 0 0 4
[11] sw_isr_table PROGBITS 40080480 0004f4 000100 00 WA 0 0 4
[12] shell_sections PROGBITS 40080580 0005f4 00002c 00 A 0 0 4
[13] shell_root_cmds_s PROGBITS 400805ac 000620 000040 00 A 0 0 4
[14] text PROGBITS 400805ec 000660 000115 00 AX 0 0 4
[15] .dram0.data PROGBITS 3ffb0240 13b29c0 000128 00 WA 0 0 4
[16] rodata PROGBITS 3ffb0368 13b2ae8 0034d0 00 A 0 0 4
[17] bss NOBITS 3ffb3838 13b5fb8 001900 00 WA 0 0 8
[18] app_noinit PROGBITS 3ffb5138 14e3c92 000000 00 W 0 0 1
[19] noinit NOBITS 3ffb5140 13b5fb8 005e10 00 WA 0 0 16
[20] .intList PROGBITS 3ebfe010 000790 000048 00 WA 0 0 4
[21] .flash.text PROGBITS 400d0018 14d2798 0114fa 00 AX 0 0 4
I'm using a tool that take this elf as input, but can only work with a maximum of 16 sections. As you can see, some of these sections are adjacent.
Is there a way to merge those sections either at link time or just before using the other tool?
I'm using a tool that take this elf as input, but can only work with a maximum of 16 sections. https://github.com/espressif/esptool
Since the tool is open-source, it would be much easier to fix it, then to attempt to work around this limit.
Merging sections that have the same flags and are consecutive is not hard, but may break the code if there are relocations referencing section start/end.
If there are no such relocations, you should look to see why you have all these sections in the first place.