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

Issues with stack and heap #56

Merged
merged 1 commit into from
Apr 1, 2024
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
31 changes: 18 additions & 13 deletions ee/linkfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ MEMORY {

REGION_ALIAS("MAIN_REGION", bram);

END_MAIN_REGION = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION);

PHDRS {
text PT_LOAD;
}
Expand All @@ -40,29 +42,21 @@ SECTIONS {
PROVIDE(_etext = .);
PROVIDE(etext = .);

.reginfo : { *(.reginfo) } >MAIN_REGION

/* Global/static constructors and deconstructors. */
.ctors ALIGN(16): {
KEEP(*crtbegin*.o(.ctors))
KEEP(*(EXCLUDE_FILE(*crtend*.o) .ctors))
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
} >MAIN_REGION

.dtors ALIGN(16): {
KEEP(*crtbegin*.o(.dtors))
KEEP(*(EXCLUDE_FILE(*crtend*.o) .dtors))
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
} >MAIN_REGION

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} >MAIN_REGION
.reginfo : { *(.reginfo) } >MAIN_REGION

.data ALIGN(128): {
_fdata = . ;
Expand All @@ -72,6 +66,13 @@ SECTIONS {
SORT(CONSTRUCTORS)
} >MAIN_REGION

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} >MAIN_REGION

.rdata ALIGN(128): { *(.rdata) } >MAIN_REGION
.gcc_except_table ALIGN(128): { *(.gcc_except_table) } >MAIN_REGION

Expand Down Expand Up @@ -108,9 +109,13 @@ SECTIONS {
_end = . ;
PROVIDE(end = .);

/* Symbols needed by crt0.s. */
PROVIDE(_heap_size = -1);
.spad 0x70000000: {
*(.spad)
} >MAIN_REGION

PROVIDE(_stack = .);
PROVIDE(_stack_size = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION) - _stack);
/* Symbols needed by crt0.c. */
/* We set a fixed stack size and the pointer for the stack, letting the remaining memory be the heap. */
PROVIDE(_stack_size = 32 * 1024);
PROVIDE(_stack = END_MAIN_REGION - _stack_size);
PROVIDE(_heap_size = -1);
}
31 changes: 18 additions & 13 deletions ee/linkfile.loadhigh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ MEMORY {

REGION_ALIAS("MAIN_REGION", high);

END_MAIN_REGION = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION);

PHDRS {
text PT_LOAD;
}
Expand All @@ -40,29 +42,21 @@ SECTIONS {
PROVIDE(_etext = .);
PROVIDE(etext = .);

.reginfo : { *(.reginfo) } >MAIN_REGION

/* Global/static constructors and deconstructors. */
.ctors ALIGN(16): {
KEEP(*crtbegin*.o(.ctors))
KEEP(*(EXCLUDE_FILE(*crtend*.o) .ctors))
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
} >MAIN_REGION

.dtors ALIGN(16): {
KEEP(*crtbegin*.o(.dtors))
KEEP(*(EXCLUDE_FILE(*crtend*.o) .dtors))
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
} >MAIN_REGION

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} >MAIN_REGION
.reginfo : { *(.reginfo) } >MAIN_REGION

.data ALIGN(128): {
_fdata = . ;
Expand All @@ -72,6 +66,13 @@ SECTIONS {
SORT(CONSTRUCTORS)
} >MAIN_REGION

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} >MAIN_REGION

.rdata ALIGN(128): { *(.rdata) } >MAIN_REGION
.gcc_except_table ALIGN(128): { *(.gcc_except_table) } >MAIN_REGION

Expand Down Expand Up @@ -108,9 +109,13 @@ SECTIONS {
_end = . ;
PROVIDE(end = .);

/* Symbols needed by crt0.s. */
PROVIDE(_heap_size = -1);
.spad 0x70000000: {
*(.spad)
} >MAIN_REGION

PROVIDE(_stack = .);
PROVIDE(_stack_size = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION) - _stack);
/* Symbols needed by crt0.c. */
/* We set a fixed stack size and the pointer for the stack, letting the remaining memory be the heap. */
PROVIDE(_stack_size = 32 * 1024);
PROVIDE(_stack = END_MAIN_REGION - _stack_size);
PROVIDE(_heap_size = -1);
}