Skip to content

Commit

Permalink
script.ld/Makefile: Use the maximum ram size available for the stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Oct 20, 2023
1 parent ef27df1 commit bf0dbda
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Makefile.rules_generic
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ debug/app.map debug/app.asm: debug/app.%: $(DBG_DIR)/app.%

# link_cmdline(objects,dest) Macro that is used to format arguments for the linker
link_cmdline = $(LD) $(LDFLAGS) -o $(2) $(1)
ifneq ($(APP_STACK_SIZE),)
link_cmdline += -Wl,--defsym=stack_size=$(APP_STACK_SIZE)
ifneq ($(APP_STACK_MIN_SIZE),)
link_cmdline += -Wl,--defsym=stack_min_size=$(APP_STACK_MIN_SIZE)
endif

# cc_cmdline(include,defines,src,dest) Macro that is used to format arguments for the compiler
Expand Down
9 changes: 4 additions & 5 deletions target/nanos/script.ld
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MEMORY
}

PAGE_SIZE = 64;
STACK_SIZE = DEFINED(stack_size) ? stack_size : 1024;
STACK_MIN_SIZE = DEFINED(stack_min_size) ? stack_min_size : 1024;
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);

/*
Expand Down Expand Up @@ -125,15 +125,14 @@ SECTIONS
app_stack_canary = .;
PROVIDE(app_stack_canary = .);
. += 4;
_stack_validation = .;
. = _stack_validation + STACK_SIZE;
_stack = ABSOLUTE(END_STACK) - STACK_SIZE;
PROVIDE( _stack = ABSOLUTE(END_STACK) - STACK_SIZE);
_stack = .;
PROVIDE( _stack = .);
_estack = ABSOLUTE(END_STACK);
PROVIDE( _estack = ABSOLUTE(END_STACK) );

} > SRAM = 0x00

ASSERT( (_estack - _stack) >= STACK_MIN_SIZE, "stack section too small" )


/****************************************************************/
Expand Down
10 changes: 5 additions & 5 deletions target/nanos2/script.ld
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MEMORY
}

PAGE_SIZE = 512;
STACK_SIZE = 1500;
STACK_MIN_SIZE = DEFINED(stack_min_size) ? stack_min_size : 1500;
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);

ENTRY(main);
Expand Down Expand Up @@ -113,15 +113,15 @@ SECTIONS
app_stack_canary = .;
PROVIDE(app_stack_canary = .);
. += 4;
_stack_validation = .;
. = _stack_validation + STACK_SIZE;
_stack = ABSOLUTE(END_STACK) - STACK_SIZE;
PROVIDE( _stack = ABSOLUTE(END_STACK) - STACK_SIZE);
_stack = .;
PROVIDE( _stack = .);
_estack = ABSOLUTE(END_STACK);
PROVIDE( _estack = ABSOLUTE(END_STACK) );

} > SRAM = 0x00

ASSERT( (_estack - _stack) >= STACK_MIN_SIZE, "stack section too small" )

/****************************************************************/
/* DEBUG */
/****************************************************************/
Expand Down
10 changes: 5 additions & 5 deletions target/nanox/script.ld
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MEMORY
}

PAGE_SIZE = 256;
STACK_SIZE = 1500;
STACK_MIN_SIZE = DEFINED(stack_min_size) ? stack_min_size : 1500;
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);

ENTRY(main);
Expand Down Expand Up @@ -124,15 +124,15 @@ SECTIONS
app_stack_canary = .;
PROVIDE(app_stack_canary = .);
. += 4;
_stack_validation = .;
. = _stack_validation + STACK_SIZE;
_stack = ABSOLUTE(END_STACK) - STACK_SIZE;
PROVIDE( _stack = ABSOLUTE(END_STACK) - STACK_SIZE);
_stack = .;
PROVIDE( _stack = .);
_estack = ABSOLUTE(END_STACK);
PROVIDE( _estack = ABSOLUTE(END_STACK) );

} > SRAM

ASSERT( (_estack - _stack) >= STACK_MIN_SIZE, "stack section too small" )

/****************************************************************/
/* DEBUG */
/****************************************************************/
Expand Down
10 changes: 5 additions & 5 deletions target/stax/script.ld
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MEMORY
}

PAGE_SIZE = 512;
STACK_SIZE = 1500;
STACK_MIN_SIZE = DEFINED(stack_min_size) ? stack_min_size : 1500;
END_STACK = ORIGIN(SRAM) + LENGTH(SRAM);

ENTRY(main);
Expand Down Expand Up @@ -114,15 +114,15 @@ SECTIONS
app_stack_canary = .;
PROVIDE(app_stack_canary = .);
. += 4;
_stack_validation = .;
. = _stack_validation + STACK_SIZE;
_stack = ABSOLUTE(END_STACK) - STACK_SIZE;
PROVIDE( _stack = ABSOLUTE(END_STACK) - STACK_SIZE);
_stack = .;
PROVIDE( _stack = .);
_estack = ABSOLUTE(END_STACK);
PROVIDE( _estack = ABSOLUTE(END_STACK) );

} > SRAM = 0x00

ASSERT( (_estack - _stack) >= STACK_MIN_SIZE, "stack section too small" )

/****************************************************************/
/* DEBUG */
/****************************************************************/
Expand Down

0 comments on commit bf0dbda

Please sign in to comment.