diff --git a/Makefile.rules_generic b/Makefile.rules_generic index d5300fc6f..00cca1f69 100644 --- a/Makefile.rules_generic +++ b/Makefile.rules_generic @@ -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 +$(warn 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 diff --git a/target/nanos/script.ld b/target/nanos/script.ld index 88c311626..f9446822d 100644 --- a/target/nanos/script.ld +++ b/target/nanos/script.ld @@ -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); /* @@ -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" ) /****************************************************************/ diff --git a/target/nanos2/script.ld b/target/nanos2/script.ld index 8fd537a6b..8f9b2f308 100644 --- a/target/nanos2/script.ld +++ b/target/nanos2/script.ld @@ -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); @@ -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 */ /****************************************************************/ diff --git a/target/nanox/script.ld b/target/nanox/script.ld index 82b459121..8c42cc4c2 100644 --- a/target/nanox/script.ld +++ b/target/nanox/script.ld @@ -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); @@ -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 */ /****************************************************************/ diff --git a/target/stax/script.ld b/target/stax/script.ld index 19b296a05..bbe3afade 100644 --- a/target/stax/script.ld +++ b/target/stax/script.ld @@ -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); @@ -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 */ /****************************************************************/