Skip to content

Commit e763c9d

Browse files
committed
changed stack to stack macro
1 parent b6bf8a7 commit e763c9d

18 files changed

Lines changed: 66 additions & 179 deletions

File tree

targets/arm/linkerscript/linkerscript.ld

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,64 @@
33
#define COMBINE_STR2(a,b) COMBINE_STRX(a,b)
44
#define COMBINE_STR3(a,b,c) COMBINE_STR2(COMBINE_STR2(a,b),c)
55

6+
/* helper macro to create a section */
7+
#define SECTION_IMPL(name, data) \
8+
.name : \
9+
{ \
10+
data \
11+
}
12+
13+
/* helper macro to create a section with a attribute */
14+
#define SECTION_IMPL_ATTR(name, attr, data) \
15+
.name (attr) : \
16+
{ \
17+
data \
18+
}
19+
20+
/* helper macro to create a alligned section */
21+
#define ALLIGNED_SECTION(name, align, data) \
22+
SECTION_IMPL( \
23+
name, \
24+
. = ALIGN(align); \
25+
data \
26+
)
27+
28+
/* helper macro to create a alligned readonly section */
29+
#define ALLIGNED_READONLY_SECTION(name, align, data) \
30+
SECTION_IMPL_ATTR( \
31+
name, \
32+
READONLY, \
33+
. = ALIGN(align); \
34+
data \
35+
)
36+
637
/* macro to define the vectors section. Should be pointed to the correct memory region */
738
#define VECTORS() \
8-
.vectors (READONLY) : \
9-
{ \
10-
. = ALIGN(4); \
11-
/* vector table */ \
39+
ALLIGNED_READONLY_SECTION( \
40+
vectors, 4, \
1241
KEEP(*(.vectors .vectors.*)); \
13-
. = ALIGN(4); \
14-
}
42+
)
1543

1644
/* macro to define the rodata section */
1745
#define RODATA() \
18-
.rodata (READONLY) : \
46+
ALLIGNED_READONLY_SECTION( \
47+
rodata, 4, \
48+
*(.rodata .rodata.* .gnu.linkonce.r.*); \
49+
)
50+
51+
/* macro to define the stack with a size in bytes */
52+
#define STACK(size) \
53+
.stack (NOLOAD) : \
1954
{ \
2055
. = ALIGN(4); \
21-
/* Constands, strings, etc */ \
22-
*(.rodata .rodata.* .gnu.linkonce.r.*); \
56+
/* provide the __stack_start */ \
57+
PROVIDE(__stack_start = .); \
58+
/* add the size in bytes to the current address */ \
59+
. = . + size; \
60+
/* make sure the size is rounded off to 4 bytes */ \
2361
. = ALIGN(4); \
62+
/* provide the __stack_end */ \
63+
PROVIDE(__stack_end = .); \
2464
}
2565

2666
/* macro to define a init array. Array name is passed as an argument */

targets/chip/atsam3x8e/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,7 @@ SECTIONS
6969
CONSTRUCTOR_SECTION(fini_array) > rom
7070

7171
/* Stack segment */
72-
.stack (NOLOAD) :
73-
{
74-
. = ALIGN(4);
75-
PROVIDE(__stack_start = .);
76-
77-
. = . + STACK_SIZE;
78-
. = ALIGN(4);
79-
80-
PROVIDE(__stack_end = .);
81-
} > ram
72+
STACK(STACK_SIZE) > ram
8273

8374
/* Data that needs to be initialized to a value different than 0 */
8475
.data :

targets/chip/atsam4s2b/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,7 @@ SECTIONS
6969
CONSTRUCTOR_SECTION(fini_array) > rom
7070

7171
/* Stack segment */
72-
.stack (NOLOAD) :
73-
{
74-
. = ALIGN(4);
75-
PROVIDE(__stack_start = .);
76-
77-
. = . + STACK_SIZE;
78-
. = ALIGN(4);
79-
80-
PROVIDE(__stack_end = .);
81-
} > ram
72+
STACK(STACK_SIZE) > ram
8273

8374
/* Data that needs to be initialized to a value different than 0 */
8475
.data :

targets/chip/lpc1752/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,7 @@ SECTIONS
8484
CONSTRUCTOR_SECTION(fini_array) > rom
8585

8686
/* Stack segment */
87-
.stack (NOLOAD) :
88-
{
89-
. = ALIGN(4);
90-
PROVIDE(__stack_start = .);
91-
92-
. = . + STACK_SIZE;
93-
. = ALIGN(4);
94-
95-
PROVIDE(__stack_end = .);
96-
} > ram
87+
STACK(STACK_SIZE) > ram
9788

9889
/* Data that needs to be initialized to a value different than 0 */
9990
.data :

targets/chip/lpc1754/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,7 @@ SECTIONS
8585
CONSTRUCTOR_SECTION(fini_array) > rom
8686

8787
/* Stack segment */
88-
.stack (NOLOAD) :
89-
{
90-
. = ALIGN(4);
91-
PROVIDE(__stack_start = .);
92-
93-
. = . + STACK_SIZE;
94-
. = ALIGN(4);
95-
96-
PROVIDE(__stack_end = .);
97-
} > ram
88+
STACK(STACK_SIZE) > ram
9889

9990
/* Data that needs to be initialized to a value different than 0 */
10091
.data :

targets/chip/lpc1756/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,7 @@ SECTIONS
8585
CONSTRUCTOR_SECTION(fini_array) > rom
8686

8787
/* Stack segment */
88-
.stack (NOLOAD) :
89-
{
90-
. = ALIGN(4);
91-
PROVIDE(__stack_start = .);
92-
93-
. = . + STACK_SIZE;
94-
. = ALIGN(4);
95-
96-
PROVIDE(__stack_end = .);
97-
} > ram
88+
STACK(STACK_SIZE) > ram
9889

9990
/* Data that needs to be initialized to a value different than 0 */
10091
.data :

targets/chip/lpc1759/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,7 @@ SECTIONS
8888
CONSTRUCTOR_SECTION(fini_array) > rom
8989

9090
/* Stack segment */
91-
.stack (NOLOAD) :
92-
{
93-
. = ALIGN(4);
94-
PROVIDE(__stack_start = .);
95-
96-
. = . + STACK_SIZE;
97-
. = ALIGN(4);
98-
99-
PROVIDE(__stack_end = .);
100-
} > ram
91+
STACK(STACK_SIZE) > ram
10192

10293
/* Data that needs to be initialized to a value different than 0 */
10394
.data :

targets/chip/lpc1788/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,7 @@ SECTIONS
9797
CONSTRUCTOR_SECTION(fini_array) > rom
9898

9999
/* Stack segment */
100-
.stack (NOLOAD) :
101-
{
102-
. = ALIGN(4);
103-
PROVIDE(__stack_start = .);
104-
105-
. = . + STACK_SIZE;
106-
. = ALIGN(4);
107-
108-
PROVIDE(__stack_end = .);
109-
} > ram
100+
STACK(STACK_SIZE) > ram
110101

111102
/* Data that needs to be initialized to a value different than 0 */
112103
.data :

targets/chip/lpc55s66/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,7 @@ SECTIONS
7878
CONSTRUCTOR_SECTION(fini_array) > rom
7979

8080
/* Stack segment */
81-
.stack (NOLOAD) :
82-
{
83-
. = ALIGN(4);
84-
PROVIDE(__stack_start = .);
85-
86-
. = . + STACK_SIZE;
87-
. = ALIGN(4);
88-
89-
PROVIDE(__stack_end = .);
90-
} > ram0
81+
STACK(STACK_SIZE) > ram0
9182

9283
/* Data that needs to be initialized to a value different than 0 */
9384
.data :

targets/chip/lpc802/linkerscript.ld

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,7 @@ SECTIONS
7474
CONSTRUCTOR_SECTION(fini_array) > rom
7575

7676
/* Stack segment */
77-
.stack (NOLOAD) :
78-
{
79-
. = ALIGN(4);
80-
PROVIDE(__stack_start = .);
81-
82-
. = . + STACK_SIZE;
83-
. = ALIGN(4);
84-
85-
PROVIDE(__stack_end = .);
86-
} > ram
77+
STACK(STACK_SIZE) > ram
8778

8879
/* Data that needs to be initialized to a value different than 0 */
8980
.data :

0 commit comments

Comments
 (0)