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

Commit 4f83fa6

Browse files
authored
Merge pull request #28 from japaric/got
raise an error if a .got section is found in the input
2 parents 2b08758 + 7b5eb7f commit 4f83fa6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

link.x

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ SECTIONS
5858
_edata = .;
5959
} > RAM AT > FLASH
6060

61+
/* fake output .got section */
62+
/* Dynamic relocations are unsupported. This section is only used to detect
63+
relocatable code in the input files and raise an error if relocatable code
64+
is found */
65+
.got :
66+
{
67+
_sgot = .;
68+
KEEP(*(.got .got.*));
69+
_egot = .;
70+
} > RAM AT > FLASH
71+
6172
/* The heap starts right after the .bss + .data section ends */
6273
_sheap = _edata;
6374

@@ -111,3 +122,10 @@ Set '_stext' to an address greater than '_einterrupts'");
111122
ASSERT(_stext < ORIGIN(FLASH) + LENGTH(FLASH), "
112123
The '.text' section must be placed inside the FLASH memory
113124
Set '_stext' to an address smaller than 'ORIGIN(FLASH) + LENGTH(FLASH)");
125+
126+
ASSERT(_sgot == _egot, "
127+
.got section detected in the input files. Dynamic relocations are not
128+
supported. If you are linking to C code compiled using the `gcc` crate
129+
then modify your build script to compile the C code _without_ the
130+
-fPIC flag. See the documentation of the `gcc::Config.fpic` method for
131+
details.");

0 commit comments

Comments
 (0)