[Lazarus] trying to read an EXE

Christo Crause christo.crause at gmail.com
Sat Sep 4 12:52:53 CEST 2021

On Sat, Sep 4, 2021 at 11:53 AM duilio foschi via lazarus <
lazarus at lists.lazarus-ide.org> wrote:

> I followed Bart's suggestion and added the -al switch to the fpc.cfg file.
> This was probably the right move, as - after a new compile - I could see
> the wanted .s file beside the regular EXE.
> I uploaded the .s file here:
> https://mega.nz/file/rlpyHa7b#fx0LYTjapmUdFRkzVGCCzFFogqYuEu7UvYQ5HtilLks
> I opened the new .s file with a text editor and had a new surprising
> result: the instruction
> i:=cmbYear.ItemIndex+2005;
> is nowhere to be found.

The assembler file you posted is for the .lpr file only.  The -al option
generates the assembler files per compilation unit, before the project gets
linked.  Also it doesn't show the machine code (this resides in the
compiled object file), which seems to be what you want to inspect/modify.

The easiest way to see both the machine code, the disassembled code and the
Pascal code from inside Lazarus is to place a breakpoint on the line of
interest, run until you hit that breakpoint, then switch to the Assembler

An alternative is to use a tool such as objdump or dumpbin to disassemble
the executable file.  There are options to include source code lines in the
output if available as debug information.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20210904/9f514f2f/attachment.html>

More information about the lazarus mailing list