flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution
I use this code under WinXPSP2:
Code: format PE GUI 4.0 entry start section '.code' data readable executable start: ret section '.reloc' data discardable data fixups if ~ $-$$ dd 0,8 ;empty fixups section iff no other fixups end if end data |
|||
![]() |
|
l_inc
revolution
Well... Thank you. I thought about creating relocations manually. A little bit nasty, but seems to be the only working solution. |
|||
![]() |
|
Tomasz Grysztar
Wow, this one is complex.
![]() Code: if inverse_relocs_size = 0FFFFFFFFh | defined safe_relocs ; ... inverse_relocs_size = dword not ($-$$) So a different approach is needed in this case. We can, for example, exploit the fact that section with just one fixup is 10 bytes in length: Code: if relocs_size = 0 | (defined safe_relocs & relocs_size = 10) safe_relocs dd $ end if revolution's solution is much nicer though. I definitely recommend to do it revolution's way. |
|||
![]() |
|
l_inc
Tomasz Grysztar
Quote:
Thank you! That's exactly, what I was trying to do, but failed to achieve because of some knowledge lack. E.g. undefined variable value defaulting to zero is not documented anywhere, is it? Quote: revolution's solution is much nicer though. I definitely recommend to do it revolution's way Why not making an empty relocations table to be compiled to dd 0,8? As revolution mentioned, zero-sized sections are not accepted by windows loader and thus make no sense. |
|||
![]() |
|
Tomasz Grysztar
Well, it was discussed before: http://board.flatassembler.net/topic.php?p=33127#33127 (note the Win9x vs WinNT difference, too).
|
|||
![]() |
|
l_inc
Tomasz Grysztar
I meant the relocation table, not the relocation section. And dd 0,8 does not mean creation of a dummy block, it really means an empty relocations table with no blocks. Thus padding of any section to achieve non-zero-sized-section is quite normal, because it's the programmer's responsibility to create or to omit section creation. But padding of a relocation table makes no-relocations-case to some special case, whereas making this code: Code: data fixups end data to be compiled as dd 0,8 makes no-relocations-case as regular as any other case. |
|||
![]() |
|
Tomasz Grysztar
Please read the whole thread I linked to.
|
|||
![]() |
|
l_inc
Tomasz Grysztar
Sorry. What I wrote before: Quote: And dd 0,8 does not mean creation of a dummy block, it really means an empty relocations table with no blocks. is not true. My mistake. |
|||
![]() |
|
revolution
l_inc wrote: But padding of a relocation table makes no-relocations-case to some special case, whereas making this code: |
|||
![]() |
|
Tomasz Grysztar
Not true that it does nothing - it creates an empty relocation table which you can fill out yourself if you need (just like any other case of "data" directive, in fact).
Also, as mentioned in that other thread, empty relocations directory is not something wrong by itself - though some Windows versions did have problems with it, others don't. Code: BASE = 1000000h format PE at BASE org BASE ; ... data fixups ; DIY fixups end data |
|||
![]() |
|
revolution
Tomasz Grysztar wrote:
Code: data fixups_without_auto_generation ;My fixus go here end data Code: format PE GUI 4.0 DLL entry start section '' data readable executable start: ret data fixups end data |
|||
![]() |
|
Tomasz Grysztar
revolution wrote: If there were some way to stop fasm from automatically inserting the fixups then it would be a true DIY: That's what the "org BASE" line in my example is for. ...but I made a mistake, it really should have been: Code: org BASE + rva $ Because you've got non-zero RVA right from the start. The trick lies in the fact that "BASE + rva $" is an absolute value equivalent to unrelocated "$". So starting from that point you define absolute addresses, and fasm has no relocations to make. |
|||
![]() |
|
revolution
Tomasz Grysztar wrote: That's what the "org BASE" line in my example is for. ![]() |
|||
![]() |
|
DOS386
Tomasz Grysztar wrote: Well, it was discussed before: http://board.flatassembler.net/topic.php?p=33127#33127 (note the Win9x vs WinNT difference, too). And here http://board.flatassembler.net/topic.php?t=11170 |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.