You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
abstract methods are not excluded (since Delphi 2010) #3
This is the result of the enhanced RTTI information emitted into the binary and thus the linker keeping this method in.
There in fact exists code for every abstract method: a jump to System._AbstractError.
The proof is this code:
var
proc: procedure(obj: TObject);
begin
proc := @TClassA.Method;
proc(nil);
If you now place a breakpoint into the line that is being marked blue in your reports you will noticed that it calls that and then jumps to the _AbstractError proc.
Now because since Delphi 2010 enhanced RTTI is enabled for all public methods the linker does not remove this method body which is not being called otherwise. When doing a virtual call to that method it directly goes to _AbstractError as the compiler has its address put into every VMT slot that is abstract for that class - you can see that with this code:
with TClassA.Create do
try
Method; // put breakpoint here and step into (with debug dcus enabled you will end up in System._AbstractError
finally
Free;
end;
Activity
sglienke commentedon Sep 15, 2022
This is the result of the enhanced RTTI information emitted into the binary and thus the linker keeping this method in.
There in fact exists code for every abstract method: a jump to
System._AbstractError.The proof is this code:
If you now place a breakpoint into the line that is being marked blue in your reports you will noticed that it calls that and then jumps to the _AbstractError proc.
Now because since Delphi 2010 enhanced RTTI is enabled for all public methods the linker does not remove this method body which is not being called otherwise. When doing a virtual call to that method it directly goes to _AbstractError as the compiler has its address put into every VMT slot that is abstract for that class - you can see that with this code:
You can solve this be either implicitly disabling RTTI for your class (has to be put into every affected unit - see https://docwiki.embarcadero.com/RADStudio/Alexandria/de/RTTI-Direktive_(Delphi)
or let the linker not keep methods just for RTTI by using the https://docwiki.embarcadero.com/RADStudio/Alexandria/en/WEAKLINKRTTI_directive_(Delphi)