* Patch by Cyrax to allow creating map file on linux (bug ID 33982)

git-svn-id: trunk@39449 -
This commit is contained in:
michael 2018-07-14 08:12:38 +00:00
parent 6a150cdd75
commit f6867cbd63

View File

@ -352,8 +352,8 @@ begin
{$endif powerpc64} {$endif powerpc64}
with Info do with Info do
begin begin
ExeCmd[1]:='ld '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE'; ExeCmd[1]:='ld '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE';
DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared $GCSECTIONS -L. -o $EXE'; DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME $MAP -shared $GCSECTIONS -L. -o $EXE';
{ when we want to cross-link we need to override default library paths; { when we want to cross-link we need to override default library paths;
when targeting binutils 2.19 or later, we use the "INSERT" command to when targeting binutils 2.19 or later, we use the "INSERT" command to
augment the default linkerscript, which also requires -T (normally that augment the default linkerscript, which also requires -T (normally that
@ -1354,7 +1354,8 @@ function TLinkerLinux.MakeExecutable:boolean;
var var
i : longint; i : longint;
binstr, binstr,
cmdstr : TCmdStr; cmdstr,
mapstr : TCmdStr;
success : boolean; success : boolean;
DynLinkStr : string; DynLinkStr : string;
GCSectionsStr, GCSectionsStr,
@ -1369,13 +1370,14 @@ begin
StripStr:=''; StripStr:='';
GCSectionsStr:=''; GCSectionsStr:='';
DynLinkStr:=''; DynLinkStr:='';
mapstr:='';
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) and if (cs_link_strip in current_settings.globalswitches) and
not(cs_link_separate_dbg_file in current_settings.globalswitches) then 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')); mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map'));
if (cs_link_smart in current_settings.globalswitches) and if (cs_link_smart in current_settings.globalswitches) and
create_smartlink_sections then create_smartlink_sections then
GCSectionsStr:='--gc-sections'; GCSectionsStr:='--gc-sections';
@ -1401,6 +1403,7 @@ begin
Replace(cmdstr,'$STRIP',StripStr); Replace(cmdstr,'$STRIP',StripStr);
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr); Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
Replace(cmdstr,'$DYNLINK',DynLinkStr); Replace(cmdstr,'$DYNLINK',DynLinkStr);
Replace(cmdstr,'$MAP',mapstr);
{ create dynamic symbol table? } { create dynamic symbol table? }
if HasExports then if HasExports then
@ -1438,10 +1441,12 @@ var
GCSectionsStr, GCSectionsStr,
SoNameStr : string[80]; SoNameStr : string[80];
binstr, binstr,
cmdstr : TCmdStr; cmdstr,
mapstr : TCmdStr;
success : boolean; success : boolean;
begin begin
MakeSharedLibrary:=false; MakeSharedLibrary:=false;
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.sharedlibfilename); Message1(exec_i_linking,current_module.sharedlibfilename);
if (cs_link_smart in current_settings.globalswitches) and if (cs_link_smart in current_settings.globalswitches) and
@ -1458,6 +1463,8 @@ begin
InitStr:='-init FPC_SHARED_LIB_START'; InitStr:='-init FPC_SHARED_LIB_START';
FiniStr:='-fini FPC_LIB_EXIT'; FiniStr:='-fini FPC_LIB_EXIT';
SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename); SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename);
if (cs_link_map in current_settings.globalswitches) then
mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.sharedlibfilename,'.map'));
{ Call linker } { Call linker }
SplitBinCmd(Info.DllCmd[1],binstr,cmdstr); SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
@ -1467,6 +1474,7 @@ begin
Replace(cmdstr,'$INIT',InitStr); Replace(cmdstr,'$INIT',InitStr);
Replace(cmdstr,'$FINI',FiniStr); Replace(cmdstr,'$FINI',FiniStr);
Replace(cmdstr,'$SONAME',SoNameStr); Replace(cmdstr,'$SONAME',SoNameStr);
Replace(cmdstr,'$MAP',mapstr);
Replace(cmdstr,'$GCSECTIONS',GCSectionsStr); Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false); success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);