flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > How relocations designed in fasm1?

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 804
Location: Russian Federation, Sochi
ProMiNick 10 Dec 2024, 13:12
In fasm1 at assembly stage any operand as variable/constant/label presented by 20 byte structure
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.
Post 10 Dec 2024, 13:12
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
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.
Post 10 Dec 2024, 15:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.