Skip to content

Commit 324f041

Browse files
committed
ldscripts: makefile to select where c++ vtables should be placed
1 parent e1ca870 commit 324f041

File tree

4 files changed

+291
-13
lines changed

4 files changed

+291
-13
lines changed

tools/sdk/ld/Makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
CPP = ../../../tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-cpp
3+
COMMON = eagle.app.v6.common.ld
4+
WARN = "\/\* warning: AUTOGENERATED from $(COMMON)\*.h \*\/"
5+
6+
.PHONY: vtables-dram vtables-iram
7+
8+
all:
9+
@echo "available rules:"
10+
@echo " iram: move c++ vtables to iram (= default in git master repository)"
11+
@echo " heap: move c++ vtables to heap"
12+
13+
heap:
14+
@(echo "$(WARN)"; $(CPP) -E -DVTABLES_IN_DRAM $(COMMON).h | grep -v '^#') > $(COMMON)
15+
@echo "c++ vtables moved to heap"
16+
17+
iram:
18+
@(echo "$(WARN)"; $(CPP) -E -DVTABLES_IN_IRAM $(COMMON).h | grep -v '^#') > $(COMMON)
19+
@echo "c++ vtables moved to iram"

tools/sdk/ld/eagle.app.v6.common.ld

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* This linker script generated from xt-genldscripts.tpp for LSP . */
2-
/* Linker Script for ld -N */
1+
/* warning: AUTOGENERATED from eagle.app.v6.common.ld*.h */
2+
3+
34

45
PHDRS
56
{
@@ -11,7 +12,7 @@ PHDRS
1112
}
1213

1314

14-
/* Default entry point: */
15+
1516
ENTRY(call_user_start)
1617
EXTERN(_DebugExceptionVector)
1718
EXTERN(_DoubleExceptionVector)
@@ -20,7 +21,7 @@ EXTERN(_NMIExceptionVector)
2021
EXTERN(_UserExceptionVector)
2122
EXTERN(core_version)
2223
PROVIDE(_memmap_vecbase_reset = 0x40000000);
23-
/* Various memory-map dependent cache attribute settings: */
24+
2425
_memmap_cacheattr_wb_base = 0x00000110;
2526
_memmap_cacheattr_wt_base = 0x00000110;
2627
_memmap_cacheattr_bp_base = 0x00000220;
@@ -84,12 +85,15 @@ SECTIONS
8485
_data_end = ABSOLUTE(.);
8586
} >dram0_0_seg :dram0_0_phdr
8687

88+
89+
90+
91+
8792
.irom0.text : ALIGN(4)
8893
{
8994
_irom0_text_start = ABSOLUTE(.);
9095
*(.ver_number)
91-
*.c.o( EXCLUDE_FILE (umm_malloc.c.o) .literal*, \
92-
EXCLUDE_FILE (umm_malloc.c.o) .text*)
96+
*.c.o( EXCLUDE_FILE (umm_malloc.c.o) .literal*, EXCLUDE_FILE (umm_malloc.c.o) .text* )
9397
*.cpp.o(.literal*, .text*)
9498
*libc.a:(.literal .text .literal.* .text.*)
9599
*libm.a:(.literal .text .literal.* .text.*)
@@ -154,14 +158,17 @@ SECTIONS
154158
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
155159
*.cpp.o(.iram.text)
156160
*.c.o(.iram.text)
157-
*(.rodata._ZTV*) /* C++ vtables */
161+
162+
*(.rodata._ZTV*)
163+
158164
*(.fini.literal)
159165
*(.fini)
160166
*(.gnu.version)
161167
_text_end = ABSOLUTE(.);
162168
_etext = .;
163169
} >iram1_0_seg :iram1_0_phdr
164170

171+
165172
.rodata : ALIGN(4)
166173
{
167174
_rodata_start = ABSOLUTE(.);
@@ -177,7 +184,7 @@ SECTIONS
177184
*(.gnu.version_r)
178185
*(.eh_frame)
179186
. = (. + 3) & ~ 3;
180-
/* C++ constructor and destructor tables, properly ordered: */
187+
181188
__init_array_start = ABSOLUTE(.);
182189
KEEP (*crtbegin.o(.ctors))
183190
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
@@ -188,15 +195,15 @@ SECTIONS
188195
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
189196
KEEP (*(SORT(.dtors.*)))
190197
KEEP (*(.dtors))
191-
/* C++ exception handlers table: */
198+
192199
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
193200
*(.xt_except_desc)
194201
*(.gnu.linkonce.h.*)
195202
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
196203
*(.xt_except_desc_end)
197204
*(.dynamic)
198205
*(.gnu.version_d)
199-
. = ALIGN(4); /* this table MUST be 4-byte aligned */
206+
. = ALIGN(4);
200207
_bss_table_start = ABSOLUTE(.);
201208
LONG(_bss_start)
202209
LONG(_bss_end)
@@ -224,9 +231,9 @@ SECTIONS
224231
. = ALIGN (8);
225232
_bss_end = ABSOLUTE(.);
226233
_heap_start = ABSOLUTE(.);
227-
/* _stack_sentry = ALIGN(0x8); */
234+
228235
} >dram0_0_seg :dram0_0_bss_phdr
229-
/* __stack = 0x3ffc8000; */
236+
230237

231238
.lit4 : ALIGN(4)
232239
{
@@ -240,5 +247,5 @@ SECTIONS
240247

241248
}
242249

243-
/* get ROM code address */
250+
244251
INCLUDE "../ld/eagle.rom.addr.v6.ld"

tools/sdk/ld/eagle.app.v6.common.ld.h

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/* This linker script generated from xt-genldscripts.tpp for LSP . */
2+
/* Linker Script for ld -N */
3+
4+
PHDRS
5+
{
6+
dport0_0_phdr PT_LOAD;
7+
dram0_0_phdr PT_LOAD;
8+
dram0_0_bss_phdr PT_LOAD;
9+
iram1_0_phdr PT_LOAD;
10+
irom0_0_phdr PT_LOAD;
11+
}
12+
13+
14+
/* Default entry point: */
15+
ENTRY(call_user_start)
16+
EXTERN(_DebugExceptionVector)
17+
EXTERN(_DoubleExceptionVector)
18+
EXTERN(_KernelExceptionVector)
19+
EXTERN(_NMIExceptionVector)
20+
EXTERN(_UserExceptionVector)
21+
EXTERN(core_version)
22+
PROVIDE(_memmap_vecbase_reset = 0x40000000);
23+
/* Various memory-map dependent cache attribute settings: */
24+
_memmap_cacheattr_wb_base = 0x00000110;
25+
_memmap_cacheattr_wt_base = 0x00000110;
26+
_memmap_cacheattr_bp_base = 0x00000220;
27+
_memmap_cacheattr_unused_mask = 0xFFFFF00F;
28+
_memmap_cacheattr_wb_trapnull = 0x2222211F;
29+
_memmap_cacheattr_wba_trapnull = 0x2222211F;
30+
_memmap_cacheattr_wbna_trapnull = 0x2222211F;
31+
_memmap_cacheattr_wt_trapnull = 0x2222211F;
32+
_memmap_cacheattr_bp_trapnull = 0x2222222F;
33+
_memmap_cacheattr_wb_strict = 0xFFFFF11F;
34+
_memmap_cacheattr_wt_strict = 0xFFFFF11F;
35+
_memmap_cacheattr_bp_strict = 0xFFFFF22F;
36+
_memmap_cacheattr_wb_allvalid = 0x22222112;
37+
_memmap_cacheattr_wt_allvalid = 0x22222112;
38+
_memmap_cacheattr_bp_allvalid = 0x22222222;
39+
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
40+
41+
SECTIONS
42+
{
43+
44+
.dport0.rodata : ALIGN(4)
45+
{
46+
_dport0_rodata_start = ABSOLUTE(.);
47+
*(.dport0.rodata)
48+
*(.dport.rodata)
49+
_dport0_rodata_end = ABSOLUTE(.);
50+
} >dport0_0_seg :dport0_0_phdr
51+
52+
.dport0.literal : ALIGN(4)
53+
{
54+
_dport0_literal_start = ABSOLUTE(.);
55+
*(.dport0.literal)
56+
*(.dport.literal)
57+
_dport0_literal_end = ABSOLUTE(.);
58+
} >dport0_0_seg :dport0_0_phdr
59+
60+
.dport0.data : ALIGN(4)
61+
{
62+
_dport0_data_start = ABSOLUTE(.);
63+
*(.dport0.data)
64+
*(.dport.data)
65+
_dport0_data_end = ABSOLUTE(.);
66+
} >dport0_0_seg :dport0_0_phdr
67+
68+
.data : ALIGN(4)
69+
{
70+
_data_start = ABSOLUTE(.);
71+
*(.data)
72+
*(.data.*)
73+
*(.gnu.linkonce.d.*)
74+
*(.data1)
75+
*(.sdata)
76+
*(.sdata.*)
77+
*(.gnu.linkonce.s.*)
78+
*(.sdata2)
79+
*(.sdata2.*)
80+
*(.gnu.linkonce.s2.*)
81+
*(.jcr)
82+
. = ALIGN(4);
83+
_Pri_3_HandlerAddress = ABSOLUTE(.);
84+
_data_end = ABSOLUTE(.);
85+
} >dram0_0_seg :dram0_0_phdr
86+
87+
#ifdef VTABLES_IN_DRAM
88+
#include "eagle.app.v6.common.ld.vtables.h"
89+
#endif
90+
91+
.irom0.text : ALIGN(4)
92+
{
93+
_irom0_text_start = ABSOLUTE(.);
94+
*(.ver_number)
95+
*.c.o( EXCLUDE_FILE (umm_malloc.c.o) .literal*, EXCLUDE_FILE (umm_malloc.c.o) .text* )
96+
*.cpp.o(.literal*, .text*)
97+
*libc.a:(.literal .text .literal.* .text.*)
98+
*libm.a:(.literal .text .literal.* .text.*)
99+
*libgcc.a:_umoddi3.o(.literal .text)
100+
*libgcc.a:_udivdi3.o(.literal .text)
101+
*libsmartconfig.a:(.literal .text .literal.* .text.*)
102+
*libstdc++.a:(.literal .text .literal.* .text.*)
103+
*liblwip_gcc.a:(.literal .text .literal.* .text.*)
104+
*liblwip_src.a:(.literal .text .literal.* .text.*)
105+
*liblwip2.a:(.literal .text .literal.* .text.*)
106+
*liblwip2_1460.a:(.literal .text .literal.* .text.*)
107+
*libaxtls.a:(.literal .text .literal.* .text.*)
108+
*libat.a:(.literal.* .text.*)
109+
*libcrypto.a:(.literal.* .text.*)
110+
*libespnow.a:(.literal.* .text.*)
111+
*libjson.a:(.literal.* .text.*)
112+
*liblwip.a:(.literal.* .text.*)
113+
*libmesh.a:(.literal.* .text.*)
114+
*libnet80211.a:(.literal.* .text.*)
115+
*libsmartconfig.a:(.literal.* .text.*)
116+
*libssl.a:(.literal.* .text.*)
117+
*libupgrade.a:(.literal.* .text.*)
118+
*libwpa.a:(.literal.* .text.*)
119+
*libwpa2.a:(.literal.* .text.*)
120+
*libwps.a:(.literal.* .text.*)
121+
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .irom.text.*)
122+
_irom0_text_end = ABSOLUTE(.);
123+
_flash_code_end = ABSOLUTE(.);
124+
} >irom0_0_seg :irom0_0_phdr
125+
126+
.text : ALIGN(4)
127+
{
128+
_stext = .;
129+
_text_start = ABSOLUTE(.);
130+
*(.UserEnter.text)
131+
. = ALIGN(16);
132+
*(.DebugExceptionVector.text)
133+
. = ALIGN(16);
134+
*(.NMIExceptionVector.text)
135+
. = ALIGN(16);
136+
*(.KernelExceptionVector.text)
137+
LONG(0)
138+
LONG(0)
139+
LONG(0)
140+
LONG(0)
141+
. = ALIGN(16);
142+
*(.UserExceptionVector.text)
143+
LONG(0)
144+
LONG(0)
145+
LONG(0)
146+
LONG(0)
147+
. = ALIGN(16);
148+
*(.DoubleExceptionVector.text)
149+
LONG(0)
150+
LONG(0)
151+
LONG(0)
152+
LONG(0)
153+
. = ALIGN (16);
154+
*(.entry.text)
155+
*(.init.literal)
156+
*(.init)
157+
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
158+
*.cpp.o(.iram.text)
159+
*.c.o(.iram.text)
160+
#ifdef VTABLES_IN_IRAM
161+
*(.rodata._ZTV*) /* C++ vtables */
162+
#endif
163+
*(.fini.literal)
164+
*(.fini)
165+
*(.gnu.version)
166+
_text_end = ABSOLUTE(.);
167+
_etext = .;
168+
} >iram1_0_seg :iram1_0_phdr
169+
170+
#ifdef VTABLES_IN_IRAM
171+
#include "eagle.app.v6.common.ld.vtables.h"
172+
#endif
173+
174+
.lit4 : ALIGN(4)
175+
{
176+
_lit4_start = ABSOLUTE(.);
177+
*(*.lit4)
178+
*(.lit4.*)
179+
*(.gnu.linkonce.lit4.*)
180+
_lit4_end = ABSOLUTE(.);
181+
} >iram1_0_seg :iram1_0_phdr
182+
183+
184+
}
185+
186+
/* get ROM code address */
187+
INCLUDE "../ld/eagle.rom.addr.v6.ld"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.rodata : ALIGN(4)
2+
{
3+
_rodata_start = ABSOLUTE(.);
4+
*(.sdk.version)
5+
*(.rodata)
6+
*(.rodata.*)
7+
*(.gnu.linkonce.r.*)
8+
*(.rodata1)
9+
__XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
10+
*(.xt_except_table)
11+
*(.gcc_except_table)
12+
*(.gnu.linkonce.e.*)
13+
*(.gnu.version_r)
14+
*(.eh_frame)
15+
. = (. + 3) & ~ 3;
16+
/* C++ constructor and destructor tables, properly ordered: */
17+
__init_array_start = ABSOLUTE(.);
18+
KEEP (*crtbegin.o(.ctors))
19+
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
20+
KEEP (*(SORT(.ctors.*)))
21+
KEEP (*(.ctors))
22+
__init_array_end = ABSOLUTE(.);
23+
KEEP (*crtbegin.o(.dtors))
24+
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
25+
KEEP (*(SORT(.dtors.*)))
26+
KEEP (*(.dtors))
27+
/* C++ exception handlers table: */
28+
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
29+
*(.xt_except_desc)
30+
*(.gnu.linkonce.h.*)
31+
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
32+
*(.xt_except_desc_end)
33+
*(.dynamic)
34+
*(.gnu.version_d)
35+
. = ALIGN(4); /* this table MUST be 4-byte aligned */
36+
_bss_table_start = ABSOLUTE(.);
37+
LONG(_bss_start)
38+
LONG(_bss_end)
39+
_bss_table_end = ABSOLUTE(.);
40+
_rodata_end = ABSOLUTE(.);
41+
} >dram0_0_seg :dram0_0_phdr
42+
43+
.bss ALIGN(8) (NOLOAD) : ALIGN(4)
44+
{
45+
. = ALIGN (8);
46+
_bss_start = ABSOLUTE(.);
47+
*(.dynsbss)
48+
*(.sbss)
49+
*(.sbss.*)
50+
*(.gnu.linkonce.sb.*)
51+
*(.scommon)
52+
*(.sbss2)
53+
*(.sbss2.*)
54+
*(.gnu.linkonce.sb2.*)
55+
*(.dynbss)
56+
*(.bss)
57+
*(.bss.*)
58+
*(.gnu.linkonce.b.*)
59+
*(COMMON)
60+
. = ALIGN (8);
61+
_bss_end = ABSOLUTE(.);
62+
_heap_start = ABSOLUTE(.);
63+
/* _stack_sentry = ALIGN(0x8); */
64+
} >dram0_0_seg :dram0_0_bss_phdr
65+
/* __stack = 0x3ffc8000; */

0 commit comments

Comments
 (0)