flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > How relocations designed in fasm1? |
Author |
|
ProMiNick 10 Dec 2024, 13:12
In fasm1 at assembly stage any operand as variable/constant/label presented by 20 byte structure
Code: virtual at 0 expr@opnd.value dq ? expr@opnd.reg1 db ? expr@opnd.reg2 db ? expr@opnd.regamount1 db ? expr@opnd.regamount2 db ? expr@opnd.value_type db ? expr@opnd.value_sign db ? expr@opnd.unknwn14 dw ? expr@opnd.unknwn16 dd ? sizeof.expr@opnd = $ end virtual label expr@opnd.regs dword at expr@opnd.reg1 label expr@opnd.reg.items word at expr@opnd.reg1 label expr@opnd.reg.amounts word at expr@opnd.regamount1 When file format is relocatable information about isrelocative or not stored in "expr@opnd.value_type" member of this structure (suppose in bit 1, but I could wrong). Tomasz, could thou explain meaning of different value_types - for what cases each other? how works "relativeto $" smallest relocatable I could imagine with "relativeto $" construction is Code: format PE if 0 relativeto $ display 'not relative' end if data fixups end data for 0: all 20 bytes structure is zeroed. for $: [expr@opnd.value] holds $00401000 (constant offset part of $) [expr@opnd.regs] holds 0 (because it isn`t relative to any regs) [expr@opnd.value_type] - here is magic (for me magic, suppose 1st bit set) [expr@opnd.value_sign] holds 0 (it could have only 2 values -1 & 0) [expr@opnd.unknwn14] - I even give up to properly name it no idea what it for [expr@opnd.unknwn16] - suppose it is ptr to internal(compilation time) symbol table, but what value would be here in case of $ I don`t know. And in case of "relativeto" operation must be matched only (expr@opnd.regs & expr@opnd.value_type) or expr@opnd.unknwn16 too? for other relocatable file formats Code: format MS COFF if 0 relativeto $ display 'not relative' end if Code: format COFF if 0 relativeto $ display 'not relative' end if Code: format elf if 0 relativeto $ display 'not relative' end if In these cases 20 bytes structure for $ differs from same one from PE by zeroed expr@opnd.value member. Are other field members are differ? or differ only internal symbol structure pointed with expr@opnd.unknwn16. (maybe expr@opnd.value_type interfere in some manner with "type of symbol (table 5.3) from Table 5.1 Symbol structure from fasmguide.zip\tables.txt" and expr@opnd.unknwn16 interfere in some manner with "address of object section or external symbol to which this symbol is relative from Table 5.1 Symbol structure from fasmguide.zip\tables.txt") Thanks in advance. _________________ I don`t like to refer by "you" to one person. My soul requires acronim "thou" instead. |
|||
10 Dec 2024, 13:12 |
|
Tomasz Grysztar 10 Dec 2024, 15:54
There is a direct correspondence between fields of this internal structure and the symbol structure in .fas files, described in table 2 of .fas documentation. The only difference is that in .fas file all direct pointers are replaced with specific offsets/references into the generated file.
|
|||
10 Dec 2024, 15:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.