* 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 -
This commit is contained in:
yury 2020-08-20 16:35:27 +00:00
parent b1ee6f7fdc
commit 1002a7c590
3 changed files with 24 additions and 5 deletions

View File

@ -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.

View File

@ -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

View File

@ -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