View Issue Details

IDProjectCategoryView StatusLast Update
0033982FPCCompilerpublic2018-10-29 13:48
ReporterCyraxAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
PlatformLinux x86_64OSArchOS Version3.17.4-1
Product Version3.1.1Product Buildr39445 
Target Version3.2.0Fixed in Version3.1.1 
Summary0033982: [patch] Allow creation of map file under linux systems.
DescriptionAttached patch will allow creation of map file under linux systems.
Tagspatch
Fixed in Revision39449
FPCOldBugId
FPCTarget
Attached Files
  • t_linux.pas.diff (3,178 bytes)
    diff --git compiler/systems/t_linux.pas compiler/systems/t_linux.pas
    index 58bfbf41f2..0a4af94074 100644
    --- compiler/systems/t_linux.pas
    +++ compiler/systems/t_linux.pas
    @@ -352,8 +352,8 @@ begin
     {$endif powerpc64}
       with Info do
        begin
    -     ExeCmd[1]:='ld '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE';
    -     DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared $GCSECTIONS -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 $MAP -shared $GCSECTIONS -L. -o $EXE';
          { 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
            augment the default linkerscript, which also requires -T (normally that
    @@ -1354,7 +1354,8 @@ function TLinkerLinux.MakeExecutable:boolean;
     var
       i : longint;
       binstr,
    -  cmdstr  : TCmdStr;
    +  cmdstr,
    +  mapstr : TCmdStr;
       success : boolean;
       DynLinkStr : string;
       GCSectionsStr,
    @@ -1369,13 +1370,14 @@ begin
       StripStr:='';
       GCSectionsStr:='';
       DynLinkStr:='';
    +  mapstr:='';
       if (cs_link_staticflag in current_settings.globalswitches) then
        StaticStr:='-static';
       if (cs_link_strip in current_settings.globalswitches) and
          not(cs_link_separate_dbg_file in current_settings.globalswitches) then
        StripStr:='-s';
       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
          create_smartlink_sections then
        GCSectionsStr:='--gc-sections';
    @@ -1401,6 +1403,7 @@ begin
       Replace(cmdstr,'$STRIP',StripStr);
       Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
       Replace(cmdstr,'$DYNLINK',DynLinkStr);
    +  Replace(cmdstr,'$MAP',mapstr);
     
       { create dynamic symbol table? }
       if HasExports then
    @@ -1438,10 +1441,12 @@ var
       GCSectionsStr,
       SoNameStr : string[80];
       binstr,
    -  cmdstr  : TCmdStr;
    +  cmdstr,
    +  mapstr : TCmdStr;
       success : boolean;
     begin
       MakeSharedLibrary:=false;
    +  mapstr:='';
       if not(cs_link_nolink in current_settings.globalswitches) then
        Message1(exec_i_linking,current_module.sharedlibfilename);
       if (cs_link_smart in current_settings.globalswitches) and
    @@ -1458,6 +1463,8 @@ begin
       InitStr:='-init FPC_SHARED_LIB_START';
       FiniStr:='-fini FPC_LIB_EXIT';
       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 }
       SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
    @@ -1467,6 +1474,7 @@ begin
       Replace(cmdstr,'$INIT',InitStr);
       Replace(cmdstr,'$FINI',FiniStr);
       Replace(cmdstr,'$SONAME',SoNameStr);
    +  Replace(cmdstr,'$MAP',mapstr);
       Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
       success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
     
    
    t_linux.pas.diff (3,178 bytes)

Activities

Cyrax

2018-07-13 20:27

reporter  

t_linux.pas.diff (3,178 bytes)
diff --git compiler/systems/t_linux.pas compiler/systems/t_linux.pas
index 58bfbf41f2..0a4af94074 100644
--- compiler/systems/t_linux.pas
+++ compiler/systems/t_linux.pas
@@ -352,8 +352,8 @@ begin
 {$endif powerpc64}
   with Info do
    begin
-     ExeCmd[1]:='ld '+platform_select+platformopt+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE';
-     DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared $GCSECTIONS -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 $MAP -shared $GCSECTIONS -L. -o $EXE';
      { 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
        augment the default linkerscript, which also requires -T (normally that
@@ -1354,7 +1354,8 @@ function TLinkerLinux.MakeExecutable:boolean;
 var
   i : longint;
   binstr,
-  cmdstr  : TCmdStr;
+  cmdstr,
+  mapstr : TCmdStr;
   success : boolean;
   DynLinkStr : string;
   GCSectionsStr,
@@ -1369,13 +1370,14 @@ begin
   StripStr:='';
   GCSectionsStr:='';
   DynLinkStr:='';
+  mapstr:='';
   if (cs_link_staticflag in current_settings.globalswitches) then
    StaticStr:='-static';
   if (cs_link_strip in current_settings.globalswitches) and
      not(cs_link_separate_dbg_file in current_settings.globalswitches) then
    StripStr:='-s';
   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
      create_smartlink_sections then
    GCSectionsStr:='--gc-sections';
@@ -1401,6 +1403,7 @@ begin
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
+  Replace(cmdstr,'$MAP',mapstr);
 
   { create dynamic symbol table? }
   if HasExports then
@@ -1438,10 +1441,12 @@ var
   GCSectionsStr,
   SoNameStr : string[80];
   binstr,
-  cmdstr  : TCmdStr;
+  cmdstr,
+  mapstr : TCmdStr;
   success : boolean;
 begin
   MakeSharedLibrary:=false;
+  mapstr:='';
   if not(cs_link_nolink in current_settings.globalswitches) then
    Message1(exec_i_linking,current_module.sharedlibfilename);
   if (cs_link_smart in current_settings.globalswitches) and
@@ -1458,6 +1463,8 @@ begin
   InitStr:='-init FPC_SHARED_LIB_START';
   FiniStr:='-fini FPC_LIB_EXIT';
   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 }
   SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
@@ -1467,6 +1474,7 @@ begin
   Replace(cmdstr,'$INIT',InitStr);
   Replace(cmdstr,'$FINI',FiniStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
+  Replace(cmdstr,'$MAP',mapstr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
 
t_linux.pas.diff (3,178 bytes)

Cyrax

2018-07-13 20:30

reporter   ~0109434

Link to thread at the forums : https://forum.lazarus.freepascal.org/index.php/topic,41875.0.html

Michael Van Canneyt

2018-07-14 10:13

administrator   ~0109444

Applied, thank you!

Cyrax

2018-10-29 13:48

reporter   ~0111657

Thank you!

Issue History

Date Modified Username Field Change
2018-07-13 20:27 Cyrax New Issue
2018-07-13 20:27 Cyrax File Added: t_linux.pas.diff
2018-07-13 20:30 Cyrax Note Added: 0109434
2018-07-13 20:31 Cyrax Tag Attached: patch
2018-07-14 00:50 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-07-14 00:50 Michael Van Canneyt Status new => assigned
2018-07-14 10:13 Michael Van Canneyt Fixed in Revision => 39449
2018-07-14 10:13 Michael Van Canneyt Note Added: 0109444
2018-07-14 10:13 Michael Van Canneyt Status assigned => resolved
2018-07-14 10:13 Michael Van Canneyt Fixed in Version => 3.1.1
2018-07-14 10:13 Michael Van Canneyt Resolution open => fixed
2018-07-14 10:13 Michael Van Canneyt Target Version => 3.2.0
2018-10-29 13:48 Cyrax Note Added: 0111657
2018-10-29 13:48 Cyrax Status resolved => closed