flat assembler
Message board for the users of flat assembler.
Index
> Main > Approach for "lea reg64, [reg64 + FunctionName]" |
| Author |
|
|
revolution 08 Feb 2026, 08:27
How is FunctionName defined? I had no trouble with this:
Code: format pe64 FunctionName: lea rax, [rbp + rva FunctionName] Code: flat assembler version 1.73.31 (16384 kilobytes memory) 1 passes, 1024 bytes. |
|||
|
|
alorent 08 Feb 2026, 09:55
Thanks revolution.
Your example builds correctly. When I use "MS64 COFF" it fails: Code: format MS64 COFF FunctionName: lea rax, [rbp + rva FunctionName] Not sure if it's a bug in FASM or a limitation for COFF OBJ? Thanks! |
|||
|
|
revolution 08 Feb 2026, 10:18
For linkable formats use $$
Code: format ms64 coff org 0x123450 FunctionName: lea rax, [rbp + FunctionName - $$] |
|||
|
|
alorent 08 Feb 2026, 16:49
Thanks revolution! That worked!! I will do some tests
|
|||
|
|
Tomasz Grysztar 09 Feb 2026, 01:15
alorent wrote: When I use "MS64 COFF" it fails: As for the $$, it evaluates to the base address of the section. More precisely: the section fragment which you define in your object file (the linker may combine multiple such sections into a single one). |
|||
|
|
alorent 13 Feb 2026, 11:36
Thanks a lot Tomasz!
You are right, with the "$$" approach it's from the base of the OBJ and not the RVA in the finally linked module. |
|||
|
|
revolution 13 Feb 2026, 12:34
Any label can be used as the base.
Code: format ms64 coff my_base: lea rbp,[my_base] lea rax, [rbp + FunctionName1 - my_base] lea rbx, [rbp + FunctionName2 - my_base] lea rcx, [rbp + FunctionName3 - my_base] FunctionName1: FunctionName2: FunctionName3: |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.