diff options
author | 2018-04-06 16:15:32 +0200 | |
---|---|---|
committer | 2018-04-09 00:51:25 +0200 | |
commit | aa9c16d736f42b470beb2624cb4cbf931aaec294 (patch) | |
tree | 68646826730a7260c3665b70d5b28620623c5d16 | |
parent | 718da40446e51ace1f3d6433203ecda6dfa4ec20 (diff) | |
download | cortex-m-aa9c16d736f42b470beb2624cb4cbf931aaec294.tar.gz cortex-m-aa9c16d736f42b470beb2624cb4cbf931aaec294.tar.zst cortex-m-aa9c16d736f42b470beb2624cb4cbf931aaec294.zip |
add LLD support
this commit adds LLD support by removing all INFO sections. LLD kind of supports INFO in the form of
NOLOAD but when the linker script contains NOLOAD sections LLD emits a binary with false `size`
information: for example, it reported a fake increase of 20KB in .text and a fake increase of 1KB in
.bss when compiling a program that only allocates a single Box.
As the INFO sections are gone we can no longer support the stack overflow protection added in #43 so
all the other related changes, like making _stack_start overridable, have been removed as well.
If you want to continue using stack overflow protection you can stick to v0.3.x.
As the .debug_gdb_scripts output section has been removed from the linker script these changes will
only reliably support both LD and LLD if/when rust-lang/rust#49728 lands.
closes #53
-rw-r--r-- | cortex-m-rt/Cargo.toml | 2 | ||||
-rw-r--r-- | cortex-m-rt/link.x | 42 |
2 files changed, 4 insertions, 40 deletions
diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index 1b61917..5086034 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"] license = "MIT OR Apache-2.0" name = "cortex-m-rt" repository = "https://github.com/japaric/cortex-m-rt" -version = "0.3.15" +version = "0.4.0" [dependencies] cortex-m = "0.3.0" diff --git a/cortex-m-rt/link.x b/cortex-m-rt/link.x index 4eaa8be..a87a880 100644 --- a/cortex-m-rt/link.x +++ b/cortex-m-rt/link.x @@ -12,7 +12,7 @@ EXTERN(EXCEPTIONS); object file that's passed to the linker *before* this crate */ EXTERN(INTERRUPTS); -PROVIDE(_stack_start = ORIGIN(RAM) + LENGTH(RAM)); +_stack_start = ORIGIN(RAM) + LENGTH(RAM); SECTIONS { @@ -48,20 +48,6 @@ SECTIONS . = ALIGN(4); } > FLASH - /* limits of the .stack region */ - _estack = _stack_start; - /* HACK the `true` case indicates that two RAM regions are being used and - /* that the stack was placed in the second region. In that case we don't know - /* the size of the second RAM region, or its start address, so we just assume - /* its zero sized */ - _sstack = _stack_start < ORIGIN(RAM)? _stack_start : ORIGIN(RAM); - - /* fictitious region that represents the memory available for the stack */ - .stack _sstack (INFO) : ALIGN(4) - { - . += (_estack - _sstack); - } - PROVIDE(_sbss = ORIGIN(RAM)); .bss _sbss : ALIGN(4) { @@ -81,15 +67,10 @@ SECTIONS PROVIDE(_heap_size = 0); + /* The heap starts right after the .bss + .data section ends */ _sheap = _edata; _eheap = _sheap + _heap_size; - /* fictitious region that represents the memory available for the heap */ - .heap _sheap (INFO) : ALIGN(4) - { - . += _heap_size; - } - /* fake output .got section */ /* Dynamic relocations are unsupported. This section is only used to detect relocatable code in the input files and raise an error if relocatable code @@ -101,26 +82,9 @@ SECTIONS _egot = .; } > RAM AT > FLASH - /* The heap starts right after the .bss + .data section ends */ - _sheap = _edata; - - /* Due to an unfortunate combination of legacy concerns, - toolchain drawbacks, and insufficient attention to detail, - rustc has no choice but to mark .debug_gdb_scripts as allocatable. - We really do not want to upload it to our target, so we - remove the allocatable bit. Unfortunately, it appears - that the only way to do this in a linker script is - the extremely obscure "INFO" output section type specifier. */ - /* a rustc hack will force the program to read the first byte of this section, - so we'll set the (fake) start address of this section to something we're - sure can be read at runtime: the start of the .text section */ - .debug_gdb_scripts _stext (INFO) : { - KEEP(*(.debug_gdb_scripts)) - } - /DISCARD/ : { - *(.ARM.exidx.*) + *(.ARM.exidx.*); } } |