flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > bug with stub

Author
Thread Post new topic Reply to topic
jekyll



Joined: 25 May 2004
Posts: 14
jekyll
i write stub program:
Code:
format MZ
entry main:start

segment main use16

start:
    


when i try to make PE with this stub compiler crashes.

fasm 1.52
Post 17 Jun 2004, 01:43
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
You have created a multisegment exe (With MZ header) and PE is expecting a plain binary file (org 100) without exe header as stub.

Maybe you could do a test editing manually the first MZ header to point to the PE header.
Post 17 Jun 2004, 12:56
View user's profile Send private message Yahoo Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7781
Location: Kraków, Poland
Tomasz Grysztar
pelaillo wrote:
You have created a multisegment exe (With MZ header) and PE is expecting a plain binary file (org 100) without exe header as stub.

No, it generally accepts the MZ programs, too (and this is even the recommended option). I have to look into that bug.
Post 17 Jun 2004, 13:05
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7781
Location: Kraków, Poland
Tomasz Grysztar
OK, fixed it for the next release. If you want to quickly fix it yourself in current release, find this piece of code in FORMATS.INC (for fasm 1.52 it should be around line 551):
Code:
        movzx   ecx,word [esi+4]
        dec     ecx
        shl     ecx,9
        sub     ecx,eax
        movzx   eax,word [esi+2]
        mov     edx,edi
        add     ecx,eax
        push    ecx
        dec     ecx
        shr     ecx,3
        inc     ecx
        shl     ecx,1
        lea     eax,[edi+ecx*4]
        cmp     edi,[display_buffer]
        jae     out_of_memory
        xor     eax,eax
        rep     stos dword [edi]
        pop     ecx
        call    read
        call    close    

add the "jz read_stub_code" jump and "read_stub_code" label, so it becomes:
Code:
        movzx   ecx,word [esi+4]
        dec     ecx
        shl     ecx,9
        sub     ecx,eax
        movzx   eax,word [esi+2]
        mov     edx,edi
        add     ecx,eax
        jz      read_stub_code
        push    ecx
        dec     ecx
        shr     ecx,3
        inc     ecx
        shl     ecx,1
        lea     eax,[edi+ecx*4]
        cmp     edi,[display_buffer]
        jae     out_of_memory
        xor     eax,eax
        rep     stos dword [edi]
        pop     ecx
     read_stub_code:
        call    read
        call    close    
Post 18 Jun 2004, 10:21
View user's profile Send private message Visit poster's website Reply with quote
jekyll



Joined: 25 May 2004
Posts: 14
jekyll
Great! Thank you Privalov. :D
Post 21 Jun 2004, 14:57
View user's profile Send private message 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.