flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug in processing the "-d" switch

Author
Thread Post new topic Reply to topic
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
It seems there was a regression in processing the "-d" switch (just checked both the windows and linux version):
Code:
fasm -dx=0 test.asm
flat assembler  version 1.71.48  (16384 kilobytes memory)
error: source file not found.    

It works OK though if the "-d" switch is at the end of the command line.

I also had this situation once, but it's not stably reproducible:
Code:
    


P.S. Sorry, posted to the wrong forum. Please, move it to compiler internals.

_________________
Faith is a superposition of knowledge and fallacy
Post 28 Nov 2015, 17:10
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
I think neither of them is consistently reproducible, or I need more details about the environment, because I was not able to get the "source file not found" error as shown in your post.
Post 05 Dec 2015, 13: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
Tomasz Grysztar
I couldn't reproduce the bug in Windows today, but luckily it was still manifesting in Linux. The problem is how you handle the stack:
Code:
        mov     [command_line],esp
        pop     eax
        lea     esp,[esp+eax*4]
        pop     eax
        pop     [environment]
        call    get_params    

This is what happens at the beginning. argc and argv are beyond the stack limits, but are still on the stack and are gonna be used. Keeping data above (at addresses lower than) the current stack pointer is careless by itself, but then you do multiple calls and overwrite pointers to the command line arguments in your own code. In my examples call convert_definition_option is the instruction that overwrites the pointer to the source file name with the return pointer.

P.S. I made a little trace with gdb, if you'd like to look in there. There's a state of registers in the order eax, ebx, ecx, edx, esi, edi, ebp, esp after each instruction executed.


Description:
Download
Filename: trace.7z
Filesize: 29.76 KB
Downloaded: 306 Time(s)


_________________
Faith is a superposition of knowledge and fallacy
Post 05 Dec 2015, 23:12
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Tomasz Grysztar
I noticed that you'd fixed the bug, but now you get the environment incorrectly. It should be mov ebx,[esp+4+ecx*4+4] instead of lea ebx,[esp+4+4+ecx*4+4] .

_________________
Faith is a superposition of knowledge and fallacy
Post 03 Jan 2016, 01:12
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.

Powered by rwasa.