Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script.ld/Makefile: Use the maximum ram size available for the stack #455

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile.rules_generic
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@ 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 ($(ENABLE_SDK_WERROR),0)
$(error Deprecated APP_STACK_SIZE define, use APP_STACK_MIN_SIZE if really needed)
else
$(warning Deprecated APP_STACK_SIZE define, use APP_STACK_MIN_SIZE if really needed)
endif
endif
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