Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 603f629

Browse files
committed
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
1 parent 40cd3ba commit 603f629

File tree

2 files changed

+4
-40
lines changed

2 files changed

+4
-40
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"]
77
license = "MIT OR Apache-2.0"
88
name = "cortex-m-rt"
99
repository = "https://github.com/japaric/cortex-m-rt"
10-
version = "0.3.14"
10+
version = "0.4.0"
1111

1212
[dependencies]
1313
cortex-m = "0.3.0"

Diff for: link.x

+3-39
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ EXTERN(EXCEPTIONS);
1212
object file that's passed to the linker *before* this crate */
1313
EXTERN(INTERRUPTS);
1414

15-
PROVIDE(_stack_start = ORIGIN(RAM) + LENGTH(RAM));
15+
_stack_start = ORIGIN(RAM) + LENGTH(RAM);
1616

1717
SECTIONS
1818
{
@@ -48,20 +48,6 @@ SECTIONS
4848
. = ALIGN(4);
4949
} > FLASH
5050

51-
/* limits of the .stack region */
52-
_estack = _stack_start;
53-
/* HACK the `true` case indicates that two RAM regions are being used and
54-
/* that the stack was placed in the second region. In that case we don't know
55-
/* the size of the second RAM region, or its start address, so we just assume
56-
/* its zero sized */
57-
_sstack = _stack_start < ORIGIN(RAM)? _stack_start : ORIGIN(RAM);
58-
59-
/* fictitious region that represents the memory available for the stack */
60-
.stack _sstack (INFO) : ALIGN(4)
61-
{
62-
. += (_estack - _sstack);
63-
}
64-
6551
PROVIDE(_sbss = ORIGIN(RAM));
6652
.bss _sbss : ALIGN(4)
6753
{
@@ -81,15 +67,10 @@ SECTIONS
8167

8268
PROVIDE(_heap_size = 0);
8369

70+
/* The heap starts right after the .bss + .data section ends */
8471
_sheap = _edata;
8572
_eheap = _sheap + _heap_size;
8673

87-
/* fictitious region that represents the memory available for the heap */
88-
.heap _sheap (INFO) : ALIGN(4)
89-
{
90-
. += _heap_size;
91-
}
92-
9374
/* fake output .got section */
9475
/* Dynamic relocations are unsupported. This section is only used to detect
9576
relocatable code in the input files and raise an error if relocatable code
@@ -101,26 +82,9 @@ SECTIONS
10182
_egot = .;
10283
} > RAM AT > FLASH
10384

104-
/* The heap starts right after the .bss + .data section ends */
105-
_sheap = _edata;
106-
107-
/* Due to an unfortunate combination of legacy concerns,
108-
toolchain drawbacks, and insufficient attention to detail,
109-
rustc has no choice but to mark .debug_gdb_scripts as allocatable.
110-
We really do not want to upload it to our target, so we
111-
remove the allocatable bit. Unfortunately, it appears
112-
that the only way to do this in a linker script is
113-
the extremely obscure "INFO" output section type specifier. */
114-
/* a rustc hack will force the program to read the first byte of this section,
115-
so we'll set the (fake) start address of this section to something we're
116-
sure can be read at runtime: the start of the .text section */
117-
.debug_gdb_scripts _stext (INFO) : {
118-
KEEP(*(.debug_gdb_scripts))
119-
}
120-
12185
/DISCARD/ :
12286
{
123-
*(.ARM.exidx.*)
87+
*(.ARM.exidx.*);
12488
}
12589
}
12690

0 commit comments

Comments
 (0)