flat assembler
Message board for the users of flat assembler.
Index
> Windows > 32bit readfile access invalid. Goto page Previous 1, 2 |
Author |
|
Roman 09 Mar 2024, 08:50
Because I thinked org set Start address for all section.
But org valid only to Start code. This is confused! And in documentation not sayed about org and any section. And User thinked org work for all section the same. Last edited by Roman on 09 Mar 2024, 11:53; edited 1 time in total |
|||
09 Mar 2024, 08:50 |
|
Roman 09 Mar 2024, 09:00
Code: section '.bss' readable writeable org 0x2349340 Guff rb 37_000_000 section '. bss' readable writeable gltf_names = 60000 ;size from gltfMapKeyNamesOfst to gltflvlDataEnd 36 080 008 bytes as file size gltfMapKeyNamesOfst rd 1 gltfMapKeyNames rb 64*gltf_names gltflvlData rd 8000000 gltflvlDataCountrOfst rd 1 gltflvlDataCountr rd 1*gltf_names gltflvlDataEnd: Status rd 51200 This code work good for readfile(to gltfMapKeyNamesOfst ) normal load file size 36 080 008 Second bss section data start at 274D000h First bss section start at 0x2349340 Guff Start address 0x2349340 I try readfile in Guff and now file load normal without errors ! Now this code work as i expected. If this code: Code: section '.bss' readable writeable org 0x500000 Guff rb 35_000_000 section '. bss' readable writeable gltf_names = 60000 ;size from gltfMapKeyNamesOfst to gltflvlDataEnd 36 080 008 bytes as file size gltfMapKeyNamesOfst rd 1 gltfMapKeyNames rb 64*gltf_names gltflvlData rd 8000000 gltflvlDataCountrOfst rd 1 gltflvlDataCountr rd 1*gltf_names gltflvlDataEnd: Status rd 51200 Second bss section data start at 404000h First bss section start at 500000h Guff Start address 500000h and Guff cross data from second bss section. Readfile load normal file to Guff without errors. |
|||
09 Mar 2024, 09:00 |
|
bitRAKE 09 Mar 2024, 17:23
I understand the confusion earlier assemblers did use ORG that way, but fasm is too complex. Try this example:
Code: db 0 org $-1 db 1 What your trying to do is very fragile. If it did work, it would break in obscure ways that are difficult to debug. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
09 Mar 2024, 17:23 |
|
revolution 09 Mar 2024, 17:55
bitRAKE wrote: What your trying to do is very fragile. Roman: The code doesn't work. It merely "works" due to coincidence and luck. To prove this try changing the values used in org. Using other values makes it crash. Which means the org there is useless and harmful. Don't use it. |
|||
09 Mar 2024, 17:55 |
|
Furs 09 Mar 2024, 20:27
revolution wrote:
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format |
|||
09 Mar 2024, 20:27 |
|
macomics 09 Mar 2024, 21:03
Furs wrote: What do you mean? https://learn.microsoft.com/en-us/windows/win32/debug/pe-format wrote: For executable images, the address of the first byte of the section relative to the image base when the section is loaded into memory. |
|||
09 Mar 2024, 21:03 |
|
Tomasz Grysztar 09 Mar 2024, 21:22
A more relevant detail in PE specification is this one:
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format wrote: In an image file, the VAs for sections must be assigned by the linker so that they are in ascending order and adjacent, and they must be a multiple of the SectionAlignment value in the optional header. |
|||
09 Mar 2024, 21:22 |
|
revolution 10 Mar 2024, 02:29
And just in case anyone was still doubtful that using org has any effect on the exe output.
Code: ~ cat orgtest.asm format pe gui section '1' data readable org MY_ORG db 0 ~ for ORG in 10 20 30 ; do fasm orgtest.asm -d MY_ORG=$ORG orgtest.$ORG ; done flat assembler version 1.73.31 (16384 kilobytes memory) 1 passes, 1024 bytes. flat assembler version 1.73.31 (16384 kilobytes memory) 1 passes, 1024 bytes. flat assembler version 1.73.31 (16384 kilobytes memory) 1 passes, 1024 bytes. ~ diff <(hd orgtest.10) <(hd orgtest.20) ~ diff <(hd orgtest.10) <(hd orgtest.30) ~ |
|||
10 Mar 2024, 02:29 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.