Skip to content

Commit fbee3ca

Browse files
committed
More documentation in the linker script
1 parent 2fc3516 commit fbee3ca

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

neotron-cortex-m.ld

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Based on the [Rust Embedded Cortex-M crate](https://github.com/rust-embedded/cortex-m).
55
*
66
* Copyright (c) 2016 Jorge Aparicio.
7-
* Copyright (c) 2023 Jonathan 'theJPster' Pallant and the Neotron Developers.
7+
* Copyright (c) 2024 Jonathan 'theJPster' Pallant and the Neotron Developers.
88
*/
99

1010
MEMORY
@@ -26,52 +26,67 @@ ENTRY(app_entry);
2626
/* # Sections */
2727
SECTIONS
2828
{
29-
/* ### .text */
29+
/* ## .text */
30+
/* All the executable code for our program */
3031
.text : ALIGN(4)
3132
{
3233
. = ALIGN(4);
3334
*(.text .text.*);
3435
. = ALIGN(4);
3536
} > RAM
3637

37-
/* ### .rodata */
38+
/* ## .rodata */
39+
/* All the read-only static data for our program */
3840
.rodata : ALIGN(4)
3941
{
4042
. = ALIGN(4);
4143
*(.rodata .rodata.*);
4244
. = ALIGN(4);
4345
} > RAM
4446

45-
/* ### .data */
47+
/* ## .data */
48+
/* All the read-write non-zero-initialised static data for our program */
4649
.data : ALIGN(4)
4750
{
4851
. = ALIGN(4);
4952
*(.data .data.*);
5053
. = ALIGN(4);
5154
} > RAM
5255

53-
/* ### .bss */
56+
/* ## .bss */
57+
/* All the read-write zero-initialised static data for our program */
5458
.bss : ALIGN(4)
5559
{
5660
. = ALIGN(4);
5761
*(.bss .bss.*);
5862
. = ALIGN(4);
5963
} > RAM
6064

61-
/* ### .uninit */
65+
/* ## .uninit */
66+
/* All the read-write uninitialised static data for our program */
6267
.uninit (NOLOAD) : ALIGN(4)
6368
{
6469
. = ALIGN(4);
6570
*(.uninit .uninit.*);
6671
. = ALIGN(4);
6772
} > RAM
6873

74+
/* ## Start of Heap */
75+
/* Newlib's `sbrk` syscall uses the `end` symbol to mark the start of heap
76+
memory. The `sbrk` syscall has a static variable tracking the edge of the
77+
heap (`heap_end`) and that value moves upwards as more heap memory is
78+
required. The `heap_end` value is initialised with the address of the `end`
79+
symbol on first allocation.
80+
81+
See https://github.com/bminor/newlib/blob/master/libgloss/libnosys/sbrk.c
82+
*/
6983
. = ALIGN(4);
7084
end = .;
7185

7286
/* ## .got */
73-
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in
74-
the input files and raise an error if relocatable code is found */
87+
/* Dynamic relocations are unsupported. This section is only used to detect
88+
relocatable code in the input files and raise an error if relocatable code
89+
is found */
7590
.got (NOLOAD) :
7691
{
7792
KEEP(*(.got .got.*));

0 commit comments

Comments
 (0)