From 282b4dc69aaf61e959bd0973824a87395117d5e7 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 28 Apr 2020 02:48:31 +0200 Subject: [PATCH] link.x: reduce alignment, use all remaining OCM for .stack --- libcortex_a9/src/mmu.rs | 2 -- libsupport_zynq/build.rs | 2 +- libsupport_zynq/link.x | 18 +++++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libcortex_a9/src/mmu.rs b/libcortex_a9/src/mmu.rs index d9be4cc..498884d 100644 --- a/libcortex_a9/src/mmu.rs +++ b/libcortex_a9/src/mmu.rs @@ -101,8 +101,6 @@ pub static mut l1_table: L1Table = L1Table { table: [L1Entry(0); L1_TABLE_SIZE] }; -/// The `#[repr(align(16384))]` is unfortunately ineffective. Hence we -/// require explicit linking to a region defined in the linker script. #[repr(align(16384))] pub struct L1Table { table: [L1Entry; L1_TABLE_SIZE] diff --git a/libsupport_zynq/build.rs b/libsupport_zynq/build.rs index 517830e..a2ce29f 100644 --- a/libsupport_zynq/build.rs +++ b/libsupport_zynq/build.rs @@ -12,7 +12,7 @@ fn main() { .unwrap(); println!("cargo:rustc-link-search={}", out.display()); - // Only re-run the build script when memory.x is changed, + // Only re-run the build script when link.x is changed, // instead of when any part of the source code changes. println!("cargo:rerun-if-changed=link.x"); } diff --git a/libsupport_zynq/link.x b/libsupport_zynq/link.x index bc6bebe..179ca53 100644 --- a/libsupport_zynq/link.x +++ b/libsupport_zynq/link.x @@ -1,7 +1,5 @@ ENTRY(_boot_cores); -STACK_SIZE = 0x8000; - /* Provide some defaults */ PROVIDE(Reset = _boot_cores); PROVIDE(UndefinedInstruction = Reset); @@ -38,21 +36,21 @@ SECTIONS *(.data .data.*); } > OCM - .bss (NOLOAD) : ALIGN(0x4000) + .bss (NOLOAD) : ALIGN(4) { + __bss_start = .; /* Aligned to 16 kB */ KEEP(*(.bss.l1_table)); *(.bss .bss.*); . = ALIGN(4); + __bss_end = .; } > OCM - __bss_start = ADDR(.bss); - __bss_end = ADDR(.bss) + SIZEOF(.bss); - .stack (NOLOAD) : ALIGN(0x1000) { - . += STACK_SIZE; + .stack (NOLOAD) : ALIGN(8) { + __stack_end = .; + . = ORIGIN(OCM) + LENGTH(OCM) - 8; + __stack_start = .; } > OCM - __stack_end = ADDR(.stack); - __stack_start = ADDR(.stack) + SIZEOF(.stack); /DISCARD/ : { @@ -62,3 +60,5 @@ SECTIONS *(.ARM.extab.*); } } + +ASSERT(SIZEOF(.stack) >= 0x8000, "less than 32 KB left for stack");