I had a chat session with
Jester on Liberia.com at the assembly channel.
Because I asking, why the application I currently programming on crash in the runtime.
As such, we discuss, what assembly is used, and why.
Then, today's night, I had a talk with ChatGPT, and I was surprising which results came out to understand the assembly better and better on a advance user point of view. I have to say, that I am not the assembly guru. But ChatGPT was my miracle on this.
As such, I used the
SED - the
Unix
Stream
EDitor tool, to patch the assembly sources that was produced by the
FPC Compiler.
So, could filter the sources, and adding patched Code.
As example, I add pascal code in Delphi classic way for class usage like:
type
TMyClass = class
public
constructor Create;
end;
This produce me a very lot of assembly code with the symbol name:
SYSTEM$_$TMYCLASS_$__$$_CREATE$$TMYCLASSDon't make thinking's on what this is - it is the mangled name when you use:
foo := TMyClass.Create;I could shrink the code to a minimum of:
section .text
global SYSTEM$_$QSTRING_$__$$_CREATE$$QSTRING
SYSTEM$_$QSTRING_$__$$_CREATE$$QSTRING:
push rbp ; save current stack value
mov rbp, rsp ; update rbp to show to new function body
sub rsp, 8 * 3 ; reserve 24 (8 * 3) Bytes
add rsp, 24 ; reset the stack
mov rsp, rbp ; set rsp value to rbp to reset stack
pop rbp ; get the last value of rbp
ret ; return to caller
But this was not enough for me - because each class member including ctor and dtor, you have so very long symbol names in the finally binary file, that you could think, that 50 percent of the code is text of symbol names, that you never ever need.
So, I did a little research.
And as a lazy programmer I found a solution.
It is called
objcopy - a tool, which can help to re-define the symbols of object files.
This means, you can make the symbol name "foo" from the existing symbol name "abracadabera_along_long_name".
You can see the differences ?
Okay, I did a little more research, and sed-out more things like
RTTI - the
Run
Time
Type
Informations.
Because not every programmer or end user of the application need such huge informations about the internal structure of the application.
Okay, you can say they are important for debugging and problem sending from the user.
But in my case, I don't need
RTTI at this time, so I skipped all information's data from the assembly data - which takes in effect to a smaller finally out, again.
The total sum of steps, to reproduce this, what I doing there would be over-helm the one or the other, so I don't going into the details of all of it. You only need to be a little bit advance programmer/developer to understand the build batch file that I ship with the source project files that I hosted on github.com.
If you have any question's about this script, you can drop a message and I would try to clarify your concern's or service request's.
But don't except that I have a recipe for all
All of this means of procedural/functional programming and not object orient programming.
But thinking in assembly: All are linear data containing 0 or 1 on the very lower level.
I could say: Stay tuned