mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 11:39:32 +02:00
* rtti alignment fixed
This commit is contained in:
parent
4bdae840a3
commit
b39c0af01b
@ -28,7 +28,7 @@
|
||||
|
||||
{$define FPCPROCVAR}
|
||||
{$define USEEXCEPT}
|
||||
|
||||
|
||||
{$ifdef cpuarm}
|
||||
{$packrecords c}
|
||||
{$endif cpuarm}
|
||||
@ -59,6 +59,7 @@
|
||||
{$define cpuflags}
|
||||
{$define noopt}
|
||||
{$define cputargethasfixedstack}
|
||||
{$define cpurequiresproperalignment}
|
||||
{$endif sparc}
|
||||
|
||||
{$ifdef powerpc}
|
||||
@ -72,6 +73,7 @@
|
||||
{$define cpuneedsdiv32helper}
|
||||
{$define cputargethasfixedstack}
|
||||
{$define noopt}
|
||||
{$define cpurequiresproperalignment}
|
||||
{$endif arm}
|
||||
|
||||
{$ifdef m68k}
|
||||
@ -82,7 +84,10 @@
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.41 2004-09-21 19:59:51 peter
|
||||
Revision 1.42 2004-10-04 21:23:15 florian
|
||||
* rtti alignment fixed
|
||||
|
||||
Revision 1.41 2004/09/21 19:59:51 peter
|
||||
* x86_64 fixes
|
||||
* cleanup of fpcdefs.icn
|
||||
|
||||
|
@ -3261,6 +3261,9 @@ implementation
|
||||
begin
|
||||
rttiList.concat(Tai_const.Create_8bit(tkrecord));
|
||||
write_rtti_name;
|
||||
{$ifdef cpurequiresproperalignment}
|
||||
rttilist.concat(Tai_align.Create(sizeof(TConstPtrUInt)));
|
||||
{$endif cpurequiresproperalignment}
|
||||
rttiList.concat(Tai_const.Create_32bit(size));
|
||||
Count:=0;
|
||||
FRTTIType:=rt;
|
||||
@ -5523,6 +5526,9 @@ implementation
|
||||
rttiList.concat(Tai_const.Create_8bit(proctypesinfo));
|
||||
rttiList.concat(Tai_const.Create_8bit(length(tpropertysym(sym).realname)));
|
||||
rttiList.concat(Tai_string.Create(tpropertysym(sym).realname));
|
||||
{$ifdef cpurequiresproperalignment}
|
||||
rttilist.concat(Tai_align.Create(sizeof(TConstPtrUInt)));
|
||||
{$endif cpurequiresproperalignment}
|
||||
end;
|
||||
else internalerror(1509992);
|
||||
end;
|
||||
@ -5698,7 +5704,9 @@ implementation
|
||||
{ generate the name }
|
||||
rttiList.concat(Tai_const.Create_8bit(length(objrealname^)));
|
||||
rttiList.concat(Tai_string.Create(objrealname^));
|
||||
|
||||
{$ifdef cpurequiresproperalignment}
|
||||
rttilist.concat(Tai_align.Create(sizeof(TConstPtrUInt)));
|
||||
{$endif cpurequiresproperalignment}
|
||||
case rt of
|
||||
initrtti :
|
||||
begin
|
||||
@ -5740,11 +5748,19 @@ implementation
|
||||
rttiList.concat(Tai_const.Create_8bit(length(current_module.realmodulename^)));
|
||||
rttiList.concat(Tai_string.Create(current_module.realmodulename^));
|
||||
|
||||
{$ifdef cpurequiresproperalignment}
|
||||
rttilist.concat(Tai_align.Create(sizeof(TConstPtrUInt)));
|
||||
{$endif cpurequiresproperalignment}
|
||||
|
||||
{ write published properties count }
|
||||
count:=0;
|
||||
symtable.foreach({$ifdef FPCPROCVAR}@{$endif}count_published_properties,nil);
|
||||
rttiList.concat(Tai_const.Create_16bit(count));
|
||||
|
||||
{$ifdef cpurequiresproperalignment}
|
||||
rttilist.concat(Tai_align.Create(sizeof(TConstPtrUInt)));
|
||||
{$endif cpurequiresproperalignment}
|
||||
|
||||
{ count is used to write nameindex }
|
||||
|
||||
{ but we need an offset of the owner }
|
||||
@ -6184,7 +6200,10 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.256 2004-09-21 23:36:51 hajny
|
||||
Revision 1.257 2004-10-04 21:23:15 florian
|
||||
* rtti alignment fixed
|
||||
|
||||
Revision 1.256 2004/09/21 23:36:51 hajny
|
||||
* SetTextLineEnding implemented, FileRec.Name position alignment for CPU64
|
||||
|
||||
Revision 1.255 2004/09/21 17:25:12 peter
|
||||
|
@ -127,6 +127,16 @@
|
||||
{$endif HASINTF}
|
||||
|
||||
|
||||
function aligntoptr(p : pointer) : pointer;
|
||||
begin
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
if (ptrint(p) mod sizeof(ptrint))<>0 then
|
||||
inc(ptrint(p),sizeof(ptrint)-ptrint(p) mod sizeof(ptrint));
|
||||
result:=p;
|
||||
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
TOBJECT
|
||||
****************************************************************************}
|
||||
@ -552,6 +562,7 @@
|
||||
inc(Temp);
|
||||
I:=Temp^;
|
||||
inc(temp,I+1); // skip name string;
|
||||
temp:=aligntoptr(temp);
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
move(PRecRec(Temp)^.Count,Count,sizeof(Count));
|
||||
{$else FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
@ -745,7 +756,10 @@
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.38 2004-04-29 21:33:22 florian
|
||||
Revision 1.39 2004-10-04 21:26:16 florian
|
||||
* rtti alignment fixed
|
||||
|
||||
Revision 1.38 2004/04/29 21:33:22 florian
|
||||
* fixed tobject.dispatch for 64 bit cpus
|
||||
|
||||
Revision 1.37 2004/04/28 20:48:20 peter
|
||||
|
@ -80,7 +80,7 @@ PArrayRec = ^TArrayRec;
|
||||
TArrayRec = record
|
||||
Size,Count : Longint;
|
||||
Info : Pointer;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Procedure fpc_Initialize (Data,TypeInfo : pointer);saveregisters;[Public,Alias : 'FPC_INITIALIZE']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
@ -124,6 +124,7 @@ begin
|
||||
inc(Temp);
|
||||
I:=Temp^;
|
||||
inc(temp,I+1); // skip name string;
|
||||
temp:=aligntoptr(temp);
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
move(PRecRec(Temp)^.Count,Count,sizeof(Count)); // get element Count
|
||||
For I:=1 to count Do
|
||||
@ -196,6 +197,7 @@ begin
|
||||
inc(Temp);
|
||||
I:=Temp^;
|
||||
inc(temp,I+1); // skip name string;
|
||||
temp:=aligntoptr(temp);
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
move(PRecRec(Temp)^.Count,Count,sizeof(Count)); // get element Count
|
||||
For I:=1 to count Do
|
||||
@ -272,6 +274,7 @@ begin
|
||||
Inc(Temp);
|
||||
I:=Temp^;
|
||||
temp:=temp+(I+1); // skip name string;
|
||||
temp:=aligntoptr(temp);
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
move(PRecRec(Temp)^.Count,Count,sizeof(Count)); // get element Count
|
||||
For I:=1 to count Do
|
||||
@ -345,6 +348,7 @@ begin
|
||||
inc(Temp);
|
||||
I:=temp^;
|
||||
inc(temp,I+1); // skip name string;
|
||||
temp:=aligntoptr(temp);
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
move(PRecRec(Temp)^.Count,Count,sizeof(Count)); // get element Count
|
||||
For I:=1 to count Do
|
||||
@ -381,7 +385,10 @@ procedure fpc_finalize_array(data,typeinfo : pointer;count,size : longint); [Pub
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.14 2004-08-18 21:03:35 florian
|
||||
Revision 1.15 2004-10-04 21:26:16 florian
|
||||
* rtti alignment fixed
|
||||
|
||||
Revision 1.14 2004/08/18 21:03:35 florian
|
||||
* sparc uses wait4 as well
|
||||
|
||||
Revision 1.13 2004/07/02 21:21:09 peter
|
||||
|
@ -133,7 +133,11 @@ unit typinfo;
|
||||
end;
|
||||
|
||||
// unsed, just for completeness
|
||||
TPropData = packed record
|
||||
TPropData =
|
||||
{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
packed
|
||||
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
record
|
||||
PropCount : Word;
|
||||
PropList : record end;
|
||||
end;
|
||||
@ -281,6 +285,16 @@ type
|
||||
Auxiliary methods
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
function aligntoptr(p : pointer) : pointer;
|
||||
begin
|
||||
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
if (ptrint(p) mod sizeof(ptrint))<>0 then
|
||||
inc(ptrint(p),sizeof(ptrint)-ptrint(p) mod sizeof(ptrint));
|
||||
result:=p;
|
||||
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||
end;
|
||||
|
||||
|
||||
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
|
||||
|
||||
Var PS : PShortString;
|
||||
@ -407,7 +421,7 @@ end;
|
||||
|
||||
Function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
|
||||
begin
|
||||
GetTypeData:=PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^);
|
||||
GetTypeData:=PTypeData(aligntoptr(PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^)));
|
||||
end;
|
||||
|
||||
|
||||
@ -428,7 +442,7 @@ begin
|
||||
// skip the name
|
||||
hp:=GetTypeData(Typeinfo);
|
||||
// the class info rtti the property rtti follows immediatly
|
||||
pd:=pointer(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1);
|
||||
pd:=aligntoptr(pointer(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1));
|
||||
Result:=@pd^.PropList;
|
||||
for i:=1 to pd^.PropCount do
|
||||
begin
|
||||
@ -436,7 +450,7 @@ begin
|
||||
if Upcase(Result^.Name)=P then
|
||||
exit;
|
||||
// skip to next property
|
||||
Result:=PPropInfo(pointer(@Result^.Name)+byte(Result^.Name[0])+1);
|
||||
Result:=PPropInfo(aligntoptr(pointer(@Result^.Name)+byte(Result^.Name[0])+1));
|
||||
end;
|
||||
// parent class
|
||||
Typeinfo:=hp^.ParentInfo;
|
||||
@ -533,17 +547,18 @@ Var
|
||||
begin
|
||||
TD:=GetTypeData(TypeInfo);
|
||||
// Get this objects TOTAL published properties count
|
||||
TP:=(@TD^.UnitName+Length(TD^.UnitName)+1);
|
||||
TP:=aligntoptr(PPropInfo(aligntoptr((@TD^.UnitName+Length(TD^.UnitName)+1))));
|
||||
Count:=PWord(TP)^;
|
||||
// Now point TP to first propinfo record.
|
||||
Inc(Pointer(TP),SizeOF(Word));
|
||||
tp:=aligntoptr(tp);
|
||||
While Count>0 do
|
||||
begin
|
||||
PropList^[0]:=TP;
|
||||
Inc(Pointer(PropList),SizeOf(Pointer));
|
||||
// Point to TP next propinfo record.
|
||||
// Located at Name[Length(Name)+1] !
|
||||
TP:=PPropInfo(pointer(@TP^.Name)+PByte(@TP^.Name)^+1);
|
||||
TP:=aligntoptr(PPropInfo(pointer(@TP^.Name)+PByte(@TP^.Name)^+1));
|
||||
Dec(Count);
|
||||
end;
|
||||
// recursive call for parent info.
|
||||
@ -1475,7 +1490,10 @@ end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.28 2004-08-16 16:12:28 peter
|
||||
Revision 1.29 2004-10-04 21:26:16 florian
|
||||
* rtti alignment fixed
|
||||
|
||||
Revision 1.28 2004/08/16 16:12:28 peter
|
||||
* patch from mattias to fix endianness and bufferoverflow with
|
||||
1 and 2 byte ordinals
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user