Skip to content

Heap and stack location assigned by compiler (__heap_end, _shadow_stack_base, _stack_cache_base) #18

@torurstrom

Description

@torurstrom

When we use programs that do not fit within the 2 MiB default size, it is necessary to manually set the heap and stack locations, e.g., for a 64 MiB memory (0x04000000 addresses), the symbols may be defined as

-O2 -Wl,--defsym,__heap_end=0x02000000 -Wl,--defsym,_stack_cache_base=0x04000000 -Wl,--defsym,_shadow_stack_base=0x03ff8000

i.e., the heap ends at half the memory size (the heap start is set by the compiler as right after the program), the stack for the first core starts at the end of the memory, and the size of the stack is 0x04000000-0x03ff8000=32 KiB. The second core's stack the starts at 0x03ff8000 and so on.

This can be difficult for users to know and decide on. Another approach is to let the compiler know the memory size, address spaces that are reserved/off limits and the stack size, and then let the compiler decide where to place the heap and stack.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions