Skip to content

Commit 0e1ba0a

Browse files
committed
core/entry_point: Start the heap at app_heap_break
Start the app's head size at the value of app_head_break passed by the kernel. This gives us more space to work with which allows us to create large buffers (such as for passing to/from the HMAC). It also means we do what the kernel expects us to do Signed-off-by: Alistair Francis <[email protected]>
1 parent b0d94d9 commit 0e1ba0a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

core/src/entry_point/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ libtock_codegen::make_read_env_var!("APP_HEAP_SIZE");
8484
/// into the rustc-generated main(). This cannot use mutable global variables or
8585
/// global references to globals until it is done setting up the data segment.
8686
#[no_mangle]
87-
unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, _app_heap_break: usize) -> ! {
87+
unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, app_heap_start: usize) -> ! {
8888
extern "C" {
8989
// This function is created internally by `rustc`. See
9090
// `src/lang_items.rs` for more details.
@@ -122,9 +122,6 @@ unsafe extern "C" fn rust_start(app_start: usize, stacktop: usize, _app_heap_bre
122122
// We get this from the environment to make it easy to set per compile.
123123
let app_heap_size: usize = read_APP_HEAP_SIZE();
124124

125-
// Make the heap start exactly at bss_end. The suggested _app_heap_break
126-
// is almost always going to be too big and leads to us wasting memory.
127-
let app_heap_start = bss_end;
128125
let app_heap_end = app_heap_start + app_heap_size;
129126

130127
// Tell the kernel the new app heap break.

0 commit comments

Comments
 (0)