Fatal error "Segment loaded at xxxxxxx lands in same 64KB..." again.
Posted: Tue Dec 07, 2021 4:27 am
Hello.
My project on ESP32-C3, i'm use ESP-IDF Master branch.
In my poject some function adresses stored in array of structures, which builded
through macros:
--- modules.h -------------
struct module
{
char const *name;
int (*xcall)(int, int, int);
void (*poll)(void);
};
#define module_t struct module \
__attribute__(( used, section("modules")))
#define DEFINE_MODULE(v,n,i,p) module_t mod_##v =\
{.name = n, \
.xcall = i, \
.poll = p \
};
------
in C sources :
DEFINE_MODULE(aaa, "aaa", foo_aaa, poll_aaa);
DEFINE_MODULE(bbb, "bbb", foo_bbb, poll_bbb);
....
----------------------------
at section "modules".
access to array:
---------------------
extern struct module __start_modules;
extern struct module __stop_modules;
---------------------
It work. But when i'm adding to my progect Wifi support, build is failed :
-----------
Merged 2 ELF sections
A fatal error occurred: Segment loaded at 0x3c0251f0 lands in same 64KB flash
mapping as segment loaded at 0x3c020020. Can't generate binary.
Suggest changing linker script or ELF to merge sections.
ninja: build stopped: subcommand failed.
-----------
"riscv32-esp-elf-objdump -h build/main.elf " output is
-------------------------------
build/main.elf: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .rtc.text 00000000 50000000 50000000 0005e010 2**0
CONTENTS
1 .rtc.dummy 00000000 50000000 50000000 0005e010 2**0
CONTENTS
2 .rtc.force_fast 00000000 50000000 50000000 0005e010 2**0
CONTENTS
3 .rtc.data 00000010 50000000 50000000 0005e000 2**3
CONTENTS, ALLOC, LOAD, DATA
4 .rtc_noinit 00000000 50000010 50000010 0005e010 2**0
CONTENTS
5 .rtc.force_slow 00000000 50000010 50000010 0005e010 2**0
CONTENTS
6 .iram0.text 0000a2fe 40380000 40380000 00033000 2**8
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .dram0.dummy 0000a400 3fc80000 3fc80000 00027000 2**0
ALLOC
8 .dram0.data 00000c38 3fc8a400 3fc8a400 00031400 2**3
CONTENTS, ALLOC, LOAD, DATA
9 .noinit 00000000 3fc8b038 3fc8b038 0005e010 2**0
CONTENTS
10 .dram0.bss 00001300 3fc8b040 3fc8b040 00032038 2**4
ALLOC
11 .flash.text 0001f156 42000020 42000020 0003e020 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .flash_rodata_dummy 00020000 3c000020 3c000020 00001020 2**0
ALLOC
13 .flash.appdesc 00000100 3c020020 3c020020 00021020 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
14 .flash.rodata 000050c0 3c020120 3c020120 00021120 2**4
CONTENTS, ALLOC, LOAD, DATA
15 modules 0000000c 3c0251e0 3c0251e0 000261e0 2**2
CONTENTS, ALLOC, LOAD, DATA
16 .eh_frame 000000d8 3c0251f0 3c0251f0 000261f0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .flash.rodata_noload 00000000 3c0252c8 3c0252c8 0005e010 2**0
CONTENTS
18 .iram0.text_end 00000102 4038a2fe 4038a2fe 0003d2fe 2**0
ALLOC
19 .iram0.data 00000000 4038a400 4038a400 0005e010 2**0
CONTENTS
20 .iram0.bss 00000000 4038a400 4038a400 0005e010 2**0
CONTENTS
21 .dram0.heap_start 00000000 3fc8c340 3fc8c340 0005e010 2**0
CONTENTS
22 .debug_info 0020474b 00000000 00000000 0005e010 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
23 .debug_abbrev 00032378 00000000 00000000 0026275b 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
24 .debug_loc 000686b2 00000000 00000000 00294ad3 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
25 .debug_aranges 000054d0 00000000 00000000 002fd188 2**3
CONTENTS, READONLY, DEBUGGING, OCTETS
26 .debug_ranges 0000e320 00000000 00000000 00302658 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
27 .debug_line 000d4563 00000000 00000000 00310978 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
28 .debug_str 0002df86 00000000 00000000 003e4edb 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
29 .comment 00000025 00000000 00000000 00412e61 2**0
CONTENTS, READONLY
30 .riscv.attributes 00000028 00000000 00000000 00412e86 2**0
CONTENTS, READONLY
31 .debug_frame 00010cac 00000000 00000000 00412eb0 2**2
CONTENTS, READONLY, DEBUGGING, OCTETS
-------------------------------
It's ".flash.appdesc" and "modules" section collision.
What's workaround?
Thanks.
My project on ESP32-C3, i'm use ESP-IDF Master branch.
In my poject some function adresses stored in array of structures, which builded
through macros:
--- modules.h -------------
struct module
{
char const *name;
int (*xcall)(int, int, int);
void (*poll)(void);
};
#define module_t struct module \
__attribute__(( used, section("modules")))
#define DEFINE_MODULE(v,n,i,p) module_t mod_##v =\
{.name = n, \
.xcall = i, \
.poll = p \
};
------
in C sources :
DEFINE_MODULE(aaa, "aaa", foo_aaa, poll_aaa);
DEFINE_MODULE(bbb, "bbb", foo_bbb, poll_bbb);
....
----------------------------
at section "modules".
access to array:
---------------------
extern struct module __start_modules;
extern struct module __stop_modules;
---------------------
It work. But when i'm adding to my progect Wifi support, build is failed :
-----------
Merged 2 ELF sections
A fatal error occurred: Segment loaded at 0x3c0251f0 lands in same 64KB flash
mapping as segment loaded at 0x3c020020. Can't generate binary.
Suggest changing linker script or ELF to merge sections.
ninja: build stopped: subcommand failed.
-----------
"riscv32-esp-elf-objdump -h build/main.elf " output is
-------------------------------
build/main.elf: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .rtc.text 00000000 50000000 50000000 0005e010 2**0
CONTENTS
1 .rtc.dummy 00000000 50000000 50000000 0005e010 2**0
CONTENTS
2 .rtc.force_fast 00000000 50000000 50000000 0005e010 2**0
CONTENTS
3 .rtc.data 00000010 50000000 50000000 0005e000 2**3
CONTENTS, ALLOC, LOAD, DATA
4 .rtc_noinit 00000000 50000010 50000010 0005e010 2**0
CONTENTS
5 .rtc.force_slow 00000000 50000010 50000010 0005e010 2**0
CONTENTS
6 .iram0.text 0000a2fe 40380000 40380000 00033000 2**8
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .dram0.dummy 0000a400 3fc80000 3fc80000 00027000 2**0
ALLOC
8 .dram0.data 00000c38 3fc8a400 3fc8a400 00031400 2**3
CONTENTS, ALLOC, LOAD, DATA
9 .noinit 00000000 3fc8b038 3fc8b038 0005e010 2**0
CONTENTS
10 .dram0.bss 00001300 3fc8b040 3fc8b040 00032038 2**4
ALLOC
11 .flash.text 0001f156 42000020 42000020 0003e020 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .flash_rodata_dummy 00020000 3c000020 3c000020 00001020 2**0
ALLOC
13 .flash.appdesc 00000100 3c020020 3c020020 00021020 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
14 .flash.rodata 000050c0 3c020120 3c020120 00021120 2**4
CONTENTS, ALLOC, LOAD, DATA
15 modules 0000000c 3c0251e0 3c0251e0 000261e0 2**2
CONTENTS, ALLOC, LOAD, DATA
16 .eh_frame 000000d8 3c0251f0 3c0251f0 000261f0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .flash.rodata_noload 00000000 3c0252c8 3c0252c8 0005e010 2**0
CONTENTS
18 .iram0.text_end 00000102 4038a2fe 4038a2fe 0003d2fe 2**0
ALLOC
19 .iram0.data 00000000 4038a400 4038a400 0005e010 2**0
CONTENTS
20 .iram0.bss 00000000 4038a400 4038a400 0005e010 2**0
CONTENTS
21 .dram0.heap_start 00000000 3fc8c340 3fc8c340 0005e010 2**0
CONTENTS
22 .debug_info 0020474b 00000000 00000000 0005e010 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
23 .debug_abbrev 00032378 00000000 00000000 0026275b 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
24 .debug_loc 000686b2 00000000 00000000 00294ad3 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
25 .debug_aranges 000054d0 00000000 00000000 002fd188 2**3
CONTENTS, READONLY, DEBUGGING, OCTETS
26 .debug_ranges 0000e320 00000000 00000000 00302658 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
27 .debug_line 000d4563 00000000 00000000 00310978 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
28 .debug_str 0002df86 00000000 00000000 003e4edb 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
29 .comment 00000025 00000000 00000000 00412e61 2**0
CONTENTS, READONLY
30 .riscv.attributes 00000028 00000000 00000000 00412e86 2**0
CONTENTS, READONLY
31 .debug_frame 00010cac 00000000 00000000 00412eb0 2**2
CONTENTS, READONLY, DEBUGGING, OCTETS
-------------------------------
It's ".flash.appdesc" and "modules" section collision.
What's workaround?
Thanks.