Page 1 of 1

使用__attribute__((section (__SEC)))自定义函数section,用于编译优化时候的错误

Posted: Mon Nov 02, 2020 7:38 pm
by vsf_simon
代码里,由于特殊原因,使用了显性的section来定义函数section:

Code: Select all

#define __SECTION(__SEC)      __attribute__((section (__SEC)))
#define SECTION(__SEC)          __SECTION(__SEC)

SECTION("text.vsf.kernel.vsf_thread_get_cur")
vsf_thread_t *vsf_thread_get_cur(void)
{
    return (vsf_thread_t *)vsf_eda_get_cur();
}
但是,连接的时候,会产生错误。
注释掉SECTION就正常,请问这里是否有保留SECTION定义的方式可以通过编译?

错误提示:
A fatal error occurred: Segment loaded at 0x400e1d24 lands in same 64KB flash mapping as segment loaded at 0x400e1cf0. Can't generate binary. Suggest changing linker script or ELF to merge sections.
ninja: build stopped: subcommand failed.

Section信息:
Sections:
Idx Name Size VMA LMA File off Algn
0 .rtc.text 00000000 400c0000 400c0000 00026e52 2**0
CONTENTS
1 .rtc.dummy 00000000 3ff80000 3ff80000 00026e52 2**0
CONTENTS
2 .rtc.force_fast 00000000 3ff80000 3ff80000 00026e52 2**0
CONTENTS
3 .rtc_noinit 00000000 50000000 50000000 00026e52 2**0
CONTENTS
4 .rtc.force_slow 00000000 50000000 50000000 00026e52 2**0
CONTENTS
5 .iram0.vectors 00000403 40080000 40080000 0000a000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
6 .iram0.text 00009ff6 40080404 40080404 0000a404 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .dram0.data 00001f74 3ffb0000 3ffb0000 00008000 2**4
CONTENTS, ALLOC, LOAD, DATA
8 .noinit 00000000 3ffb1f74 3ffb1f74 00026e52 2**0
CONTENTS
9 .dram0.bss 00002a00 3ffb1f78 3ffb1f78 00009f74 2**3
ALLOC
10 .flash.rodata 00006454 3f400020 3f400020 00001020 2**4
CONTENTS, ALLOC, LOAD, DATA
11 .flash.text 00011ccf 400d0020 400d0020 00015020 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 text.vsf.kernel.vsf_thread.literal 00000034 400e1cf0 400e1cf0 00026cf0 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 text.vsf.kernel.vsf_thread_get_cur.literal 00000000 400e1d24 400e1d24 00026d24 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 text.vsf.kernel.vsf_thread 00000124 400e1d24 400e1d24 00026d24 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
15 text.vsf.kernel.vsf_thread_get_cur 0000000a 400e1e48 400e1e48 00026e48 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
16 .iram0.text_end 00000002 4008a3fa 4008a3fa 000143fa 2**0
ALLOC
17 .iram0.data 00000000 4008a3fc 4008a3fc 00026e52 2**0
CONTENTS
18 .iram0.bss 00000000 4008a3fc 4008a3fc 00026e52 2**0
CONTENTS
19 .dram0.heap_start 00000000 3ffb4978 3ffb4978 00026e52 2**0
CONTENTS
20 .xtensa.info 00000038 00000000 00000000 00026e52 2**0
CONTENTS, READONLY
21 .comment 00000065 00000000 00000000 00026e8a 2**0
CONTENTS, READONLY
22 .stab 000101b8 00000000 00000000 00044cc8 2**2
CONTENTS, READONLY, DEBUGGING
23 .stabstr 0001ddd9 00000000 00000000 00026eef 2**0
CONTENTS, READONLY, DEBUGGING
24 .debug_frame 00007598 00000000 00000000 00054e80 2**2
CONTENTS, READONLY, DEBUGGING
25 .debug_info 001727ee 00000000 00000000 0005c418 2**0
CONTENTS, READONLY, DEBUGGING
26 .debug_abbrev 00019907 00000000 00000000 001cec06 2**0
CONTENTS, READONLY, DEBUGGING
27 .debug_loc 0003ce7e 00000000 00000000 001e850d 2**0
CONTENTS, READONLY, DEBUGGING
28 .debug_aranges 00003080 00000000 00000000 00225390 2**3
CONTENTS, READONLY, DEBUGGING
29 .debug_ranges 000053c0 00000000 00000000 00228410 2**3
CONTENTS, READONLY, DEBUGGING
30 .debug_line 0008d20d 00000000 00000000 0022d7d0 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_str 0001a9be 00000000 00000000 002ba9dd 2**0
CONTENTS, READONLY, DEBUGGING

Re: 使用__attribute__((section (__SEC)))自定义函数section,用于编译优化时候的错误

Posted: Tue Nov 03, 2020 2:25 am
by ESP_morris
改成

Code: Select all

.text.vsf.kernel.vsf_thread_get_cur
试试

Re: 使用__attribute__((section (__SEC)))自定义函数section,用于编译优化时候的错误

Posted: Tue Nov 03, 2020 4:31 am
by vsf_simon
OK,加了点就好了