* Convert symversions to dyn array of word

This commit is contained in:
Michaël Van Canneyt 2025-03-18 15:30:59 +01:00
parent 8b816782c3
commit 859b100da6
2 changed files with 9 additions and 9 deletions

View File

@ -44,6 +44,7 @@ interface
TByteDynArray = array of byte; TByteDynArray = array of byte;
TAnsiCharDynArray = array of ansichar; TAnsiCharDynArray = array of ansichar;
TBooleanDynArray = array of boolean; TBooleanDynArray = array of boolean;
TWordDynArray = array of word;
Int32 = Longint; Int32 = Longint;

View File

@ -135,7 +135,7 @@ interface
symtaboffset: aword; symtaboffset: aword;
syms: longword; syms: longword;
localsyms: longword; localsyms: longword;
symversions: PWord; symversions: TWordDynArray;
dynobj: boolean; dynobj: boolean;
CObjSymbol: TObjSymbolClass; CObjSymbol: TObjSymbolClass;
verdefs: TFPHashObjectList; verdefs: TFPHashObjectList;
@ -1168,8 +1168,7 @@ implementation
FreeMem(FSecTbl); FreeMem(FSecTbl);
strtab:=nil; strtab:=nil;
shstrtab:=nil; shstrtab:=nil;
if Assigned(symversions) then symversions:=nil;
FreeMem(symversions);
inherited Destroy; inherited Destroy;
end; end;
@ -1660,9 +1659,9 @@ implementation
InternalError(2012102004); InternalError(2012102004);
if shdrs[i].sh_size<>syms*sizeof(word) then if shdrs[i].sh_size<>syms*sizeof(word) then
InternalError(2012102005); InternalError(2012102005);
GetMem(symversions,shdrs[i].sh_size); SetLength(symversions,shdrs[i].sh_size);
FReader.seek(shdrs[i].sh_offset); FReader.seek(shdrs[i].sh_offset);
FReader.read(symversions^,shdrs[i].sh_size); FReader.read(symversions[0],shdrs[i].sh_size);
if source_info.endian<>target_info.endian then if source_info.endian<>target_info.endian then
for j:=0 to syms-1 do for j:=0 to syms-1 do
symversions[j]:=SwapEndian(symversions[j]); symversions[j]:=SwapEndian(symversions[j]);
@ -2906,9 +2905,9 @@ implementation
ver: TElfVersionDef; ver: TElfVersionDef;
vn: TElfverneed; vn: TElfverneed;
vna: TElfvernaux; vna: TElfvernaux;
symversions: pword; symversions: TWordDynArray;
begin begin
symversions:=AllocMem((dynsymlist.count+1)*sizeof(word)); SetLength(symversions,(dynsymlist.count+1));
{ Assign version indices } { Assign version indices }
idx:=VER_NDX_GLOBAL+1; idx:=VER_NDX_GLOBAL+1;
for i:=0 to dynsymlist.count-1 do for i:=0 to dynsymlist.count-1 do
@ -2989,9 +2988,9 @@ implementation
if source_info.endian<>target_info.endian then if source_info.endian<>target_info.endian then
for i:=0 to dynsymlist.count+1 do for i:=0 to dynsymlist.count+1 do
symversions[i]:=swapendian(symversions[i]); symversions[i]:=swapendian(symversions[i]);
symversec.write(symversions^,(dynsymlist.count+1)*sizeof(word)); symversec.write(symversions[0],(dynsymlist.count+1)*sizeof(word));
end; end;
FreeMem(symversions); symversions:=nil;
end; end;