* support -Xg under linux

git-svn-id: trunk@9811 -
This commit is contained in:
peter 2008-01-20 12:12:15 +00:00
parent 03de80785d
commit de918497ef
3 changed files with 29 additions and 3 deletions

View File

@ -150,6 +150,7 @@ interface
sharedlibfilename, { fullname of the shared libraryfile } sharedlibfilename, { fullname of the shared libraryfile }
mapfilename, { fullname of the mapfile } mapfilename, { fullname of the mapfile }
exefilename, { fullname of the exefile } exefilename, { fullname of the exefile }
dbgfilename, { fullname of the debug info file }
mainsource : pshortstring; { name of the main sourcefile } mainsource : pshortstring; { name of the main sourcefile }
constructor create(const s:string); constructor create(const s:string);
destructor destroy;override; destructor destroy;override;
@ -615,6 +616,7 @@ uses
stringdispose(sharedlibfilename); stringdispose(sharedlibfilename);
stringdispose(mapfilename); stringdispose(mapfilename);
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(dbgfilename);
stringdispose(outputpath); stringdispose(outputpath);
stringdispose(path); stringdispose(path);
stringdispose(paramfn); stringdispose(paramfn);
@ -669,6 +671,7 @@ uses
sharedlibfilename:=stringdup(p+prefix+n+suffix+target_info.sharedlibext); sharedlibfilename:=stringdup(p+prefix+n+suffix+target_info.sharedlibext);
end; end;
mapfilename:=stringdup(p+n+'.map'); mapfilename:=stringdup(p+n+'.map');
dbgfilename:=stringdup(p+n+'.dbg');
end; end;
@ -684,6 +687,7 @@ uses
staticlibfilename:=nil; staticlibfilename:=nil;
sharedlibfilename:=nil; sharedlibfilename:=nil;
exefilename:=nil; exefilename:=nil;
dbgfilename:=nil;
mapfilename:=nil; mapfilename:=nil;
outputpath:=nil; outputpath:=nil;
paramfn:=nil; paramfn:=nil;
@ -710,6 +714,7 @@ uses
stringdispose(staticlibfilename); stringdispose(staticlibfilename);
stringdispose(sharedlibfilename); stringdispose(sharedlibfilename);
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(dbgfilename);
stringdispose(mapfilename); stringdispose(mapfilename);
stringdispose(outputpath); stringdispose(outputpath);
stringdispose(path); stringdispose(path);

View File

@ -37,7 +37,8 @@ interface
Type Type
TLinkerInfo=record TLinkerInfo=record
ExeCmd, ExeCmd,
DllCmd : array[1..3] of string; DllCmd,
ExtDbgCmd : array[1..3] of string;
ResName : string[100]; ResName : string[100];
ScriptName : string[100]; ScriptName : string[100];
ExtraOptions : TCmdStr; ExtraOptions : TCmdStr;

View File

@ -242,6 +242,9 @@ begin
ExeCmd[1]:=ExeCmd[1]+' $RES'; ExeCmd[1]:=ExeCmd[1]+' $RES';
DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES -E'; DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES -E';
DllCmd[2]:='strip --strip-unneeded $EXE'; DllCmd[2]:='strip --strip-unneeded $EXE';
ExtDbgCmd[1]:='objcopy --only-keep-debug $EXE $DBG';
ExtDbgCmd[2]:='objcopy --add-gnu-debuglink=$DBG $EXE';
ExtDbgCmd[3]:='strip --strip-unneeded $EXE';
{$ifdef m68k} {$ifdef m68k}
{ experimental, is this correct? } { experimental, is this correct? }
@ -1006,6 +1009,7 @@ end;
function TLinkerLinux.MakeExecutable:boolean; function TLinkerLinux.MakeExecutable:boolean;
var var
i : longint;
binstr, binstr,
cmdstr : TCmdStr; cmdstr : TCmdStr;
success : boolean; success : boolean;
@ -1024,7 +1028,8 @@ begin
DynLinkStr:=''; DynLinkStr:='';
if (cs_link_staticflag in current_settings.globalswitches) then if (cs_link_staticflag in current_settings.globalswitches) then
StaticStr:='-static'; StaticStr:='-static';
if (cs_link_strip in current_settings.globalswitches) then if (cs_link_strip in current_settings.globalswitches) and
not(cs_link_separate_dbg_file in current_settings.globalswitches) then
StripStr:='-s'; StripStr:='-s';
if (cs_link_map in current_settings.globalswitches) then if (cs_link_map in current_settings.globalswitches) then
StripStr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename^,'.map')); StripStr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename^,'.map'));
@ -1059,7 +1064,22 @@ begin
success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false); success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
{ Remove ReponseFile } { Create external .dbg file with debuginfo }
if success and (cs_link_separate_dbg_file in current_settings.globalswitches) then
begin
for i:=1 to 3 do
begin
SplitBinCmd(Info.ExtDbgCmd[i],binstr,cmdstr);
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
Replace(cmdstr,'$DBGFN',maybequoted(extractfilename(current_module.dbgfilename^)));
Replace(cmdstr,'$DBG',maybequoted(current_module.dbgfilename^));
success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
if not success then
break;
end;
end;
{ Remove ReponseFile }
if (success) and not(cs_link_nolink in current_settings.globalswitches) then if (success) and not(cs_link_nolink in current_settings.globalswitches) then
DeleteFile(outputexedir+Info.ResName); DeleteFile(outputexedir+Info.ResName);