Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit ad3c810

Browse files
committed
make the linker script compatible with lld
To work around a bug in lld, we need to avoid starting the .bss section from a fixed address (previously, the _sbss symbol).
1 parent 0b6bc01 commit ad3c810

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

link.x

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ SECTIONS
2424
*(.rodata .rodata.*);
2525
} > FLASH
2626

27-
PROVIDE(_sbss = ORIGIN(RAM));
28-
.bss ALIGN(_sbss,4) :
27+
.bss :
2928
{
29+
_sbss = .;
3030
*(.bss .bss.*);
3131
. = ALIGN(4);
3232
_ebss = .;
3333
} > RAM
3434

35-
.data _ebss :
35+
.data _ebss : AT(LOADADDR(.rodata) + SIZEOF(.rodata))
3636
{
3737
_sidata = LOADADDR(.data);
3838
_sdata = .;
@@ -41,41 +41,39 @@ SECTIONS
4141
*(.data .data.*);
4242
. = ALIGN(4);
4343
_edata = .;
44-
} > RAM AT > FLASH /* LLD fails on AT > FLASH */
44+
} > RAM
4545

4646
PROVIDE(_heap_size = 0);
4747

4848
/* fictitious region that represents the memory available for the heap */
49-
.heap _edata (INFO) : ALIGN(4)
49+
.heap _edata (NOLOAD) :
5050
{
5151
_sheap = .;
5252
. += _heap_size;
5353
. = ALIGN(4);
5454
_eheap = .;
55-
}
55+
} > RAM
5656

5757
/* fictitious region that represents the memory available for the stack */
58-
.stack _eheap (INFO) : ALIGN(4)
58+
.stack _eheap (NOLOAD) :
5959
{
6060
_estack = .;
6161
. = _stack_start;
6262
_sstack = .;
63-
}
63+
} > RAM
6464

6565
/* fake output .got section */
6666
/* Dynamic relocations are unsupported. This section is only used to detect
6767
relocatable code in the input files and raise an error if relocatable code
6868
is found */
69-
.got :
69+
.got (NOLOAD) :
7070
{
71-
_sgot = .;
7271
KEEP(*(.got .got.*));
73-
_egot = .;
74-
} > RAM AT > FLASH /* LLD fails on AT > FLASH */
72+
}
7573
}
7674

7775
/* Do not exceed this mark in the error messages below | */
78-
ASSERT(_sgot == _egot, "
76+
ASSERT(SIZEOF(.got) == 0, "
7977
.got section detected in the input files. Dynamic relocations are not
8078
supported. If you are linking to C code compiled using the `gcc` crate
8179
then modify your build script to compile the C code _without_ the

0 commit comments

Comments
 (0)