* powerpc-morphos: add support for linker map file generation, some code cleanups

This commit is contained in:
Karoly Balogh 2022-02-21 11:35:24 +01:00
parent dea81f4f60
commit 4b88fa8e3b

View File

@ -69,12 +69,12 @@ begin
begin begin
if not UseVLink then if not UseVLink then
begin begin
ExeCmd[1]:='ld $OPT $GCSECTIONS -o $EXE $RES'; ExeCmd[1]:='ld $OPT $GCSECTIONS $MAP -o $EXE $RES';
ExeCmd[2]:='strip --strip-unneeded --remove-section .comment $EXE'; ExeCmd[2]:='strip --strip-unneeded --remove-section .comment $EXE';
end end
else else
begin begin
ExeCmd[1]:='vlink -b elf32amiga $OPT $STRIP $GCSECTIONS -o $EXE -T $RES'; ExeCmd[1]:='vlink -b elf32amiga $OPT $STRIP $GCSECTIONS $MAP -o $EXE -T $RES';
end; end;
end; end;
end; end;
@ -212,9 +212,11 @@ var
success : boolean; success : boolean;
GCSectionsStr: string; GCSectionsStr: string;
StripStr: string[40]; StripStr: string[40];
MapStr: string;
begin begin
StripStr:=''; StripStr:='';
GCSectionsStr:=''; GCSectionsStr:='';
MapStr:='';
if not(cs_link_nolink in current_settings.globalswitches) then if not(cs_link_nolink in current_settings.globalswitches) then
Message1(exec_i_linking,current_module.exefilename); Message1(exec_i_linking,current_module.exefilename);
@ -223,11 +225,15 @@ begin
begin begin
if (cs_link_strip in current_settings.globalswitches) then if (cs_link_strip in current_settings.globalswitches) then
StripStr:='-s -P __abox__'; StripStr:='-s -P __abox__';
if (cs_link_map in current_settings.globalswitches) then
MapStr:='-M'+Unix2AmigaPath(maybequoted(ScriptFixFilename(current_module.mapfilename)));
if create_smartlink_sections then if create_smartlink_sections then
GCSectionsStr:='-gc-all -sc -sd'; GCSectionsStr:='-gc-all -sc -sd';
end end
else else
begin begin
if (cs_link_map in current_settings.globalswitches) then
MapStr:='-Map '+maybequoted(ScriptFixFileName(current_module.mapfilename));
if create_smartlink_sections then if create_smartlink_sections then
GCSectionsStr:='--gc-sections -e _start'; GCSectionsStr:='--gc-sections -e _start';
end; end;
@ -238,18 +244,18 @@ begin
{ Call linker } { Call linker }
SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr); SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
Replace(cmdstr,'$OPT',Info.ExtraOptions); Replace(cmdstr,'$OPT',Info.ExtraOptions);
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
Replace(cmdstr,'$MAP',MapStr);
if UseVLink then if UseVLink then
begin begin
Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename)))); Replace(cmdstr,'$EXE',Unix2AmigaPath(maybequoted(ScriptFixFileName(current_module.exefilename))));
Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName)))); Replace(cmdstr,'$RES',Unix2AmigaPath(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
Replace(cmdstr,'$STRIP',StripStr); Replace(cmdstr,'$STRIP',StripStr);
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
end end
else else
begin begin
Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(current_module.exefilename))); Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(current_module.exefilename)));
Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName))); Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
end; end;
success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false); success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false);
@ -272,7 +278,6 @@ begin
DeleteFile(outputexedir+Info.ResName); DeleteFile(outputexedir+Info.ResName);
MakeExecutable:=success; { otherwise a recursive call to link method } MakeExecutable:=success; { otherwise a recursive call to link method }
end; end;