function TlinkerEmbedded.MakeExecutable:boolean;
var
binstr,
cmdstr,
mapstr: TCmdStr;
success : boolean;
StaticStr,
GCSectionsStr,
DynLinkStr,
StripStr,
ElfStr, //added by @ackarwow
FixedExeFileName: string;
begin
{ for future use }
StaticStr:='';
StripStr:='';
mapstr:='';
DynLinkStr:='';
ElfStr:=ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.elf'));//changed by @ackarwow
FixedExeFileName:=maybequoted(ElfStr);//changed by @ackarwow
GCSectionsStr:='--gc-sections';
//if not(cs_link_extern in current_settings.globalswitches) then
if not(cs_link_nolink in current_settings.globalswitches) then
Message1(exec_i_linking,current_module.exefilename);
if (cs_link_map in current_settings.globalswitches) then
mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
{ Write used files and libraries }
WriteResponseFile();
{ Call linker }
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
Replace(cmdstr,'$OPT',Info.ExtraOptions);
if not(cs_link_on_target in current_settings.globalswitches) then
begin
Replace(cmdstr,'$EXE',FixedExeFileName);
Replace(cmdstr,'$RES',(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
Replace(cmdstr,'$STATIC',StaticStr);
Replace(cmdstr,'$STRIP',StripStr);
Replace(cmdstr,'$MAP',mapstr);
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
Replace(cmdstr,'$DYNLINK',DynLinkStr);
end
else
begin
Replace(cmdstr,'$EXE',FixedExeFileName);
Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
Replace(cmdstr,'$STATIC',StaticStr);
Replace(cmdstr,'$STRIP',StripStr);
Replace(cmdstr,'$MAP',mapstr);
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
Replace(cmdstr,'$DYNLINK',DynLinkStr);
end;
success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false);
{ Remove ReponseFile }
if success and not(cs_link_nolink in current_settings.globalswitches) then
DeleteFile(outputexedir+Info.ResName);
{ Post process }
if success and not(cs_link_nolink in current_settings.globalswitches) then
success:=PostProcessExecutable(ElfStr,false);//changed by @ackarwow
if success and (target_info.system in [system_arm_embedded,system_avr_embedded,system_mipsel_embedded,system_xtensa_embedded]) then
begin
success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+
FixedExeFileName+' '+
maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.hex'))),true,false);
if success then
success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+
FixedExeFileName+' '+
maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),true,false);
if success and (target_info.system in systems_support_uf2) and (cs_generate_uf2 in current_settings.globalswitches) then
success := GenerateUF2(maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),
maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.uf2'))),
embedded_controllers[current_settings.controllertype].flashbase);
{$ifdef ARM}
if success and (current_settings.controllertype = ct_raspi2) then
success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+ FixedExeFileName + ' kernel7.img',true,false);
{$endif ARM}
end;
MakeExecutable:=success; { otherwise a recursive call to link method }
end;