flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > PE64 DLL without fixups bug

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 23 Aug 2015, 21:09
Tomasz Grysztar
Quote:
though the fragment mentioning it is perhaps not unequivocal enough

It's not. And as a sidenote the actual loader implementation does not check even this condition.
Quote:
fasm's "format PE" implementation is such that you define image file and memory image side by side

Limited flexibility of format PE is OK for me. I just don't like that you conceptually bind the RVA to the file offset. And for full flexibility I'd prefer to use format binary anyway, though the lack of relocations support there is very frustrating. Btw. I don't think it would be easy to simulate relocations in fasm g, cause it's also important to track the property of relocatability through arithmetical calculations.

_________________
Faith is a superposition of knowledge and fallacy
Post 23 Aug 2015, 21:09
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 23 Aug 2015, 22:21
l_inc wrote:
Btw. I don't think it would be easy to simulate relocations in fasm g, cause it's also important to track the property of relocatability through arithmetical calculations.
The MZ example demonstrates on a simplest case how to do it. For relocations like PE ones all you need is ORG with a base relative to an ELEMENT symbol, say "element ImageBase", and then a DD handler checking whether given value is relative to that element. It is in fact the same principle that fasm 1 uses for relocations, but in a very generalized form.
Post 23 Aug 2015, 22:21
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 24 Aug 2015, 15:14
Tomasz Grysztar
Quote:
all you need is ORG with a base relative to an ELEMENT symbol

That is a cool combination I didn't think of. I only briefly reviewed the manual though. I had a hard time trying to understand the namespaces at the beginning. As for me the wording choice is such that some things are very hard to understand, but it's been a while since then.

_________________
Faith is a superposition of knowledge and fallacy
Post 24 Aug 2015, 15:14
View user's profile Send private message Reply with quote
>_<



Joined: 08 Apr 2015
Posts: 8
>_< 05 Sep 2015, 12:43
hmm...additional test dll x64 rip-relative only

masm64 vs2015
IMAGE_FILE_RELOCS_STRIPPED - NO
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE - YES
Reloc DIR RVA - 0
Reloc DIR SIZE - 0

FASM 1.71.39 without "data fixups" / "section '.reloc' data readable discardable fixups"
IMAGE_FILE_RELOCS_STRIPPED - YES
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE - NO
Reloc DIR RVA - 0
Reloc DIR SIZE - 0

FASM 1.71.39 with "data fixups"
IMAGE_FILE_RELOCS_STRIPPED - NO
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE - YES
Reloc DIR RVA - 00001D5E -> string "test"
Reloc DIR SIZE - 0

FASM 1.71.39 with "section '.reloc' data readable discardable fixups"
IMAGE_FILE_RELOCS_STRIPPED - NO
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE - YES
Reloc DIR RVA - 00002000 -> .reloc section with zero virtual/raw size
Reloc DIR SIZE - 0


non zero "Reloc DIR RVA" (fasm bug)
00007FF8C96A0000 dwmapi.dll
00007FF8CDF20000 oleaut32.dll
00007FF8BCEC0000 atlthunk.dll
0000000100000000 test64.dll <- ASLR FAIL?

manually zero "Reloc DIR RVA"
00007FF8C96A0000 dwmapi.dll
00007FF8CDF20000 oleaut32.dll
00007FF8BCEC0000 atlthunk.dll
00007FF8B4400000 test64.dll <- ok


Tomasz Grysztar
"empty fixups" - OK, what about "data fixups" + "Reloc DIR RVA"? this will be fixed for x64?
and... how about IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA for PE64?
Post 05 Sep 2015, 12:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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.