Browse Source

* 8086: Fixed very long section names when $HUGECODE is ON and section based smartlinking is used.
* Added a utility function TrimStrCRC32().

git-svn-id: trunk@46511 -

yury 5 years ago
parent
commit
1002a7c590
3 changed files with 24 additions and 5 deletions
  1. 20 1
      compiler/fpccrc.pas
  2. 2 2
      compiler/ogomf.pas
  3. 2 2
      compiler/x86/agx86nsm.pas

+ 20 - 1
compiler/fpccrc.pas

@@ -26,7 +26,9 @@ Unit fpccrc;
 Interface
 
 Function UpdateCrc32(InitCrc:cardinal;const InBuf;InLen:integer):cardinal;
-
+{ If needed trims the string to maxlen, adding at the end the CRC32 of discarded chars.
+  The resulting string is guaranteed to be not longer than maxlen. }
+function TrimStrCRC32(const s: ansistring; maxlen: longint): ansistring;
 
 Implementation
 
@@ -73,4 +75,21 @@ begin
 end;
 
 
+function TrimStrCRC32(const s: ansistring; maxlen: longint): ansistring;
+var
+  crc: DWord;
+  len: longint;
+begin
+  len:=length(s);
+  if (len<=maxlen) or (len<12) then
+    result:=s
+  else
+   begin
+     dec(maxlen,11);
+     crc:=0;
+     crc:=UpdateCrc32(crc,s[maxlen+1],len-maxlen);
+     result:=copy(s,1,maxlen)+'$CRC'+hexstr(crc,8);
+   end;
+end;
+
 end.

+ 2 - 2
compiler/ogomf.pas

@@ -803,7 +803,7 @@ implementation
 
     uses
        SysUtils,
-       cutils,verbose,globals,
+       cutils,verbose,globals,fpccrc,
        fmodule,aasmtai,aasmdata,
        ogmap,owomflib,elfbase,
        version
@@ -1053,7 +1053,7 @@ implementation
         if current_settings.x86memorymodel in x86_far_code_models then
           begin
             if cs_huge_code in current_settings.moduleswitches then
-              result:=aname + '_TEXT'
+              result:=TrimStrCRC32(aname,30) + '_TEXT'
             else
               result:=current_module.modulename^ + '_TEXT';
           end

+ 2 - 2
compiler/x86/agx86nsm.pas

@@ -84,7 +84,7 @@ interface
   implementation
 
     uses
-      cutils,globals,systems,
+      cutils,globals,systems,fpccrc,
       fmodule,finput,verbose,cpuinfo,cgbase,omfbase
       ;
 
@@ -306,7 +306,7 @@ interface
         if current_settings.x86memorymodel in x86_far_code_models then
           begin
             if cs_huge_code in current_settings.moduleswitches then
-              result:=aname + '_TEXT'
+              result:=TrimStrCRC32(aname,30) + '_TEXT'
             else
               result:=current_module.modulename^ + '_TEXT';
           end