Skip to content

Commit c284f35

Browse files
bors[bot]Disasm
andcommitted
Merge #36
36: Fix linker script r=laanwj a=Disasm This PR fixes * section alignment issues * section flags (now both `.heap` and `.stack` are `NOBITS`) * wrong offsets with overridden `_stext` Co-authored-by: Vadim Kaushan <[email protected]>
2 parents 80759f2 + 44c86e2 commit c284f35

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

riscv-rt/link.x

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,15 @@ PROVIDE(__pre_init = default_pre_init);
2020
*/
2121
PROVIDE(_mp_hook = default_mp_hook);
2222

23-
PHDRS
24-
{
25-
load PT_LOAD;
26-
ram_load PT_LOAD;
27-
virtual PT_NULL;
28-
}
29-
3023
SECTIONS
3124
{
32-
.text.dummy ORIGIN(REGION_TEXT) :
25+
.text.dummy (NOLOAD) :
3326
{
3427
/* This section is intended to make _stext address work */
35-
} > REGION_TEXT :virtual
28+
. = _stext;
29+
} > REGION_TEXT
3630

37-
.text ALIGN(_stext,4) :
31+
.text _stext :
3832
{
3933
/* Put reset handler first in .text section so it ends up as the entry */
4034
/* point of the program. */
@@ -45,48 +39,54 @@ SECTIONS
4539
KEEP(*(.trap.rust));
4640

4741
*(.text .text.*);
48-
} > REGION_TEXT :load
42+
} > REGION_TEXT
4943

50-
.rodata ALIGN(4) :
44+
.rodata : ALIGN(4)
5145
{
5246
*(.rodata .rodata.*);
53-
} > REGION_RODATA :load
5447

55-
.data ALIGN(4) :
48+
/* 4-byte align the end (VMA) of this section.
49+
This is required by LLD to ensure the LMA of the following .data
50+
section will have the correct alignment. */
51+
. = ALIGN(4);
52+
} > REGION_RODATA
53+
54+
.data : ALIGN(4)
5655
{
5756
_sidata = LOADADDR(.data);
5857
_sdata = .;
5958
/* Must be called __global_pointer$ for linker relaxations to work. */
6059
PROVIDE(__global_pointer$ = . + 0x800);
60+
*(.sdata .sdata.*);
6161
*(.data .data.*);
6262
. = ALIGN(4);
6363
_edata = .;
64-
} > REGION_DATA AT > REGION_RODATA :ram_load
64+
} > REGION_DATA AT > REGION_RODATA
6565

66-
.bss :
66+
.bss (NOLOAD) :
6767
{
6868
_sbss = .;
6969
*(.sbss .sbss.* .bss .bss.*);
7070
. = ALIGN(4);
7171
_ebss = .;
72-
} > REGION_BSS :virtual
72+
} > REGION_BSS
7373

7474
/* fictitious region that represents the memory available for the heap */
75-
.heap (INFO) :
75+
.heap (NOLOAD) :
7676
{
7777
_sheap = .;
7878
. += _heap_size;
7979
. = ALIGN(4);
8080
_eheap = .;
81-
} > REGION_HEAP :virtual
81+
} > REGION_HEAP
8282

8383
/* fictitious region that represents the memory available for the stack */
84-
.stack (INFO) :
84+
.stack (NOLOAD) :
8585
{
8686
_estack = .;
8787
. = _stack_start;
8888
_sstack = .;
89-
} > REGION_STACK :virtual
89+
} > REGION_STACK
9090

9191
/* fake output .got section */
9292
/* Dynamic relocations are unsupported. This section is only used to detect

0 commit comments

Comments
 (0)