t_embed.pas 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135
  1. {
  2. Copyright (c) 2005-2017 by Free Pascal Compiler team
  3. This unit implements support import, export, link routines
  4. for the Embedded Target
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit t_embed;
  19. {$i fpcdefs.inc}
  20. interface
  21. implementation
  22. uses
  23. SysUtils,
  24. cutils,cfileutl,cclasses,
  25. globtype,globals,systems,verbose,comphook,cscript,fmodule,i_embed,link,
  26. cpuinfo;
  27. type
  28. TlinkerEmbedded=class(texternallinker)
  29. private
  30. Function WriteResponseFile: Boolean;
  31. public
  32. constructor Create; override;
  33. procedure SetDefaultInfo; override;
  34. function MakeExecutable:boolean; override;
  35. function postprocessexecutable(const fn : string;isdll:boolean):boolean;
  36. end;
  37. { TlinkerEmbedded_SdccSdld - the sdld linker from the SDCC project ( http://sdcc.sourceforge.net/ ) }
  38. TlinkerEmbedded_SdccSdld=class(texternallinker)
  39. private
  40. Function WriteResponseFile: Boolean;
  41. public
  42. { constructor Create; override;}
  43. procedure SetDefaultInfo; override;
  44. function MakeExecutable:boolean; override;
  45. { function postprocessexecutable(const fn : string;isdll:boolean):boolean;}
  46. end;
  47. {*****************************************************************************
  48. TlinkerEmbedded
  49. *****************************************************************************}
  50. Constructor TlinkerEmbedded.Create;
  51. begin
  52. Inherited Create;
  53. SharedLibFiles.doubles:=true;
  54. StaticLibFiles.doubles:=true;
  55. end;
  56. procedure TlinkerEmbedded.SetDefaultInfo;
  57. const
  58. {$ifdef mips}
  59. {$ifdef mipsel}
  60. platform_select='-EL';
  61. {$else}
  62. platform_select='-EB';
  63. {$endif}
  64. {$else}
  65. platform_select='';
  66. {$endif}
  67. begin
  68. with Info do
  69. begin
  70. ExeCmd[1]:='ld -g '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES';
  71. end;
  72. end;
  73. Function TlinkerEmbedded.WriteResponseFile: Boolean;
  74. Var
  75. linkres : TLinkRes;
  76. i : longint;
  77. HPath : TCmdStrListItem;
  78. s,s1,s2 : TCmdStr;
  79. prtobj,
  80. cprtobj : string[80];
  81. linklibc : boolean;
  82. found1,
  83. found2 : boolean;
  84. {$if defined(ARM)}
  85. LinkStr : string;
  86. {$endif}
  87. begin
  88. WriteResponseFile:=False;
  89. linklibc:=(SharedLibFiles.Find('c')<>nil);
  90. {$if defined(ARM) or defined(i386) or defined(x86_64) or defined(AVR) or defined(MIPSEL) or defined(RISCV32) or defined(XTENSA)}
  91. prtobj:='';
  92. {$else}
  93. prtobj:='prt0';
  94. {$endif}
  95. cprtobj:='cprt0';
  96. if linklibc then
  97. prtobj:=cprtobj;
  98. { Open link.res file }
  99. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
  100. { Write path to search libraries }
  101. HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  102. while assigned(HPath) do
  103. begin
  104. s:=HPath.Str;
  105. if (cs_link_on_target in current_settings.globalswitches) then
  106. s:=ScriptFixFileName(s);
  107. LinkRes.Add('-L'+s);
  108. HPath:=TCmdStrListItem(HPath.Next);
  109. end;
  110. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  111. while assigned(HPath) do
  112. begin
  113. s:=HPath.Str;
  114. if s<>'' then
  115. LinkRes.Add('SEARCH_DIR("'+s+'")');
  116. HPath:=TCmdStrListItem(HPath.Next);
  117. end;
  118. LinkRes.Add('INPUT (');
  119. { add objectfiles, start with prt0 always }
  120. //s:=FindObjectFile('prt0','',false);
  121. if prtobj<>'' then
  122. begin
  123. s:=FindObjectFile(prtobj,'',false);
  124. LinkRes.AddFileName(s);
  125. end;
  126. { try to add crti and crtbegin if linking to C }
  127. if linklibc then
  128. begin
  129. if librarysearchpath.FindFile('crtbegin.o',false,s) then
  130. LinkRes.AddFileName(s);
  131. if librarysearchpath.FindFile('crti.o',false,s) then
  132. LinkRes.AddFileName(s);
  133. end;
  134. while not ObjectFiles.Empty do
  135. begin
  136. s:=ObjectFiles.GetFirst;
  137. if s<>'' then
  138. begin
  139. { vlink doesn't use SEARCH_DIR for object files }
  140. if not(cs_link_on_target in current_settings.globalswitches) then
  141. s:=FindObjectFile(s,'',false);
  142. LinkRes.AddFileName((maybequoted(s)));
  143. end;
  144. end;
  145. { Write staticlibraries }
  146. if not StaticLibFiles.Empty then
  147. begin
  148. { vlink doesn't need, and doesn't support GROUP }
  149. if (cs_link_on_target in current_settings.globalswitches) then
  150. begin
  151. LinkRes.Add(')');
  152. LinkRes.Add('GROUP(');
  153. end;
  154. while not StaticLibFiles.Empty do
  155. begin
  156. S:=StaticLibFiles.GetFirst;
  157. LinkRes.AddFileName((maybequoted(s)));
  158. end;
  159. end;
  160. if (cs_link_on_target in current_settings.globalswitches) then
  161. begin
  162. LinkRes.Add(')');
  163. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  164. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  165. linklibc:=false;
  166. while not SharedLibFiles.Empty do
  167. begin
  168. S:=SharedLibFiles.GetFirst;
  169. if s<>'c' then
  170. begin
  171. i:=Pos(target_info.sharedlibext,S);
  172. if i>0 then
  173. Delete(S,i,255);
  174. LinkRes.Add('-l'+s);
  175. end
  176. else
  177. begin
  178. LinkRes.Add('-l'+s);
  179. linklibc:=true;
  180. end;
  181. end;
  182. { be sure that libc&libgcc is the last lib }
  183. if linklibc then
  184. begin
  185. LinkRes.Add('-lc');
  186. LinkRes.Add('-lgcc');
  187. end;
  188. end
  189. else
  190. begin
  191. while not SharedLibFiles.Empty do
  192. begin
  193. S:=SharedLibFiles.GetFirst;
  194. LinkRes.Add('lib'+s+target_info.staticlibext);
  195. end;
  196. LinkRes.Add(')');
  197. end;
  198. { objects which must be at the end }
  199. if linklibc then
  200. begin
  201. found1:=librarysearchpath.FindFile('crtend.o',false,s1);
  202. found2:=librarysearchpath.FindFile('crtn.o',false,s2);
  203. if found1 or found2 then
  204. begin
  205. LinkRes.Add('INPUT(');
  206. if found1 then
  207. LinkRes.AddFileName(s1);
  208. if found2 then
  209. LinkRes.AddFileName(s2);
  210. LinkRes.Add(')');
  211. end;
  212. end;
  213. {$ifdef ARM}
  214. case current_settings.controllertype of
  215. ct_none:
  216. begin
  217. end;
  218. ct_lpc810m021fn8,
  219. ct_lpc811m001fdh16,
  220. ct_lpc812m101fdh16,
  221. ct_lpc812m101fd20,
  222. ct_lpc812m101fdh20,
  223. ct_lpc1110fd20,
  224. ct_lpc1111fdh20_002,
  225. ct_lpc1111fhn33_101,
  226. ct_lpc1111fhn33_102,
  227. ct_lpc1111fhn33_103,
  228. ct_lpc1111fhn33_201,
  229. ct_lpc1111fhn33_202,
  230. ct_lpc1111fhn33_203,
  231. ct_lpc1112fd20_102,
  232. ct_lpc1112fdh20_102,
  233. ct_lpc1112fdh28_102,
  234. ct_lpc1112fhn33_101,
  235. ct_lpc1112fhn33_102,
  236. ct_lpc1112fhn33_103,
  237. ct_lpc1112fhn33_201,
  238. ct_lpc1112fhn24_202,
  239. ct_lpc1112fhn33_202,
  240. ct_lpc1112fhn33_203,
  241. ct_lpc1112fhi33_202,
  242. ct_lpc1112fhi33_203,
  243. ct_lpc1113fhn33_201,
  244. ct_lpc1113fhn33_202,
  245. ct_lpc1113fhn33_203,
  246. ct_lpc1113fhn33_301,
  247. ct_lpc1113fhn33_302,
  248. ct_lpc1113fhn33_303,
  249. ct_lpc1113bfd48_301,
  250. ct_lpc1113bfd48_302,
  251. ct_lpc1113bfd48_303,
  252. ct_lpc1114fdh28_102,
  253. ct_lpc1114fn28_102,
  254. ct_lpc1114fhn33_201,
  255. ct_lpc1114fhn33_202,
  256. ct_lpc1114fhn33_203,
  257. ct_lpc1114fhn33_301,
  258. ct_lpc1114fhn33_302,
  259. ct_lpc1114fhn33_303,
  260. ct_lpc1114fhn33_333,
  261. ct_lpc1114fhi33_302,
  262. ct_lpc1114fhi33_303,
  263. ct_lpc1114bfd48_301,
  264. ct_lpc1114bfd48_302,
  265. ct_lpc1114bfd48_303,
  266. ct_lpc1114bfd48_323,
  267. ct_lpc1114bfd48_333,
  268. ct_lpc1115bfd48_303,
  269. ct_lpc11c12fd48_301,
  270. ct_lpc11c14fd48_301,
  271. ct_lpc11c22fd48_301,
  272. ct_lpc11c24fd48_301,
  273. ct_lpc11d24fd48_301,
  274. ct_lpc1224fbd48_101,
  275. ct_lpc1224fbd48_121,
  276. ct_lpc1224fbd64_101,
  277. ct_lpc1224fbd64_121,
  278. ct_lpc1225fbd48_301,
  279. ct_lpc1225fbd48_321,
  280. ct_lpc1225fbd64_301,
  281. ct_lpc1225fbd64_321,
  282. ct_lpc1226fbd48_301,
  283. ct_lpc1226fbd64_301,
  284. ct_lpc1227fbd48_301,
  285. ct_lpc1227fbd64_301,
  286. ct_lpc12d27fbd100_301,
  287. ct_lpc1311fhn33,
  288. ct_lpc1311fhn33_01,
  289. ct_lpc1313fhn33,
  290. ct_lpc1313fhn33_01,
  291. ct_lpc1313fbd48,
  292. ct_lpc1313fbd48_01,
  293. ct_lpc1315fhn33,
  294. ct_lpc1315fbd48,
  295. ct_lpc1316fhn33,
  296. ct_lpc1316fbd48,
  297. ct_lpc1317fhn33,
  298. ct_lpc1317fbd48,
  299. ct_lpc1317fbd64,
  300. ct_lpc1342fhn33,
  301. ct_lpc1342fbd48,
  302. ct_lpc1343fhn33,
  303. ct_lpc1343fbd48,
  304. ct_lpc1345fhn33,
  305. ct_lpc1345fbd48,
  306. ct_lpc1346fhn33,
  307. ct_lpc1346fbd48,
  308. ct_lpc1347fhn33,
  309. ct_lpc1347fbd48,
  310. ct_lpc1347fbd64,
  311. ct_lpc2114,
  312. ct_lpc2124,
  313. ct_lpc2194,
  314. ct_lpc1768,
  315. ct_at91sam7s256,
  316. ct_at91sam7se256,
  317. ct_at91sam7x256,
  318. ct_at91sam7xc256,
  319. ct_stm32f030c6,
  320. ct_stm32f030c8,
  321. ct_stm32f030f4,
  322. ct_stm32f030k6,
  323. ct_stm32f030r8,
  324. ct_stm32f050c4,
  325. ct_stm32f050c6,
  326. ct_stm32f050f4,
  327. ct_stm32f050f6,
  328. ct_stm32f050g4,
  329. ct_stm32f050g6,
  330. ct_stm32f050k4,
  331. ct_stm32f050k6,
  332. ct_stm32f051c4,
  333. ct_stm32f051c6,
  334. ct_stm32f051c8,
  335. ct_stm32f051k4,
  336. ct_stm32f051k6,
  337. ct_stm32f051k8,
  338. ct_stm32f051r4,
  339. ct_stm32f051r6,
  340. ct_stm32f051r8,
  341. ct_stm32f091cc,
  342. ct_stm32f091cb,
  343. ct_stm32f091rc,
  344. ct_stm32f091rb,
  345. ct_stm32f091vc,
  346. ct_stm32f091vb,
  347. ct_stm32f100x4,
  348. ct_stm32f100x6,
  349. ct_stm32f100x8,
  350. ct_stm32f100xB,
  351. ct_stm32f100xC,
  352. ct_stm32f100xD,
  353. ct_stm32f100xE,
  354. ct_stm32f101x4,
  355. ct_stm32f101x6,
  356. ct_stm32f101x8,
  357. ct_stm32f101xB,
  358. ct_stm32f101xC,
  359. ct_stm32f101xD,
  360. ct_stm32f101xE,
  361. ct_stm32f101xF,
  362. ct_stm32f101xG,
  363. ct_stm32f102x4,
  364. ct_stm32f102x6,
  365. ct_stm32f102x8,
  366. ct_stm32f102xB,
  367. ct_stm32f103x4,
  368. ct_stm32f103x6,
  369. ct_stm32f103x8,
  370. ct_stm32f103xB,
  371. ct_stm32f103xC,
  372. ct_stm32f103xD,
  373. ct_stm32f103xE,
  374. ct_stm32f103xF,
  375. ct_stm32f103xG,
  376. ct_stm32f107x8,
  377. ct_stm32f107xB,
  378. ct_stm32f107xC,
  379. ct_stm32f105r8,
  380. ct_stm32f105rb,
  381. ct_stm32f105rc,
  382. ct_stm32f105v8,
  383. ct_stm32f105vb,
  384. ct_stm32f105vc,
  385. ct_stm32f107rb,
  386. ct_stm32f107rc,
  387. ct_stm32f107vb,
  388. ct_stm32f107vc,
  389. ct_stm32f401cb,
  390. ct_stm32f401rb,
  391. ct_stm32f401vb,
  392. ct_stm32f401cc,
  393. ct_stm32f401rc,
  394. ct_stm32f401vc,
  395. ct_discoveryf401vc,
  396. ct_stm32f401cd,
  397. ct_stm32f401rd,
  398. ct_stm32f401vd,
  399. ct_stm32f401ce,
  400. ct_stm32f401re,
  401. ct_nucleof401re,
  402. ct_stm32f401ve,
  403. ct_stm32f407vg,
  404. ct_discoveryf407vg,
  405. ct_stm32f407ig,
  406. ct_stm32f407zg,
  407. ct_stm32f407ve,
  408. ct_stm32f407ze,
  409. ct_stm32f407ie,
  410. ct_stm32f411cc,
  411. ct_stm32f411rc,
  412. ct_stm32f411vc,
  413. ct_stm32f411ce,
  414. ct_stm32f411re,
  415. ct_nucleof411re,
  416. ct_stm32f411ve,
  417. ct_discoveryf411ve,
  418. ct_stm32f429vg,
  419. ct_stm32f429zg,
  420. ct_stm32f429ig,
  421. ct_stm32f429vi,
  422. ct_stm32f429zi,
  423. ct_discoveryf429zi,
  424. ct_stm32f429ii,
  425. ct_stm32f429ve,
  426. ct_stm32f429ze,
  427. ct_stm32f429ie,
  428. ct_stm32f429bg,
  429. ct_stm32f429bi,
  430. ct_stm32f429be,
  431. ct_stm32f429ng,
  432. ct_stm32f429ni,
  433. ct_stm32f429ne,
  434. ct_stm32f446mc,
  435. ct_stm32f446rc,
  436. ct_stm32f446vc,
  437. ct_stm32f446zc,
  438. ct_stm32f446me,
  439. ct_stm32f446re,
  440. ct_nucleof446re,
  441. ct_stm32f446ve,
  442. ct_stm32f446ze,
  443. ct_stm32f745xe,
  444. ct_stm32f745xg,
  445. ct_stm32f746xe,
  446. ct_stm32f746xg,
  447. ct_stm32f756xe,
  448. ct_stm32f756xg,
  449. ct_stm32g071rb,
  450. ct_nucleog071rb,
  451. { TI - 64 K Flash, 16 K SRAM Devices }
  452. ct_lm3s1110,
  453. ct_lm3s1133,
  454. ct_lm3s1138,
  455. ct_lm3s1150,
  456. ct_lm3s1162,
  457. ct_lm3s1165,
  458. ct_lm3s1166,
  459. ct_lm3s2110,
  460. ct_lm3s2139,
  461. ct_lm3s6100,
  462. ct_lm3s6110,
  463. { TI 128 K Flash, 32 K SRAM devices - Fury Class }
  464. ct_lm3s1601,
  465. ct_lm3s1608,
  466. ct_lm3s1620,
  467. ct_lm3s1635,
  468. ct_lm3s1636,
  469. ct_lm3s1637,
  470. ct_lm3s1651,
  471. ct_lm3s2601,
  472. ct_lm3s2608,
  473. ct_lm3s2620,
  474. ct_lm3s2637,
  475. ct_lm3s2651,
  476. ct_lm3s6610,
  477. ct_lm3s6611,
  478. ct_lm3s6618,
  479. ct_lm3s6633,
  480. ct_lm3s6637,
  481. ct_lm3s8630,
  482. { TI 256 K Flase, 32 K SRAM devices - Fury Class }
  483. ct_lm3s1911,
  484. ct_lm3s1918,
  485. ct_lm3s1937,
  486. ct_lm3s1958,
  487. ct_lm3s1960,
  488. ct_lm3s1968,
  489. ct_lm3s1969,
  490. ct_lm3s2911,
  491. ct_lm3s2918,
  492. ct_lm3s2919,
  493. ct_lm3s2939,
  494. ct_lm3s2948,
  495. ct_lm3s2950,
  496. ct_lm3s2965,
  497. ct_lm3s6911,
  498. ct_lm3s6918,
  499. ct_lm3s6938,
  500. ct_lm3s6950,
  501. ct_lm3s6952,
  502. ct_lm3s6965,
  503. ct_lm3s8930,
  504. ct_lm3s8933,
  505. ct_lm3s8938,
  506. ct_lm3s8962,
  507. ct_lm3s8970,
  508. ct_lm3s8971,
  509. { TI - Tempest Tempest - 256 K Flash, 64 K SRAM }
  510. ct_lm3s5951,
  511. ct_lm3s5956,
  512. ct_lm3s1b21,
  513. ct_lm3s2b93,
  514. ct_lm3s5b91,
  515. ct_lm3s9b81,
  516. ct_lm3s9b90,
  517. ct_lm3s9b92,
  518. ct_lm3s9b95,
  519. ct_lm3s9b96,
  520. ct_lm3s5d51,
  521. { TI - Stellaris something }
  522. ct_lm4f120h5,
  523. { Infineon }
  524. ct_xmc4500x1024,
  525. ct_xmc4500x768,
  526. ct_xmc4502x768,
  527. ct_xmc4504x512,
  528. { Allwinner }
  529. ct_allwinner_a20,
  530. { Freescale }
  531. ct_mk20dx128vfm5,
  532. ct_mk20dx128vft5,
  533. ct_mk20dx128vlf5,
  534. ct_mk20dx128vlh5,
  535. ct_teensy30,
  536. ct_mk20dx128vmp5,
  537. ct_mk20dx32vfm5,
  538. ct_mk20dx32vft5,
  539. ct_mk20dx32vlf5,
  540. ct_mk20dx32vlh5,
  541. ct_mk20dx32vmp5,
  542. ct_mk20dx64vfm5,
  543. ct_mk20dx64vft5,
  544. ct_mk20dx64vlf5,
  545. ct_mk20dx64vlh5,
  546. ct_mk20dx64vmp5,
  547. ct_mk20dx128vlh7,
  548. ct_mk20dx128vlk7,
  549. ct_mk20dx128vll7,
  550. ct_mk20dx128vmc7,
  551. ct_mk20dx256vlh7,
  552. ct_mk20dx256vlk7,
  553. ct_mk20dx256vll7,
  554. ct_mk20dx256vmc7,
  555. ct_teensy31,
  556. ct_teensy32,
  557. ct_mk20dx64vlh7,
  558. ct_mk20dx64vlk7,
  559. ct_mk20dx64vmc7,
  560. ct_mk22fn512cap12,
  561. ct_mk22fn512cbp12,
  562. ct_mk22fn512vdc12,
  563. ct_mk22fn512vlh12,
  564. ct_mk22fn512vll12,
  565. ct_mk22fn512vmp12,
  566. ct_freedom_k22f,
  567. { Atmel }
  568. ct_sam3x8e,
  569. ct_arduino_due,
  570. ct_flip_n_click,
  571. { Nordic Semiconductor }
  572. ct_nrf51422_xxaa,
  573. ct_nrf51422_xxab,
  574. ct_nrf51422_xxac,
  575. ct_nrf51822_xxaa,
  576. ct_nrf51822_xxab,
  577. ct_nrf51822_xxac,
  578. ct_nrf52832_xxaa,
  579. ct_nrf52840_xxaa,
  580. ct_sc32442b,
  581. { Raspberry Pi 2 }
  582. ct_raspi2,
  583. ct_thumb2bare:
  584. begin
  585. with embedded_controllers[current_settings.controllertype] do
  586. with linkres do
  587. begin
  588. if (embedded_controllers[current_settings.controllertype].controllerunitstr='MK20D5')
  589. or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK20D7')
  590. or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK22F51212')
  591. or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK64F12') then
  592. Add('ENTRY(_LOWLEVELSTART)')
  593. else
  594. Add('ENTRY(_START)');
  595. Add('MEMORY');
  596. Add('{');
  597. if flashsize<>0 then
  598. begin
  599. LinkStr := ' flash : ORIGIN = 0x' + IntToHex(flashbase,8)
  600. + ', LENGTH = 0x' + IntToHex(flashsize,8);
  601. Add(LinkStr);
  602. end;
  603. LinkStr := ' ram : ORIGIN = 0x' + IntToHex(srambase,8)
  604. + ', LENGTH = 0x' + IntToHex(sramsize,8);
  605. Add(LinkStr);
  606. Add('}');
  607. Add('_stack_top = 0x' + IntToHex(sramsize+srambase,8) + ';');
  608. // Add Checksum Calculation for LPC Controllers so that the bootloader starts the uploaded binary
  609. writeln(controllerunitstr);
  610. if (controllerunitstr = 'LPC8xx') or (controllerunitstr = 'LPC11XX') or (controllerunitstr = 'LPC122X') then
  611. Add('Startup_Checksum = 0 - (_stack_top + _START + 1 + NonMaskableInt_interrupt + 1 + Hardfault_interrupt + 1);');
  612. if (controllerunitstr = 'LPC13XX') then
  613. Add('Startup_Checksum = 0 - (_stack_top + _START + 1 + NonMaskableInt_interrupt + 1 + MemoryManagement_interrupt + 1 + BusFault_interrupt + 1 + UsageFault_interrupt + 1);');
  614. end;
  615. end
  616. else
  617. if not (cs_link_nolink in current_settings.globalswitches) then
  618. internalerror(200902011);
  619. end;
  620. with linkres do
  621. begin
  622. Add('SECTIONS');
  623. Add('{');
  624. Add(' .text :');
  625. Add(' {');
  626. Add(' _text_start = .;');
  627. Add(' KEEP(*(.init .init.*))');
  628. if (embedded_controllers[current_settings.controllertype].controllerunitstr='MK20D5')
  629. or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK20D7')
  630. or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK22F51212')
  631. or (embedded_controllers[current_settings.controllertype].controllerunitstr='MK64F12') then
  632. begin
  633. Add(' . = 0x400;');
  634. Add(' KEEP(*(.flash_config *.flash_config.*))');
  635. end;
  636. Add(' *(.text .text.*)');
  637. Add(' *(.strings)');
  638. Add(' *(.rodata .rodata.*)');
  639. Add(' *(.comment)');
  640. Add(' . = ALIGN(4);');
  641. Add(' _etext = .;');
  642. if embedded_controllers[current_settings.controllertype].flashsize<>0 then
  643. begin
  644. Add(' } >flash');
  645. Add(' .note.gnu.build-id : { *(.note.gnu.build-id) } >flash ');
  646. end
  647. else
  648. begin
  649. Add(' } >ram');
  650. Add(' .note.gnu.build-id : { *(.note.gnu.build-id) } >ram ');
  651. end;
  652. Add(' .data :');
  653. Add(' {');
  654. Add(' _data = .;');
  655. Add(' *(.data .data.*)');
  656. Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  657. Add(' _edata = .;');
  658. if embedded_controllers[current_settings.controllertype].flashsize<>0 then
  659. begin
  660. Add(' } >ram AT >flash');
  661. end
  662. else
  663. begin
  664. Add(' } >ram');
  665. end;
  666. Add(' .bss :');
  667. Add(' {');
  668. Add(' _bss_start = .;');
  669. Add(' *(.bss .bss.*)');
  670. Add(' *(COMMON)');
  671. Add(' } >ram');
  672. Add('. = ALIGN(4);');
  673. Add('_bss_end = . ;');
  674. Add('}');
  675. Add('_end = .;');
  676. end;
  677. {$endif ARM}
  678. {$ifdef i386}
  679. with linkres do
  680. begin
  681. Add('ENTRY(_START)');
  682. Add('SECTIONS');
  683. Add('{');
  684. Add(' . = 0x100000;');
  685. Add(' .text ALIGN (0x1000) :');
  686. Add(' {');
  687. Add(' _text = .;');
  688. Add(' KEEP(*(.init .init.*))');
  689. Add(' *(.text .text.*)');
  690. Add(' *(.strings)');
  691. Add(' *(.rodata .rodata.*)');
  692. Add(' *(.comment)');
  693. Add(' _etext = .;');
  694. Add(' }');
  695. Add(' .data ALIGN (0x1000) :');
  696. Add(' {');
  697. Add(' _data = .;');
  698. Add(' *(.data .data.*)');
  699. Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  700. Add(' _edata = .;');
  701. Add(' }');
  702. Add(' . = ALIGN(4);');
  703. Add(' .bss :');
  704. Add(' {');
  705. Add(' _bss_start = .;');
  706. Add(' *(.bss .bss.*)');
  707. Add(' *(COMMON)');
  708. Add(' }');
  709. Add('_bss_end = . ;');
  710. Add('}');
  711. Add('_end = .;');
  712. end;
  713. {$endif i386}
  714. {$ifdef x86_64}
  715. with linkres do
  716. begin
  717. Add('ENTRY(_START)');
  718. Add('SECTIONS');
  719. Add('{');
  720. Add(' . = 0x100000;');
  721. Add(' .text ALIGN (0x1000) :');
  722. Add(' {');
  723. Add(' _text = .;');
  724. Add(' KEEP(*(.init .init.*))');
  725. Add(' *(.text .text.*)');
  726. Add(' *(.strings)');
  727. Add(' *(.rodata .rodata.*)');
  728. Add(' *(.comment)');
  729. Add(' _etext = .;');
  730. Add(' }');
  731. Add(' .data ALIGN (0x1000) :');
  732. Add(' {');
  733. Add(' _data = .;');
  734. Add(' *(.data .data.*)');
  735. Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  736. Add(' _edata = .;');
  737. Add(' }');
  738. Add(' . = ALIGN(4);');
  739. Add(' .bss :');
  740. Add(' {');
  741. Add(' _bss_start = .;');
  742. Add(' *(.bss .bss.*)');
  743. Add(' *(COMMON)');
  744. Add(' }');
  745. Add('_bss_end = . ;');
  746. Add('}');
  747. Add('_end = .;');
  748. end;
  749. {$endif x86_64}
  750. {$ifdef AVR}
  751. with linkres do
  752. begin
  753. { linker script from ld 2.19 }
  754. Add('ENTRY(_START)');
  755. Add('OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")');
  756. case current_settings.cputype of
  757. cpu_avr1:
  758. Add('OUTPUT_ARCH(avr:1)');
  759. cpu_avr2:
  760. Add('OUTPUT_ARCH(avr:2)');
  761. cpu_avr25:
  762. Add('OUTPUT_ARCH(avr:25)');
  763. cpu_avr3:
  764. Add('OUTPUT_ARCH(avr:3)');
  765. cpu_avr31:
  766. Add('OUTPUT_ARCH(avr:31)');
  767. cpu_avr35:
  768. Add('OUTPUT_ARCH(avr:35)');
  769. cpu_avr4:
  770. Add('OUTPUT_ARCH(avr:4)');
  771. cpu_avr5:
  772. Add('OUTPUT_ARCH(avr:5)');
  773. cpu_avr51:
  774. Add('OUTPUT_ARCH(avr:51)');
  775. cpu_avr6:
  776. Add('OUTPUT_ARCH(avr:6)');
  777. cpu_avrxmega3:
  778. Add('OUTPUT_ARCH(avr:103)');
  779. cpu_avrtiny:
  780. Add('OUTPUT_ARCH(avr:100)');
  781. else
  782. Internalerror(2015072701);
  783. end;
  784. Add('MEMORY');
  785. with embedded_controllers[current_settings.controllertype] do
  786. begin
  787. Add('{');
  788. Add(' text (rx) : ORIGIN = 0, LENGTH = 0x'+IntToHex(flashsize,6));
  789. Add(' data (rw!x) : ORIGIN = 0x'+IntToHex($800000+srambase,6)+', LENGTH = 0x'+IntToHex(sramsize,6));
  790. Add(' eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 0x'+IntToHex(eepromsize,6));
  791. Add(' fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K');
  792. Add(' lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K');
  793. Add(' signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K');
  794. Add('}');
  795. Add('_stack_top = 0x' + IntToHex(srambase+sramsize-1,4) + ';');
  796. end;
  797. Add('SECTIONS');
  798. Add('{');
  799. Add(' /* Read-only sections, merged into text segment: */');
  800. Add(' .hash : { *(.hash) }');
  801. Add(' .dynsym : { *(.dynsym) }');
  802. Add(' .dynstr : { *(.dynstr) }');
  803. Add(' .gnu.version : { *(.gnu.version) }');
  804. Add(' .gnu.version_d : { *(.gnu.version_d) }');
  805. Add(' .gnu.version_r : { *(.gnu.version_r) }');
  806. Add(' .rel.init : { *(.rel.init) }');
  807. Add(' .rela.init : { *(.rela.init) }');
  808. Add(' .rel.text :');
  809. Add(' {');
  810. Add(' *(.rel.text)');
  811. Add(' *(.rel.text.*)');
  812. Add(' *(.rel.gnu.linkonce.t*)');
  813. Add(' }');
  814. Add(' .rela.text :');
  815. Add(' {');
  816. Add(' *(.rela.text)');
  817. Add(' *(.rela.text.*)');
  818. Add(' *(.rela.gnu.linkonce.t*)');
  819. Add(' }');
  820. Add(' .rel.fini : { *(.rel.fini) }');
  821. Add(' .rela.fini : { *(.rela.fini) }');
  822. Add(' .rel.rodata :');
  823. Add(' {');
  824. Add(' *(.rel.rodata)');
  825. Add(' *(.rel.rodata.*)');
  826. Add(' *(.rel.gnu.linkonce.r*)');
  827. Add(' }');
  828. Add(' .rela.rodata :');
  829. Add(' {');
  830. Add(' *(.rela.rodata)');
  831. Add(' *(.rela.rodata.*)');
  832. Add(' *(.rela.gnu.linkonce.r*)');
  833. Add(' }');
  834. Add(' .rel.data :');
  835. Add(' {');
  836. Add(' *(.rel.data)');
  837. Add(' *(.rel.data.*)');
  838. Add(' *(.rel.gnu.linkonce.d*)');
  839. Add(' }');
  840. Add(' .rela.data :');
  841. Add(' {');
  842. Add(' *(.rela.data)');
  843. Add(' *(.rela.data.*)');
  844. Add(' *(.rela.gnu.linkonce.d*)');
  845. Add(' }');
  846. Add(' .rel.ctors : { *(.rel.ctors) }');
  847. Add(' .rela.ctors : { *(.rela.ctors) }');
  848. Add(' .rel.dtors : { *(.rel.dtors) }');
  849. Add(' .rela.dtors : { *(.rela.dtors) }');
  850. Add(' .rel.got : { *(.rel.got) }');
  851. Add(' .rela.got : { *(.rela.got) }');
  852. Add(' .rel.bss : { *(.rel.bss) }');
  853. Add(' .rela.bss : { *(.rela.bss) }');
  854. Add(' .rel.plt : { *(.rel.plt) }');
  855. Add(' .rela.plt : { *(.rela.plt) }');
  856. Add(' /* Internal text space or external memory. */');
  857. Add(' .text :');
  858. Add(' {');
  859. Add(' KEEP(*(.init .init.*))');
  860. Add(' /* For data that needs to reside in the lower 64k of progmem. */');
  861. Add(' *(.progmem.gcc*)');
  862. Add(' *(.progmem*)');
  863. Add(' . = ALIGN(2);');
  864. Add(' __trampolines_start = . ;');
  865. Add(' /* The jump trampolines for the 16-bit limited relocs will reside here. */');
  866. Add(' *(.trampolines)');
  867. Add(' *(.trampolines*)');
  868. Add(' __trampolines_end = . ;');
  869. Add(' /* For future tablejump instruction arrays for 3 byte pc devices.');
  870. Add(' We don''t relax jump/call instructions within these sections. */');
  871. Add(' *(.jumptables)');
  872. Add(' *(.jumptables*)');
  873. Add(' /* For code that needs to reside in the lower 128k progmem. */');
  874. Add(' *(.lowtext)');
  875. Add(' *(.lowtext*)');
  876. Add(' __ctors_start = . ;');
  877. Add(' *(.ctors)');
  878. Add(' __ctors_end = . ;');
  879. Add(' __dtors_start = . ;');
  880. Add(' *(.dtors)');
  881. Add(' __dtors_end = . ;');
  882. Add(' KEEP(SORT(*)(.ctors))');
  883. Add(' KEEP(SORT(*)(.dtors))');
  884. Add(' /* From this point on, we don''t bother about wether the insns are');
  885. Add(' below or above the 16 bits boundary. */');
  886. Add(' *(.init0) /* Start here after reset. */');
  887. Add(' KEEP (*(.init0))');
  888. Add(' *(.init1)');
  889. Add(' KEEP (*(.init1))');
  890. Add(' *(.init2) /* Clear __zero_reg__, set up stack pointer. */');
  891. Add(' KEEP (*(.init2))');
  892. Add(' *(.init3)');
  893. Add(' KEEP (*(.init3))');
  894. Add(' *(.init4) /* Initialize data and BSS. */');
  895. Add(' KEEP (*(.init4))');
  896. Add(' *(.init5)');
  897. Add(' KEEP (*(.init5))');
  898. Add(' *(.init6) /* C++ constructors. */');
  899. Add(' KEEP (*(.init6))');
  900. Add(' *(.init7)');
  901. Add(' KEEP (*(.init7))');
  902. Add(' *(.init8)');
  903. Add(' KEEP (*(.init8))');
  904. Add(' *(.init9) /* Call main(). */');
  905. Add(' KEEP (*(.init9))');
  906. Add(' *(.text)');
  907. Add(' . = ALIGN(2);');
  908. Add(' *(.text.*)');
  909. Add(' . = ALIGN(2);');
  910. Add(' *(.fini9) /* _exit() starts here. */');
  911. Add(' KEEP (*(.fini9))');
  912. Add(' *(.fini8)');
  913. Add(' KEEP (*(.fini8))');
  914. Add(' *(.fini7)');
  915. Add(' KEEP (*(.fini7))');
  916. Add(' *(.fini6) /* C++ destructors. */');
  917. Add(' KEEP (*(.fini6))');
  918. Add(' *(.fini5)');
  919. Add(' KEEP (*(.fini5))');
  920. Add(' *(.fini4)');
  921. Add(' KEEP (*(.fini4))');
  922. Add(' *(.fini3)');
  923. Add(' KEEP (*(.fini3))');
  924. Add(' *(.fini2)');
  925. Add(' KEEP (*(.fini2))');
  926. Add(' *(.fini1)');
  927. Add(' KEEP (*(.fini1))');
  928. Add(' *(.fini0) /* Infinite loop after program termination. */');
  929. Add(' KEEP (*(.fini0))');
  930. Add(' _etext = . ;');
  931. Add(' } > text');
  932. Add(' .data : AT (ADDR (.text) + SIZEOF (.text))');
  933. Add(' {');
  934. Add(' PROVIDE (__data_start = .) ;');
  935. Add(' *(.data)');
  936. Add(' *(.data*)');
  937. Add(' *(.rodata) /* We need to include .rodata here if gcc is used */');
  938. Add(' *(.rodata*) /* with -fdata-sections. */');
  939. Add(' *(.gnu.linkonce.d*)');
  940. Add(' . = ALIGN(2);');
  941. Add(' _edata = . ;');
  942. Add(' PROVIDE (__data_end = .) ;');
  943. Add(' } > data');
  944. Add(' .bss : AT (ADDR (.bss))');
  945. Add(' {');
  946. Add(' PROVIDE (__bss_start = .) ;');
  947. Add(' *(.bss)');
  948. Add(' *(.bss*)');
  949. Add(' *(COMMON)');
  950. Add(' PROVIDE (__bss_end = .) ;');
  951. Add(' } > data');
  952. Add(' __data_load_start = LOADADDR(.data);');
  953. Add(' __data_load_end = __data_load_start + SIZEOF(.data);');
  954. Add(' /* Global data not cleared after reset. */');
  955. Add(' .noinit :');
  956. Add(' {');
  957. Add(' PROVIDE (__noinit_start = .) ;');
  958. Add(' *(.noinit*)');
  959. Add(' PROVIDE (__noinit_end = .) ;');
  960. Add(' _end = . ;');
  961. Add(' PROVIDE (__heap_start = .) ;');
  962. Add(' } > data');
  963. Add(' .eeprom :');
  964. Add(' {');
  965. Add(' *(.eeprom*)');
  966. Add(' __eeprom_end = . ;');
  967. Add(' } > eeprom');
  968. Add(' .fuse :');
  969. Add(' {');
  970. Add(' KEEP(*(.fuse))');
  971. Add(' KEEP(*(.lfuse))');
  972. Add(' KEEP(*(.hfuse))');
  973. Add(' KEEP(*(.efuse))');
  974. Add(' } > fuse');
  975. Add(' .lock :');
  976. Add(' {');
  977. Add(' KEEP(*(.lock*))');
  978. Add(' } > lock');
  979. Add(' .signature :');
  980. Add(' {');
  981. Add(' KEEP(*(.signature*))');
  982. Add(' } > signature');
  983. Add(' /* Stabs debugging sections. */');
  984. Add(' .stab 0 : { *(.stab) }');
  985. Add(' .stabstr 0 : { *(.stabstr) }');
  986. Add(' .stab.excl 0 : { *(.stab.excl) }');
  987. Add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
  988. Add(' .stab.index 0 : { *(.stab.index) }');
  989. Add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
  990. Add(' .comment 0 : { *(.comment) }');
  991. Add(' /* DWARF debug sections.');
  992. Add(' Symbols in the DWARF debugging sections are relative to the beginning');
  993. Add(' of the section so we begin them at 0. */');
  994. Add(' /* DWARF 1 */');
  995. Add(' .debug 0 : { *(.debug) }');
  996. Add(' .line 0 : { *(.line) }');
  997. Add(' /* GNU DWARF 1 extensions */');
  998. Add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  999. Add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  1000. Add(' /* DWARF 1.1 and DWARF 2 */');
  1001. Add(' .debug_aranges 0 : { *(.debug_aranges) }');
  1002. Add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  1003. Add(' /* DWARF 2 */');
  1004. Add(' .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }');
  1005. Add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  1006. Add(' .debug_line 0 : { *(.debug_line) }');
  1007. Add(' .debug_frame 0 : { *(.debug_frame) }');
  1008. Add(' .debug_str 0 : { *(.debug_str) }');
  1009. Add(' .debug_loc 0 : { *(.debug_loc) }');
  1010. Add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  1011. Add('}');
  1012. end;
  1013. {$endif AVR}
  1014. {$ifdef MIPSEL}
  1015. case current_settings.controllertype of
  1016. ct_none:
  1017. begin
  1018. end;
  1019. ct_pic32mx110f016b,
  1020. ct_pic32mx110f016c,
  1021. ct_pic32mx110f016d,
  1022. ct_pic32mx120f032b,
  1023. ct_pic32mx120f032c,
  1024. ct_pic32mx120f032d,
  1025. ct_pic32mx130f064b,
  1026. ct_pic32mx130f064c,
  1027. ct_pic32mx130f064d,
  1028. ct_pic32mx150f128b,
  1029. ct_pic32mx150f128c,
  1030. ct_pic32mx150f128d,
  1031. ct_pic32mx210f016b,
  1032. ct_pic32mx210f016c,
  1033. ct_pic32mx210f016d,
  1034. ct_pic32mx220f032b,
  1035. ct_pic32mx220f032c,
  1036. ct_pic32mx220f032d,
  1037. ct_pic32mx230f064b,
  1038. ct_pic32mx230f064c,
  1039. ct_pic32mx230f064d,
  1040. ct_pic32mx250f128b,
  1041. ct_pic32mx250f128c,
  1042. ct_pic32mx250f128d,
  1043. ct_pic32mx775f256h,
  1044. ct_pic32mx775f256l,
  1045. ct_pic32mx775f512h,
  1046. ct_pic32mx775f512l,
  1047. ct_pic32mx795f512h,
  1048. ct_pic32mx795f512l:
  1049. begin
  1050. with embedded_controllers[current_settings.controllertype] do
  1051. with linkres do
  1052. begin
  1053. Add('OUTPUT_FORMAT("elf32-tradlittlemips")');
  1054. Add('OUTPUT_ARCH(pic32mx)');
  1055. Add('ENTRY(_reset)');
  1056. Add('PROVIDE(_vector_spacing = 0x00000001);');
  1057. Add('_ebase_address = 0x'+IntToHex(flashbase,8)+';');
  1058. Add('_RESET_ADDR = 0xBFC00000;');
  1059. Add('_BEV_EXCPT_ADDR = 0xBFC00380;');
  1060. Add('_DBG_EXCPT_ADDR = 0xBFC00480;');
  1061. Add('_GEN_EXCPT_ADDR = _ebase_address + 0x180;');
  1062. Add('MEMORY');
  1063. Add('{');
  1064. if flashsize<>0 then
  1065. begin
  1066. Add(' kseg0_program_mem : ORIGIN = 0x'+IntToHex(flashbase,8)+', LENGTH = 0x'+IntToHex(flashsize,8));
  1067. //TODO This should better be placed into the controllertype records
  1068. Add(' kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0xbef');
  1069. Add(' config3 : ORIGIN = 0xBFC00BF0, LENGTH = 0x4');
  1070. Add(' config2 : ORIGIN = 0xBFC00BF4, LENGTH = 0x4');
  1071. Add(' config1 : ORIGIN = 0xBFC00BF8, LENGTH = 0x4');
  1072. Add(' config0 : ORIGIN = 0xBFC00BFC, LENGTH = 0x4');
  1073. end;
  1074. Add(' ram : ORIGIN = 0x' + IntToHex(srambase,8)
  1075. + ', LENGTH = 0x' + IntToHex(sramsize,8));
  1076. Add('}');
  1077. Add('_stack_top = 0x' + IntToHex(sramsize+srambase,8) + ';');
  1078. end;
  1079. end
  1080. end;
  1081. with linkres do
  1082. begin
  1083. Add('SECTIONS');
  1084. Add('{');
  1085. Add(' .reset _RESET_ADDR :');
  1086. Add(' {');
  1087. Add(' KEEP(*(.reset .reset.*))');
  1088. Add(' KEEP(*(.startup .startup.*))');
  1089. Add(' } > kseg1_boot_mem');
  1090. Add(' .bev_excpt _BEV_EXCPT_ADDR :');
  1091. Add(' {');
  1092. Add(' KEEP(*(.bev_handler))');
  1093. Add(' } > kseg1_boot_mem');
  1094. Add(' .text :');
  1095. Add(' {');
  1096. Add(' _text_start = .;');
  1097. Add(' . = _text_start + 0x180;');
  1098. Add(' KEEP(*(.gen_handler))');
  1099. Add(' . = _text_start + 0x200;');
  1100. Add(' KEEP(*(.init .init.*))');
  1101. Add(' *(.text .text.*)');
  1102. Add(' *(.strings)');
  1103. Add(' *(.rodata .rodata.*)');
  1104. Add(' *(.comment)');
  1105. Add(' _etext = .;');
  1106. if embedded_controllers[current_settings.controllertype].flashsize<>0 then
  1107. begin
  1108. Add(' } >kseg0_program_mem');
  1109. end
  1110. else
  1111. begin
  1112. Add(' } >ram');
  1113. end;
  1114. Add(' .note.gnu.build-id : { *(.note.gnu.build-id) }');
  1115. Add(' .data :');
  1116. Add(' {');
  1117. Add(' _data = .;');
  1118. Add(' *(.data .data.*)');
  1119. Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  1120. Add(' . = .;');
  1121. Add(' _gp = ALIGN(16) + 0x7ff0;');
  1122. Add(' _edata = .;');
  1123. if embedded_controllers[current_settings.controllertype].flashsize<>0 then
  1124. begin
  1125. Add(' } >ram AT >kseg0_program_mem');
  1126. end
  1127. else
  1128. begin
  1129. Add(' } >ram');
  1130. end;
  1131. Add(' .config_BFC00BF0 : {');
  1132. Add(' KEEP(*(.config_BFC00BF0))');
  1133. Add(' } > config3');
  1134. Add(' .config_BFC00BF4 : {');
  1135. Add(' KEEP(*(.config_BFC00BF4))');
  1136. Add(' } > config2');
  1137. Add(' .config_BFC00BF8 : {');
  1138. Add(' KEEP(*(.config_BFC00BF8))');
  1139. Add(' } > config1');
  1140. Add(' .config_BFC00BFC : {');
  1141. Add(' KEEP(*(.config_BFC00BFC))');
  1142. Add(' } > config0');
  1143. Add(' .bss :');
  1144. Add(' {');
  1145. Add(' _bss_start = .;');
  1146. Add(' *(.bss .bss.*)');
  1147. Add(' *(COMMON)');
  1148. Add(' } >ram');
  1149. Add('. = ALIGN(4);');
  1150. Add('_bss_end = . ;');
  1151. Add(' .comment 0 : { *(.comment) }');
  1152. Add(' /* DWARF debug sections.');
  1153. Add(' Symbols in the DWARF debugging sections are relative to the beginning');
  1154. Add(' of the section so we begin them at 0. */');
  1155. Add(' /* DWARF 1 */');
  1156. Add(' .debug 0 : { *(.debug) }');
  1157. Add(' .line 0 : { *(.line) }');
  1158. Add(' /* GNU DWARF 1 extensions */');
  1159. Add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  1160. Add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  1161. Add(' /* DWARF 1.1 and DWARF 2 */');
  1162. Add(' .debug_aranges 0 : { *(.debug_aranges) }');
  1163. Add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  1164. Add(' /* DWARF 2 */');
  1165. Add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  1166. Add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  1167. Add(' /DISCARD/ : { *(.debug_line) }');
  1168. Add(' .debug_frame 0 : { *(.debug_frame) }');
  1169. Add(' .debug_str 0 : { *(.debug_str) }');
  1170. Add(' /DISCARD/ : { *(.debug_loc) }');
  1171. Add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  1172. Add(' /* SGI/MIPS DWARF 2 extensions */');
  1173. Add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  1174. Add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  1175. Add(' .debug_typenames 0 : { *(.debug_typenames) }');
  1176. Add(' .debug_varnames 0 : { *(.debug_varnames) }');
  1177. Add(' /* DWARF 3 */');
  1178. Add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
  1179. Add(' .debug_ranges 0 : { *(.debug_ranges) }');
  1180. Add(' .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }');
  1181. Add(' .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }');
  1182. Add(' .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }');
  1183. Add(' .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) }');
  1184. Add(' .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) }');
  1185. Add(' .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) }');
  1186. Add(' .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) }');
  1187. Add(' .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) }');
  1188. Add(' .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) }');
  1189. Add(' /DISCARD/ : { *(.rel.dyn) }');
  1190. Add(' /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }');
  1191. Add('}');
  1192. Add('_end = .;');
  1193. end;
  1194. {$endif MIPSEL}
  1195. {$ifdef RISCV32}
  1196. with linkres do
  1197. begin
  1198. Add('OUTPUT_ARCH("riscv")');
  1199. Add('ENTRY(_START)');
  1200. Add('MEMORY');
  1201. with embedded_controllers[current_settings.controllertype] do
  1202. begin
  1203. Add('{');
  1204. Add(' flash (rx) : ORIGIN = 0x'+IntToHex(flashbase,6)+', LENGTH = 0x'+IntToHex(flashsize,6));
  1205. Add(' ram (rw!x) : ORIGIN = 0x'+IntToHex(srambase,6)+', LENGTH = 0x'+IntToHex(sramsize,6));
  1206. Add('}');
  1207. Add('_stack_top = 0x' + IntToHex(srambase+sramsize-1,4) + ';');
  1208. end;
  1209. Add('SECTIONS');
  1210. Add('{');
  1211. Add(' .text :');
  1212. Add(' {');
  1213. Add(' _text_start = .;');
  1214. Add(' KEEP(*(.init .init.*))');
  1215. Add(' *(.text .text.*)');
  1216. Add(' *(.strings)');
  1217. Add(' *(.rodata .rodata.*)');
  1218. Add(' *(.comment)');
  1219. Add(' . = ALIGN(4);');
  1220. Add(' _etext = .;');
  1221. if embedded_controllers[current_settings.controllertype].flashsize<>0 then
  1222. begin
  1223. Add(' } >flash');
  1224. //Add(' .note.gnu.build-id : { *(.note.gnu.build-id) } >flash ');
  1225. end
  1226. else
  1227. begin
  1228. Add(' } >ram');
  1229. //Add(' .note.gnu.build-id : { *(.note.gnu.build-id) } >ram ');
  1230. end;
  1231. Add(' .data :');
  1232. Add(' {');
  1233. Add(' _data = .;');
  1234. Add(' *(.data .data.*)');
  1235. Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  1236. Add(' _edata = .;');
  1237. if embedded_controllers[current_settings.controllertype].flashsize<>0 then
  1238. begin
  1239. Add(' } >ram AT >flash');
  1240. end
  1241. else
  1242. begin
  1243. Add(' } >ram');
  1244. end;
  1245. Add(' .bss :');
  1246. Add(' {');
  1247. Add(' _bss_start = .;');
  1248. Add(' *(.bss .bss.*)');
  1249. Add(' *(COMMON)');
  1250. Add(' } >ram');
  1251. Add(' . = ALIGN(4);');
  1252. Add(' _bss_end = . ;');
  1253. Add(' /* Stabs debugging sections. */');
  1254. Add(' .stab 0 : { *(.stab) }');
  1255. Add(' .stabstr 0 : { *(.stabstr) }');
  1256. Add(' .stab.excl 0 : { *(.stab.excl) }');
  1257. Add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
  1258. Add(' .stab.index 0 : { *(.stab.index) }');
  1259. Add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
  1260. Add(' .comment 0 : { *(.comment) }');
  1261. Add(' /* DWARF debug sections.');
  1262. Add(' Symbols in the DWARF debugging sections are relative to the beginning');
  1263. Add(' of the section so we begin them at 0. */');
  1264. Add(' /* DWARF 1 */');
  1265. Add(' .debug 0 : { *(.debug) }');
  1266. Add(' .line 0 : { *(.line) }');
  1267. Add(' /* GNU DWARF 1 extensions */');
  1268. Add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  1269. Add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  1270. Add(' /* DWARF 1.1 and DWARF 2 */');
  1271. Add(' .debug_aranges 0 : { *(.debug_aranges) }');
  1272. Add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  1273. Add(' /* DWARF 2 */');
  1274. Add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  1275. Add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  1276. Add(' .debug_line 0 : { *(.debug_line) }');
  1277. Add(' .debug_frame 0 : { *(.debug_frame) }');
  1278. Add(' .debug_str 0 : { *(.debug_str) }');
  1279. Add(' .debug_loc 0 : { *(.debug_loc) }');
  1280. Add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  1281. Add(' /* SGI/MIPS DWARF 2 extensions */');
  1282. Add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  1283. Add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  1284. Add(' .debug_typenames 0 : { *(.debug_typenames) }');
  1285. Add(' .debug_varnames 0 : { *(.debug_varnames) }');
  1286. Add(' /* DWARF 3 */');
  1287. Add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
  1288. Add(' .debug_ranges 0 : { *(.debug_ranges) }');
  1289. Add('}');
  1290. Add('_end = .;');
  1291. end;
  1292. {$endif RISCV32}
  1293. {$ifdef XTENSA}
  1294. with linkres do
  1295. begin
  1296. Add('/* Script for -z combreloc: combine and sort reloc sections */');
  1297. Add('/* Copyright (C) 2014-2018 Free Software Foundation, Inc.');
  1298. Add(' Copying and distribution of this script, with or without modification,');
  1299. Add(' are permitted in any medium without royalty provided the copyright');
  1300. Add(' notice and this notice are preserved. */');
  1301. Add('ENTRY(_start)');
  1302. Add('SEARCH_DIR("=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");');
  1303. Add('SECTIONS');
  1304. Add('{');
  1305. Add(' /* Read-only sections, merged into text segment: */');
  1306. Add(' PROVIDE (__executable_start = 0x400000); . = 0x400000 + SIZEOF_HEADERS;');
  1307. Add(' .interp : { *(.interp) }');
  1308. Add(' .note.gnu.build-id : { *(.note.gnu.build-id) }');
  1309. Add(' .hash : { *(.hash) }');
  1310. Add(' .gnu.hash : { *(.gnu.hash) }');
  1311. Add(' .dynsym : { *(.dynsym) }');
  1312. Add(' .dynstr : { *(.dynstr) }');
  1313. Add(' .gnu.version : { *(.gnu.version) }');
  1314. Add(' .gnu.version_d : { *(.gnu.version_d) }');
  1315. Add(' .gnu.version_r : { *(.gnu.version_r) }');
  1316. Add(' .rela.dyn :');
  1317. Add(' {');
  1318. Add(' *(.rela.init)');
  1319. Add(' *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)');
  1320. Add(' *(.rela.fini)');
  1321. Add(' *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)');
  1322. Add(' *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)');
  1323. Add(' *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)');
  1324. Add(' *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)');
  1325. Add(' *(.rela.ctors)');
  1326. Add(' *(.rela.dtors)');
  1327. Add(' *(.rela.got)');
  1328. Add(' *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)');
  1329. Add(' }');
  1330. Add(' .rela.plt : { *(.rela.plt) }');
  1331. Add(' /* .plt* sections are embedded in .text */');
  1332. Add(' .text :');
  1333. Add(' {');
  1334. Add(' *(.got.plt* .plt*)');
  1335. Add(' KEEP (*(.init.literal))');
  1336. Add(' KEEP (*(SORT_NONE(.init)))');
  1337. Add(' *(.literal .text .stub .literal.* .text.* .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)');
  1338. Add(' /* .gnu.warning sections are handled specially by elf32.em. */');
  1339. Add(' *(.gnu.warning)');
  1340. Add(' KEEP (*(.fini.literal))');
  1341. Add(' KEEP (*(SORT_NONE(.fini)))');
  1342. Add(' } =0');
  1343. Add(' PROVIDE (__etext = .);');
  1344. Add(' PROVIDE (_etext = .);');
  1345. Add(' PROVIDE (etext = .);');
  1346. Add(' .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }');
  1347. Add(' .rodata1 : { *(.rodata1) }');
  1348. Add(' .got.loc : { *(.got.loc) }');
  1349. Add(' .xt_except_table : ONLY_IF_RO { KEEP (*(.xt_except_table .xt_except_table.* .gnu.linkonce.e.*)) }');
  1350. Add(' .eh_frame_hdr : { *(.eh_frame_hdr) }');
  1351. Add(' .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }');
  1352. Add(' .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }');
  1353. Add(' /* Adjust the address for the data segment. We want to adjust up to');
  1354. Add(' the same address within the page on the next page up. */');
  1355. Add(' . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));');
  1356. Add(' /* Exception handling */');
  1357. Add(' .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }');
  1358. Add(' .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }');
  1359. Add(' /* Thread Local Storage sections */');
  1360. Add(' .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }');
  1361. Add(' .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }');
  1362. Add(' .preinit_array :');
  1363. Add(' {');
  1364. Add(' PROVIDE_HIDDEN (__preinit_array_start = .);');
  1365. Add(' KEEP (*(.preinit_array))');
  1366. Add(' PROVIDE_HIDDEN (__preinit_array_end = .);');
  1367. Add(' }');
  1368. Add(' .init_array :');
  1369. Add(' {');
  1370. Add(' PROVIDE_HIDDEN (__init_array_start = .);');
  1371. Add(' KEEP (*(SORT(.init_array.*)))');
  1372. Add(' KEEP (*(.init_array))');
  1373. Add(' PROVIDE_HIDDEN (__init_array_end = .);');
  1374. Add(' }');
  1375. Add(' .fini_array :');
  1376. Add(' {');
  1377. Add(' PROVIDE_HIDDEN (__fini_array_start = .);');
  1378. Add(' KEEP (*(SORT(.fini_array.*)))');
  1379. Add(' KEEP (*(.fini_array))');
  1380. Add(' PROVIDE_HIDDEN (__fini_array_end = .);');
  1381. Add(' }');
  1382. Add(' .ctors :');
  1383. Add(' {');
  1384. Add(' /* gcc uses crtbegin.o to find the start of');
  1385. Add(' the constructors, so we make sure it is');
  1386. Add(' first. Because this is a wildcard, it');
  1387. Add(' doesn''t matter if the user does not');
  1388. Add(' actually link against crtbegin.o; the');
  1389. Add(' linker won''t look for a file to match a');
  1390. Add(' wildcard. The wildcard also means that it');
  1391. Add(' doesn''t matter which directory crtbegin.o');
  1392. Add(' is in. */');
  1393. Add(' KEEP (*crtbegin.o(.ctors))');
  1394. Add(' KEEP (*crtbegin?.o(.ctors))');
  1395. Add(' /* We don''t want to include the .ctor section from');
  1396. Add(' the crtend.o file until after the sorted ctors.');
  1397. Add(' The .ctor section from the crtend file contains the');
  1398. Add(' end of ctors marker and it must be last */');
  1399. Add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))');
  1400. Add(' KEEP (*(SORT(.ctors.*)))');
  1401. Add(' KEEP (*(.ctors))');
  1402. Add(' }');
  1403. Add(' .dtors :');
  1404. Add(' {');
  1405. Add(' KEEP (*crtbegin.o(.dtors))');
  1406. Add(' KEEP (*crtbegin?.o(.dtors))');
  1407. Add(' KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))');
  1408. Add(' KEEP (*(SORT(.dtors.*)))');
  1409. Add(' KEEP (*(.dtors))');
  1410. Add(' }');
  1411. Add(' .jcr : { KEEP (*(.jcr)) }');
  1412. Add(' .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }');
  1413. Add(' .xt_except_table : ONLY_IF_RW { KEEP (*(.xt_except_table .xt_except_table.* .gnu.linkonce.e.*)) }');
  1414. Add(' .dynamic : { *(.dynamic) }');
  1415. Add(' .got : { *(.got) }');
  1416. Add(' .data :');
  1417. Add(' {');
  1418. Add(' *(.data .data.* .gnu.linkonce.d.*)');
  1419. Add(' SORT(CONSTRUCTORS)');
  1420. Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))');
  1421. Add(' }');
  1422. Add(' .data1 : { *(.data1) }');
  1423. Add(' .xt_except_desc :');
  1424. Add(' {');
  1425. Add(' *(.xt_except_desc .xt_except_desc.* .gnu.linkonce.h.*)');
  1426. Add(' *(.xt_except_desc_end)');
  1427. Add(' }');
  1428. Add(' .lit4 :');
  1429. Add(' {');
  1430. Add(' PROVIDE (_lit4_start = .);');
  1431. Add(' *(.lit4 .lit4.* .gnu.linkonce.lit4.*)');
  1432. Add(' PROVIDE (_lit4_end = .);');
  1433. Add(' }');
  1434. Add(' _edata = .; PROVIDE (edata = .);');
  1435. Add(' __bss_start = .;');
  1436. Add(' .bss :');
  1437. Add(' {');
  1438. Add(' *(.dynbss)');
  1439. Add(' *(.bss .bss.* .gnu.linkonce.b.*)');
  1440. Add(' *(COMMON)');
  1441. Add(' /* Align here to ensure that the .bss section occupies space up to');
  1442. Add(' _end. Align after .bss to ensure correct alignment even if the');
  1443. Add(' .bss section disappears because there are no input sections.');
  1444. Add(' FIXME: Why do we need it? When there is no .bss section, we don''t');
  1445. Add(' pad the .data section. */');
  1446. Add(' . = ALIGN(. != 0 ? 32 / 8 : 1);');
  1447. Add(' }');
  1448. Add(' . = ALIGN(32 / 8);');
  1449. Add(' . = ALIGN(32 / 8);');
  1450. Add(' _end = .; PROVIDE (end = .);');
  1451. Add(' /* Stabs debugging sections. */');
  1452. Add(' .stab 0 : { *(.stab) }');
  1453. Add(' .stabstr 0 : { *(.stabstr) }');
  1454. Add(' .stab.excl 0 : { *(.stab.excl) }');
  1455. Add(' .stab.exclstr 0 : { *(.stab.exclstr) }');
  1456. Add(' .stab.index 0 : { *(.stab.index) }');
  1457. Add(' .stab.indexstr 0 : { *(.stab.indexstr) }');
  1458. Add(' .comment 0 : { *(.comment) }');
  1459. Add(' /* DWARF debug sections.');
  1460. Add(' Symbols in the DWARF debugging sections are relative to the beginning');
  1461. Add(' of the section so we begin them at 0. */');
  1462. Add(' /* DWARF 1 */');
  1463. Add(' .debug 0 : { *(.debug) }');
  1464. Add(' .line 0 : { *(.line) }');
  1465. Add(' /* GNU DWARF 1 extensions */');
  1466. Add(' .debug_srcinfo 0 : { *(.debug_srcinfo) }');
  1467. Add(' .debug_sfnames 0 : { *(.debug_sfnames) }');
  1468. Add(' /* DWARF 1.1 and DWARF 2 */');
  1469. Add(' .debug_aranges 0 : { *(.debug_aranges) }');
  1470. Add(' .debug_pubnames 0 : { *(.debug_pubnames) }');
  1471. Add(' /* DWARF 2 */');
  1472. Add(' .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }');
  1473. Add(' .debug_abbrev 0 : { *(.debug_abbrev) }');
  1474. Add(' .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }');
  1475. Add(' .debug_frame 0 : { *(.debug_frame) }');
  1476. Add(' .debug_str 0 : { *(.debug_str) }');
  1477. Add(' .debug_loc 0 : { *(.debug_loc) }');
  1478. Add(' .debug_macinfo 0 : { *(.debug_macinfo) }');
  1479. Add(' /* SGI/MIPS DWARF 2 extensions */');
  1480. Add(' .debug_weaknames 0 : { *(.debug_weaknames) }');
  1481. Add(' .debug_funcnames 0 : { *(.debug_funcnames) }');
  1482. Add(' .debug_typenames 0 : { *(.debug_typenames) }');
  1483. Add(' .debug_varnames 0 : { *(.debug_varnames) }');
  1484. Add(' /* DWARF 3 */');
  1485. Add(' .debug_pubtypes 0 : { *(.debug_pubtypes) }');
  1486. Add(' .debug_ranges 0 : { *(.debug_ranges) }');
  1487. Add(' /* DWARF Extension. */');
  1488. Add(' .debug_macro 0 : { *(.debug_macro) }');
  1489. Add(' .debug_addr 0 : { *(.debug_addr) }');
  1490. Add(' .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }');
  1491. Add(' .xt.lit 0 : { KEEP (*(.xt.lit .xt.lit.* .gnu.linkonce.p.*)) }');
  1492. Add(' .xt.insn 0 : { KEEP (*(.xt.insn .gnu.linkonce.x.*)) }');
  1493. Add(' .xt.prop 0 : { KEEP (*(.xt.prop .xt.prop.* .gnu.linkonce.prop.*)) }');
  1494. Add(' /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }');
  1495. Add('}');
  1496. end;
  1497. {$endif XTENSA}
  1498. { Write and Close response }
  1499. linkres.writetodisk;
  1500. linkres.free;
  1501. WriteResponseFile:=True;
  1502. end;
  1503. function TlinkerEmbedded.MakeExecutable:boolean;
  1504. var
  1505. binstr,
  1506. cmdstr,
  1507. mapstr: TCmdStr;
  1508. success : boolean;
  1509. StaticStr,
  1510. GCSectionsStr,
  1511. DynLinkStr,
  1512. StripStr,
  1513. FixedExeFileName: string;
  1514. begin
  1515. { for future use }
  1516. StaticStr:='';
  1517. StripStr:='';
  1518. mapstr:='';
  1519. DynLinkStr:='';
  1520. FixedExeFileName:=maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.elf')));
  1521. GCSectionsStr:='--gc-sections';
  1522. //if not(cs_link_extern in current_settings.globalswitches) then
  1523. if not(cs_link_nolink in current_settings.globalswitches) then
  1524. Message1(exec_i_linking,current_module.exefilename);
  1525. if (cs_link_map in current_settings.globalswitches) then
  1526. mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
  1527. { Write used files and libraries }
  1528. WriteResponseFile();
  1529. { Call linker }
  1530. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  1531. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  1532. if not(cs_link_on_target in current_settings.globalswitches) then
  1533. begin
  1534. Replace(cmdstr,'$EXE',FixedExeFileName);
  1535. Replace(cmdstr,'$RES',(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
  1536. Replace(cmdstr,'$STATIC',StaticStr);
  1537. Replace(cmdstr,'$STRIP',StripStr);
  1538. Replace(cmdstr,'$MAP',mapstr);
  1539. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  1540. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  1541. end
  1542. else
  1543. begin
  1544. Replace(cmdstr,'$EXE',FixedExeFileName);
  1545. Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
  1546. Replace(cmdstr,'$STATIC',StaticStr);
  1547. Replace(cmdstr,'$STRIP',StripStr);
  1548. Replace(cmdstr,'$MAP',mapstr);
  1549. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  1550. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  1551. end;
  1552. success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false);
  1553. { Remove ReponseFile }
  1554. if success and not(cs_link_nolink in current_settings.globalswitches) then
  1555. DeleteFile(outputexedir+Info.ResName);
  1556. { Post process }
  1557. if success and not(cs_link_nolink in current_settings.globalswitches) then
  1558. success:=PostProcessExecutable(FixedExeFileName,false);
  1559. if success and (target_info.system in [system_arm_embedded,system_avr_embedded,system_mipsel_embedded,system_xtensa_embedded]) then
  1560. begin
  1561. success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+
  1562. FixedExeFileName+' '+
  1563. maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.hex'))),true,false);
  1564. if success then
  1565. success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+
  1566. FixedExeFileName+' '+
  1567. maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),true,false);
  1568. {$ifdef ARM}
  1569. if success and (current_settings.controllertype = ct_raspi2) then
  1570. success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+ FixedExeFileName + ' kernel7.img',true,false);
  1571. {$endif ARM}
  1572. end;
  1573. MakeExecutable:=success; { otherwise a recursive call to link method }
  1574. end;
  1575. function TLinkerEmbedded.postprocessexecutable(const fn : string;isdll:boolean):boolean;
  1576. type
  1577. TElf32header=packed record
  1578. magic0123 : longint;
  1579. file_class : byte;
  1580. data_encoding : byte;
  1581. file_version : byte;
  1582. padding : array[$07..$0f] of byte;
  1583. e_type : word;
  1584. e_machine : word;
  1585. e_version : longint;
  1586. e_entry : longint; { entrypoint }
  1587. e_phoff : longint; { program header offset }
  1588. e_shoff : longint; { sections header offset }
  1589. e_flags : longint;
  1590. e_ehsize : word; { elf header size in bytes }
  1591. e_phentsize : word; { size of an entry in the program header array }
  1592. e_phnum : word; { 0..e_phnum-1 of entrys }
  1593. e_shentsize : word; { size of an entry in sections header array }
  1594. e_shnum : word; { 0..e_shnum-1 of entrys }
  1595. e_shstrndx : word; { index of string section header }
  1596. end;
  1597. TElf32sechdr=packed record
  1598. sh_name : longint;
  1599. sh_type : longint;
  1600. sh_flags : longint;
  1601. sh_addr : longint;
  1602. sh_offset : longint;
  1603. sh_size : longint;
  1604. sh_link : longint;
  1605. sh_info : longint;
  1606. sh_addralign : longint;
  1607. sh_entsize : longint;
  1608. end;
  1609. function MayBeSwapHeader(h : telf32header) : telf32header;
  1610. begin
  1611. result:=h;
  1612. if source_info.endian<>target_info.endian then
  1613. with h do
  1614. begin
  1615. result.e_type:=swapendian(e_type);
  1616. result.e_machine:=swapendian(e_machine);
  1617. result.e_version:=swapendian(e_version);
  1618. result.e_entry:=swapendian(e_entry);
  1619. result.e_phoff:=swapendian(e_phoff);
  1620. result.e_shoff:=swapendian(e_shoff);
  1621. result.e_flags:=swapendian(e_flags);
  1622. result.e_ehsize:=swapendian(e_ehsize);
  1623. result.e_phentsize:=swapendian(e_phentsize);
  1624. result.e_phnum:=swapendian(e_phnum);
  1625. result.e_shentsize:=swapendian(e_shentsize);
  1626. result.e_shnum:=swapendian(e_shnum);
  1627. result.e_shstrndx:=swapendian(e_shstrndx);
  1628. end;
  1629. end;
  1630. function MaybeSwapSecHeader(h : telf32sechdr) : telf32sechdr;
  1631. begin
  1632. result:=h;
  1633. if source_info.endian<>target_info.endian then
  1634. with h do
  1635. begin
  1636. result.sh_name:=swapendian(sh_name);
  1637. result.sh_type:=swapendian(sh_type);
  1638. result.sh_flags:=swapendian(sh_flags);
  1639. result.sh_addr:=swapendian(sh_addr);
  1640. result.sh_offset:=swapendian(sh_offset);
  1641. result.sh_size:=swapendian(sh_size);
  1642. result.sh_link:=swapendian(sh_link);
  1643. result.sh_info:=swapendian(sh_info);
  1644. result.sh_addralign:=swapendian(sh_addralign);
  1645. result.sh_entsize:=swapendian(sh_entsize);
  1646. end;
  1647. end;
  1648. var
  1649. f : file;
  1650. function ReadSectionName(pos : longint) : String;
  1651. var
  1652. oldpos : longint;
  1653. c : char;
  1654. begin
  1655. oldpos:=filepos(f);
  1656. seek(f,pos);
  1657. Result:='';
  1658. while true do
  1659. begin
  1660. blockread(f,c,1);
  1661. if c=#0 then
  1662. break;
  1663. Result:=Result+c;
  1664. end;
  1665. seek(f,oldpos);
  1666. end;
  1667. var
  1668. elfheader : TElf32header;
  1669. secheader : TElf32sechdr;
  1670. i : longint;
  1671. stringoffset : longint;
  1672. secname : string;
  1673. begin
  1674. postprocessexecutable:=false;
  1675. { open file }
  1676. assign(f,fn);
  1677. {$push}{$I-}
  1678. reset(f,1);
  1679. if ioresult<>0 then
  1680. Message1(execinfo_f_cant_open_executable,fn);
  1681. { read header }
  1682. blockread(f,elfheader,sizeof(tElf32header));
  1683. elfheader:=MayBeSwapHeader(elfheader);
  1684. seek(f,elfheader.e_shoff);
  1685. { read string section header }
  1686. seek(f,elfheader.e_shoff+sizeof(TElf32sechdr)*elfheader.e_shstrndx);
  1687. blockread(f,secheader,sizeof(secheader));
  1688. secheader:=MaybeSwapSecHeader(secheader);
  1689. stringoffset:=secheader.sh_offset;
  1690. seek(f,elfheader.e_shoff);
  1691. status.datasize:=0;
  1692. for i:=0 to elfheader.e_shnum-1 do
  1693. begin
  1694. blockread(f,secheader,sizeof(secheader));
  1695. secheader:=MaybeSwapSecHeader(secheader);
  1696. secname:=ReadSectionName(stringoffset+secheader.sh_name);
  1697. if secname='.text' then
  1698. begin
  1699. Message1(execinfo_x_codesize,tostr(secheader.sh_size));
  1700. status.codesize:=secheader.sh_size;
  1701. end
  1702. else if secname='.data' then
  1703. begin
  1704. Message1(execinfo_x_initdatasize,tostr(secheader.sh_size));
  1705. inc(status.datasize,secheader.sh_size);
  1706. end
  1707. else if secname='.bss' then
  1708. begin
  1709. Message1(execinfo_x_uninitdatasize,tostr(secheader.sh_size));
  1710. inc(status.datasize,secheader.sh_size);
  1711. end;
  1712. end;
  1713. close(f);
  1714. {$pop}
  1715. if ioresult<>0 then
  1716. ;
  1717. postprocessexecutable:=true;
  1718. end;
  1719. {*****************************************************************************
  1720. TlinkerEmbedded_SdccSdld
  1721. *****************************************************************************}
  1722. function TlinkerEmbedded_SdccSdld.WriteResponseFile: Boolean;
  1723. Var
  1724. linkres : TLinkRes;
  1725. i : longint;
  1726. HPath : TCmdStrListItem;
  1727. s,s1,s2 : TCmdStr;
  1728. prtobj,
  1729. cprtobj : string[80];
  1730. linklibc : boolean;
  1731. found1,
  1732. found2 : boolean;
  1733. {$if defined(ARM)}
  1734. LinkStr : string;
  1735. {$endif}
  1736. begin
  1737. WriteResponseFile:=False;
  1738. linklibc:=(SharedLibFiles.Find('c')<>nil);
  1739. prtobj:='prt0';
  1740. cprtobj:='cprt0';
  1741. if linklibc then
  1742. prtobj:=cprtobj;
  1743. { Open link.res file }
  1744. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
  1745. { Write path to search libraries }
  1746. (* HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
  1747. while assigned(HPath) do
  1748. begin
  1749. s:=HPath.Str;
  1750. if (cs_link_on_target in current_settings.globalswitches) then
  1751. s:=ScriptFixFileName(s);
  1752. LinkRes.Add('-L'+s);
  1753. HPath:=TCmdStrListItem(HPath.Next);
  1754. end;
  1755. HPath:=TCmdStrListItem(LibrarySearchPath.First);
  1756. while assigned(HPath) do
  1757. begin
  1758. s:=HPath.Str;
  1759. if s<>'' then
  1760. LinkRes.Add('SEARCH_DIR("'+s+'")');
  1761. HPath:=TCmdStrListItem(HPath.Next);
  1762. end;
  1763. LinkRes.Add('INPUT (');
  1764. { add objectfiles, start with prt0 always }*)
  1765. //s:=FindObjectFile('prt0','',false);
  1766. if prtobj<>'' then
  1767. begin
  1768. s:=FindObjectFile(prtobj,'',false);
  1769. LinkRes.AddFileName(s);
  1770. end;
  1771. { try to add crti and crtbegin if linking to C }
  1772. if linklibc then
  1773. begin
  1774. if librarysearchpath.FindFile('crtbegin.o',false,s) then
  1775. LinkRes.AddFileName(s);
  1776. if librarysearchpath.FindFile('crti.o',false,s) then
  1777. LinkRes.AddFileName(s);
  1778. end;
  1779. while not ObjectFiles.Empty do
  1780. begin
  1781. s:=ObjectFiles.GetFirst;
  1782. if s<>'' then
  1783. begin
  1784. { vlink doesn't use SEARCH_DIR for object files }
  1785. if not(cs_link_on_target in current_settings.globalswitches) then
  1786. s:=FindObjectFile(s,'',false);
  1787. LinkRes.AddFileName((maybequoted(s)));
  1788. end;
  1789. end;
  1790. { Write staticlibraries }
  1791. if not StaticLibFiles.Empty then
  1792. begin
  1793. { vlink doesn't need, and doesn't support GROUP }
  1794. { if (cs_link_on_target in current_settings.globalswitches) then
  1795. begin
  1796. LinkRes.Add(')');
  1797. LinkRes.Add('GROUP(');
  1798. end;}
  1799. while not StaticLibFiles.Empty do
  1800. begin
  1801. S:=StaticLibFiles.GetFirst;
  1802. LinkRes.Add('-l'+maybequoted(s));
  1803. end;
  1804. end;
  1805. (* if (cs_link_on_target in current_settings.globalswitches) then
  1806. begin
  1807. LinkRes.Add(')');
  1808. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  1809. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  1810. linklibc:=false;
  1811. while not SharedLibFiles.Empty do
  1812. begin
  1813. S:=SharedLibFiles.GetFirst;
  1814. if s<>'c' then
  1815. begin
  1816. i:=Pos(target_info.sharedlibext,S);
  1817. if i>0 then
  1818. Delete(S,i,255);
  1819. LinkRes.Add('-l'+s);
  1820. end
  1821. else
  1822. begin
  1823. LinkRes.Add('-l'+s);
  1824. linklibc:=true;
  1825. end;
  1826. end;
  1827. { be sure that libc&libgcc is the last lib }
  1828. if linklibc then
  1829. begin
  1830. LinkRes.Add('-lc');
  1831. LinkRes.Add('-lgcc');
  1832. end;
  1833. end
  1834. else
  1835. begin
  1836. while not SharedLibFiles.Empty do
  1837. begin
  1838. S:=SharedLibFiles.GetFirst;
  1839. LinkRes.Add('lib'+s+target_info.staticlibext);
  1840. end;
  1841. LinkRes.Add(')');
  1842. end;*)
  1843. { objects which must be at the end }
  1844. (*if linklibc then
  1845. begin
  1846. found1:=librarysearchpath.FindFile('crtend.o',false,s1);
  1847. found2:=librarysearchpath.FindFile('crtn.o',false,s2);
  1848. if found1 or found2 then
  1849. begin
  1850. LinkRes.Add('INPUT(');
  1851. if found1 then
  1852. LinkRes.AddFileName(s1);
  1853. if found2 then
  1854. LinkRes.AddFileName(s2);
  1855. LinkRes.Add(')');
  1856. end;
  1857. end;*)
  1858. { Write and Close response }
  1859. linkres.writetodisk;
  1860. linkres.free;
  1861. WriteResponseFile:=True;
  1862. end;
  1863. procedure TlinkerEmbedded_SdccSdld.SetDefaultInfo;
  1864. const
  1865. {$if defined(Z80)}
  1866. ExeName='sdldz80';
  1867. {$else}
  1868. ExeName='sdld';
  1869. {$endif}
  1870. begin
  1871. with Info do
  1872. begin
  1873. ExeCmd[1]:=ExeName+' -n $OPT -i $MAP $EXE -f $RES'
  1874. //-g '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE -T $RES';
  1875. end;
  1876. end;
  1877. function TlinkerEmbedded_SdccSdld.MakeExecutable: boolean;
  1878. var
  1879. binstr,
  1880. cmdstr,
  1881. mapstr: TCmdStr;
  1882. success : boolean;
  1883. StaticStr,
  1884. // GCSectionsStr,
  1885. DynLinkStr,
  1886. StripStr,
  1887. FixedExeFileName: string;
  1888. begin
  1889. { for future use }
  1890. StaticStr:='';
  1891. StripStr:='';
  1892. mapstr:='';
  1893. DynLinkStr:='';
  1894. FixedExeFileName:=maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.ihx')));
  1895. (* GCSectionsStr:='--gc-sections';
  1896. //if not(cs_link_extern in current_settings.globalswitches) then
  1897. if not(cs_link_nolink in current_settings.globalswitches) then
  1898. Message1(exec_i_linking,current_module.exefilename);*)
  1899. if (cs_link_map in current_settings.globalswitches) then
  1900. mapstr:='-mw';
  1901. { Write used files and libraries }
  1902. WriteResponseFile();
  1903. { Call linker }
  1904. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  1905. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  1906. if not(cs_link_on_target in current_settings.globalswitches) then
  1907. begin
  1908. Replace(cmdstr,'$EXE',FixedExeFileName);
  1909. Replace(cmdstr,'$RES',(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
  1910. Replace(cmdstr,'$STATIC',StaticStr);
  1911. Replace(cmdstr,'$STRIP',StripStr);
  1912. Replace(cmdstr,'$MAP',mapstr);
  1913. // Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  1914. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  1915. end
  1916. else
  1917. begin
  1918. Replace(cmdstr,'$EXE',FixedExeFileName);
  1919. Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
  1920. Replace(cmdstr,'$STATIC',StaticStr);
  1921. Replace(cmdstr,'$STRIP',StripStr);
  1922. Replace(cmdstr,'$MAP',mapstr);
  1923. // Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  1924. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  1925. end;
  1926. success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false);
  1927. { Remove ReponseFile }
  1928. if success and not(cs_link_nolink in current_settings.globalswitches) then
  1929. DeleteFile(outputexedir+Info.ResName);
  1930. (* { Post process }
  1931. if success and not(cs_link_nolink in current_settings.globalswitches) then
  1932. success:=PostProcessExecutable(FixedExeFileName,false);
  1933. if success and (target_info.system in [system_arm_embedded,system_avr_embedded,system_mipsel_embedded,system_xtensa_embedded]) then
  1934. begin
  1935. success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+
  1936. FixedExeFileName+' '+
  1937. maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.hex'))),true,false);
  1938. if success then
  1939. success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+
  1940. FixedExeFileName+' '+
  1941. maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),true,false);
  1942. end;*)
  1943. MakeExecutable:=success; { otherwise a recursive call to link method }
  1944. end;
  1945. {*****************************************************************************
  1946. Initialize
  1947. *****************************************************************************}
  1948. initialization
  1949. {$ifdef arm}
  1950. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1951. RegisterTarget(system_arm_embedded_info);
  1952. {$endif arm}
  1953. {$ifdef avr}
  1954. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1955. RegisterTarget(system_avr_embedded_info);
  1956. {$endif avr}
  1957. {$ifdef i386}
  1958. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1959. RegisterTarget(system_i386_embedded_info);
  1960. {$endif i386}
  1961. {$ifdef x86_64}
  1962. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1963. RegisterTarget(system_x86_64_embedded_info);
  1964. {$endif x86_64}
  1965. {$ifdef i8086}
  1966. { no need to register linker ld_embedded, because i8086_embedded uses the
  1967. regular msdos linker. In case a flat binary, relocated for a specific
  1968. segment address is needed (e.g. for a BIOS or a real mode bootloader), it
  1969. can be produced post-compilation with exe2bin or a similar tool. }
  1970. RegisterTarget(system_i8086_embedded_info);
  1971. {$endif i8086}
  1972. {$ifdef mipsel}
  1973. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1974. RegisterTarget(system_mipsel_embedded_info);
  1975. {$endif mipsel}
  1976. {$ifdef m68k}
  1977. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1978. RegisterTarget(system_m68k_embedded_info);
  1979. {$endif m68k}
  1980. {$ifdef riscv32}
  1981. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1982. RegisterTarget(system_riscv32_embedded_info);
  1983. {$endif riscv32}
  1984. {$ifdef riscv64}
  1985. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1986. RegisterTarget(system_riscv64_embedded_info);
  1987. {$endif riscv64}
  1988. {$ifdef xtensa}
  1989. RegisterLinker(ld_embedded,TLinkerEmbedded);
  1990. RegisterTarget(system_xtensa_embedded_info);
  1991. {$endif xtensa}
  1992. {$ifdef z80}
  1993. RegisterLinker(ld_embedded,TlinkerEmbedded_SdccSdld);
  1994. RegisterTarget(system_z80_embedded_info);
  1995. {$endif z80}
  1996. end.