Skip to content

Commit 29fb80f

Browse files
committed
linker: Factor section arrays into shared include
Move the duplicated linker section array definitions (clicmd, rpcdef, servicedef, httproute, udpinput, ghook, copyhandler, driver) into cpu/section_arrays.ld and INCLUDE it from each architecture and platform linker script. This also adds the previously missing driver array to aarch32.
1 parent c73dd9a commit 29fb80f

5 files changed

Lines changed: 45 additions & 177 deletions

File tree

src/cpu/aarch32/aarch32.ld

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,7 @@ SECTIONS {
2121
KEEP(*(SORT_BY_NAME(.fini_array.*)))
2222
_fini_array_end = .;
2323

24-
. = ALIGN(4);
25-
_clicmd_array_begin = .;
26-
KEEP(*(SORT_BY_NAME(clicmd.*)))
27-
_clicmd_array_end = .;
28-
. = ALIGN(4);
29-
30-
. = ALIGN(4);
31-
_rpcdef_array_begin = .;
32-
KEEP(*(rpcdef))
33-
_rpcdef_array_end = .;
34-
. = ALIGN(4);
35-
36-
. = ALIGN(4);
37-
_servicedef_array_begin = .;
38-
KEEP(*(servicedef))
39-
_servicedef_array_end = .;
40-
. = ALIGN(4);
41-
42-
. = ALIGN(4);
43-
_httproute_array_begin = .;
44-
KEEP(*(httproute))
45-
_httproute_array_end = .;
46-
. = ALIGN(4);
47-
48-
. = ALIGN(4);
49-
_udpinput_array_begin = .;
50-
KEEP(*(udpinput))
51-
_udpinput_array_end = .;
52-
. = ALIGN(4);
53-
54-
. = ALIGN(4);
55-
_ghook_array_begin = .;
56-
KEEP(*(ghook))
57-
_ghook_array_end = .;
58-
. = ALIGN(4);
59-
60-
. = ALIGN(4);
61-
_copyhandler_array_begin = .;
62-
KEEP(*(SORT_BY_NAME(copyhandler.*)))
63-
_copyhandler_array_end = .;
64-
. = ALIGN(4);
24+
INCLUDE cpu/section_arrays.ld
6525

6626
} >RAM
6727

src/cpu/aarch64/aarch64.ld

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,7 @@ SECTIONS {
2727
KEEP(*(SORT_BY_NAME(.fini_array.*)))
2828
_fini_array_end = .;
2929

30-
. = ALIGN(8);
31-
_clicmd_array_begin = .;
32-
KEEP(*(SORT_BY_NAME(clicmd.*)))
33-
_clicmd_array_end = .;
34-
35-
. = ALIGN(8);
36-
_rpcdef_array_begin = .;
37-
KEEP(*(rpcdef))
38-
_rpcdef_array_end = .;
39-
40-
. = ALIGN(8);
41-
_servicedef_array_begin = .;
42-
KEEP(*(servicedef))
43-
_servicedef_array_end = .;
44-
45-
. = ALIGN(8);
46-
_httproute_array_begin = .;
47-
KEEP(*(httproute))
48-
_httproute_array_end = .;
49-
50-
. = ALIGN(8);
51-
_udpinput_array_begin = .;
52-
KEEP(*(udpinput))
53-
_udpinput_array_end = .;
54-
55-
. = ALIGN(8);
56-
_ghook_array_begin = .;
57-
KEEP(*(ghook))
58-
_ghook_array_end = .;
59-
. = ALIGN(8);
60-
61-
. = ALIGN(8);
62-
_driver_array_begin = .;
63-
KEEP(*(SORT_BY_NAME(driver.*)))
64-
_driver_array_end = .;
65-
. = ALIGN(8);
66-
67-
. = ALIGN(8);
68-
_copyhandler_array_begin = .;
69-
KEEP(*(SORT_BY_NAME(copyhandler.*)))
70-
_copyhandler_array_end = .;
71-
. = ALIGN(8);
30+
INCLUDE cpu/section_arrays.ld
7231

7332
. = ALIGN(4096);
7433
_efi_runtime_begin = .;

src/cpu/cortexm/cortexm.ld

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -47,53 +47,7 @@ SECTIONS {
4747
KEEP(*(SORT_BY_NAME(.fini_array.*)))
4848
_fini_array_end = .;
4949

50-
. = ALIGN(4);
51-
_clicmd_array_begin = .;
52-
KEEP(*(SORT_BY_NAME(clicmd.*)))
53-
_clicmd_array_end = .;
54-
. = ALIGN(4);
55-
56-
. = ALIGN(4);
57-
_rpcdef_array_begin = .;
58-
KEEP(*(rpcdef))
59-
_rpcdef_array_end = .;
60-
. = ALIGN(4);
61-
62-
. = ALIGN(4);
63-
_servicedef_array_begin = .;
64-
KEEP(*(servicedef))
65-
_servicedef_array_end = .;
66-
. = ALIGN(4);
67-
68-
. = ALIGN(4);
69-
_httproute_array_begin = .;
70-
KEEP(*(httproute))
71-
_httproute_array_end = .;
72-
. = ALIGN(4);
73-
74-
. = ALIGN(4);
75-
_udpinput_array_begin = .;
76-
KEEP(*(udpinput))
77-
_udpinput_array_end = .;
78-
. = ALIGN(4);
79-
80-
. = ALIGN(4);
81-
_ghook_array_begin = .;
82-
KEEP(*(ghook))
83-
_ghook_array_end = .;
84-
. = ALIGN(4);
85-
86-
. = ALIGN(4);
87-
_copyhandler_array_begin = .;
88-
KEEP(*(SORT_BY_NAME(copyhandler.*)))
89-
_copyhandler_array_end = .;
90-
. = ALIGN(4);
91-
92-
. = ALIGN(4);
93-
_driver_array_begin = .;
94-
KEEP(*(SORT_BY_NAME(driver.*)))
95-
_driver_array_end = .;
96-
. = ALIGN(4);
50+
INCLUDE cpu/section_arrays.ld
9751

9852
} >FLASH
9953

src/cpu/section_arrays.ld

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Shared linker section arrays — INCLUDE this inside a rodata/data section */
2+
3+
. = ALIGN(8);
4+
_clicmd_array_begin = .;
5+
KEEP(*(SORT_BY_NAME(clicmd.*)))
6+
_clicmd_array_end = .;
7+
8+
. = ALIGN(8);
9+
_rpcdef_array_begin = .;
10+
KEEP(*(rpcdef))
11+
_rpcdef_array_end = .;
12+
13+
. = ALIGN(8);
14+
_servicedef_array_begin = .;
15+
KEEP(*(servicedef))
16+
_servicedef_array_end = .;
17+
18+
. = ALIGN(8);
19+
_httproute_array_begin = .;
20+
KEEP(*(httproute))
21+
_httproute_array_end = .;
22+
23+
. = ALIGN(8);
24+
_udpinput_array_begin = .;
25+
KEEP(*(udpinput))
26+
_udpinput_array_end = .;
27+
28+
. = ALIGN(8);
29+
_ghook_array_begin = .;
30+
KEEP(*(ghook))
31+
_ghook_array_end = .;
32+
33+
. = ALIGN(8);
34+
_copyhandler_array_begin = .;
35+
KEEP(*(SORT_BY_NAME(copyhandler.*)))
36+
_copyhandler_array_end = .;
37+
38+
. = ALIGN(8);
39+
_driver_array_begin = .;
40+
KEEP(*(SORT_BY_NAME(driver.*)))
41+
_driver_array_end = .;

src/platform/stm32n6/stm32n6.ld

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -66,53 +66,7 @@ SECTIONS {
6666
KEEP(*(SORT_BY_NAME(.fini_array.*)))
6767
_fini_array_end = .;
6868

69-
. = ALIGN(4);
70-
_clicmd_array_begin = .;
71-
KEEP(*(SORT_BY_NAME(clicmd.*)))
72-
_clicmd_array_end = .;
73-
. = ALIGN(4);
74-
75-
. = ALIGN(4);
76-
_rpcdef_array_begin = .;
77-
KEEP(*(rpcdef))
78-
_rpcdef_array_end = .;
79-
. = ALIGN(4);
80-
81-
. = ALIGN(4);
82-
_servicedef_array_begin = .;
83-
KEEP(*(servicedef))
84-
_servicedef_array_end = .;
85-
. = ALIGN(4);
86-
87-
. = ALIGN(4);
88-
_httproute_array_begin = .;
89-
KEEP(*(httproute))
90-
_httproute_array_end = .;
91-
. = ALIGN(4);
92-
93-
. = ALIGN(4);
94-
_udpinput_array_begin = .;
95-
KEEP(*(udpinput))
96-
_udpinput_array_end = .;
97-
. = ALIGN(4);
98-
99-
. = ALIGN(4);
100-
_ghook_array_begin = .;
101-
KEEP(*(ghook))
102-
_ghook_array_end = .;
103-
. = ALIGN(4);
104-
105-
. = ALIGN(4);
106-
_copyhandler_array_begin = .;
107-
KEEP(*(SORT_BY_NAME(copyhandler.*)))
108-
_copyhandler_array_end = .;
109-
. = ALIGN(4);
110-
111-
. = ALIGN(4);
112-
_driver_array_begin = .;
113-
KEEP(*(SORT_BY_NAME(driver.*)))
114-
_driver_array_end = .;
115-
. = ALIGN(4);
69+
INCLUDE cpu/section_arrays.ld
11670

11771
} >RAM
11872

0 commit comments

Comments
 (0)