flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fixups possibly broken

Author
Thread Post new topic Reply to topic
b1528932



Joined: 21 May 2010
Posts: 287
b1528932
Code:
data fixups
end data
push $    




doesnt work. i belive this is correct anyway, pe loader doesnt care where are relocations, it just process them in load time.
fasm should first count number on relocations based on symbols, then build reloc table, and at the end, compile.
Post 01 Nov 2010, 01:10
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
b1528932,

fasm is, by definition, flat. It can handle forward references for numerical constants, not for fixups. Beliefs have nothing to do with that.
Post 01 Nov 2010, 01:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
b1528932: You are right, the Windows loader does not care where the fixups are in the exe file. In theory you can put them at the beginning of the exe, but currently fasm does not support such an arrangement.

Perhaps at the very least fasm could report an error if any relocatable labels are placed after the fixup section.
Post 01 Nov 2010, 04:11
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
Perhaps at the very least fasm could report an error if any relocatable labels are placed after the fixup section.
I thought that's what it does now?

As for the support for forward-referencing fixups, it would be quite simple to implement into fasm, analogously to the section table building (since size of section table can also grow depending on what is defined later in source). It's just that never before anyone suggested that it would be needed for some purpose.
Post 01 Nov 2010, 06:53
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
I implemented resolving of "forward referenced" fixups in 1.69.27. Be warned that it was not thoroughly tested yet.
Post 27 Nov 2010, 10:56
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3044
Location: vpcmipstrm
bitRAKE
Important to also note that Windows loader will not reclaim memory used by fixup section unless it is at end of EXE (or with other discardable sections at end).
Post 28 Nov 2010, 01:39
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
bitRAKE wrote:
Important to also note that Windows loader will not reclaim memory used by fixup section unless it is at end of EXE (or with other discardable sections at end).
Actually AFAIK all 32-bit loaders will never reclaim the fixup memory no matter where you put it or how you mark the section flags. Perhaps the same for 64-bit loaders also?
Post 28 Nov 2010, 01:47
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3044
Location: vpcmipstrm
bitRAKE
I don't know about never, but there they are. Doesn't appear the 64-loader reclaims the memory either.

Edit: if the fixups are not in their own section the program gets relocated for no reason at all. Yet, that is the only way I see not to have a wasted page. Also, seeing some other weird settings. Very Happy
Post 28 Nov 2010, 04:45
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3044
Location: vpcmipstrm
bitRAKE
Relocation page is now readable (at $12000):
Code:
format PE64 GUI 5.0 at 0
section '' code readable writeable executable
    entry $
    enter 32,0
    xor r9,r9
    lea r8,[.title]
    lea edx,[.text]
    xor ecx,ecx
    call [MessageBoxA]
    leave
    retn
.title db "Hello?",0
.text db "Debugger didn't stop!",0


_user db 'USER32'
_MessageBoxA db 0,0,'MessageBoxA',0

    align 8
_user.table:
    MessageBoxA dq RVA _MessageBoxA 
data import
    dd 0,0,0,RVA _user,RVA _user.table
    rd 5
end data

section '' fixups    

_________________
¯\(°_o)/¯ unlicense.org
Post 28 Nov 2010, 05:49
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.