News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Static RSP built in JWasm

Started by habran, June 14, 2013, 03:39:17 PM

Previous topic - Next topic

japheth

Quote from: habran on August 30, 2013, 06:32:26 AM
It still brakes :(

This has probably nothing to do with unwind. It looks like you're allocating a too small stack space:


main_eh:
  0000000000000128: 48 89 4C 24 08                               mov         qword ptr [rsp+8],rcx
  000000000000012D: 48 89 54 24 10                               mov         qword ptr [rsp+10h],rdx
  0000000000000132: 4C 89 44 24 18                               mov         qword ptr [rsp+18h],r8
  0000000000000137: 55                                           push        rbp
  0000000000000138: 48 8B EC                                     mov         rbp,rsp
  000000000000013B: 48 83 EC 20                                  sub         rsp,20h
  000000000000013F: 48 8B 4D 10                                  mov         rcx,qword ptr [rbp+10h]
  0000000000000143: 48 8B 45 20                                  mov         rax,qword ptr [rbp+20h]
  0000000000000147: 48 89 44 24 38                               mov         qword ptr [rsp+38h],rax    ;<---- !!!!!!
  000000000000014C: 48 8B 45 18                                  mov         rax,qword ptr [rbp+18h]
  0000000000000150: 48 89 44 24 30                               mov         qword ptr [rsp+30h],rax    ;<---- !!!!!!
  0000000000000155: 48 8B 41 10                                  mov         rax,qword ptr [rcx+10h]
  0000000000000159: 48 89 44 24 28                               mov         qword ptr [rsp+28h],rax     ;<---- !!!!!!
  000000000000015E: 48 8B 41 08                                  mov         rax,qword ptr [rcx+8]
  0000000000000162: 48 89 44 24 20                               mov         qword ptr [rsp+20h],rax    ;<---- !!!!!!
  0000000000000167: 44 8B 49 04                                  mov         r9d,dword ptr [rcx+4]
  000000000000016B: 44 8B 01                                     mov         r8d,dword ptr [rcx]
  000000000000016E: 48 8B D1                                     mov         rdx,rcx
  0000000000000171: 48 B9 00 00 00 00 00 00 00 00                mov         rcx,offset ??0004
  000000000000017B: E8 00 00 00 00                               call        printf


In this excerpt you're allocating 20h bytes stack space, but the printf function that is called later needs 40h bytes.

Perhaps you did optimize a bit too much  :icon_mrgreen:

habran

You are right, however, there is no locals in that function that's why it is allocated only size for the reserved stack
I tried to put 4 QWORD dummy locals an it works than
I am actually very busy with my job and did not have enough time to study the sources
I hope on Sunday I will have more time to play with it and hopefully find the solution

thank you Japheth for engaging yourself in this case, I appreciate that  :t
Cod-Father

habran

I did not pay attention that you told me ::)
QuoteMasm64-compatible version, which has to emit the SEH-primitives manually
now I understand what you were talking about and I will work on it as soon as I have a little bit of time
I tasted your version rc10 , it is working fine and I am looking forward for your source code  :t
however, 16 byte alignment in the beginning of proc is missing and that bothers me
my last version has bin fixed so that it works as I wanted it and emits debug info correctly
the only thing now is that damn SEH thing :(
I'll concentrate on that to make it work
Cod-Father

habran

I have uploaded new version at the top of the thread
there was error with restoring a stack when USES xmm used without general registers
replace files with the new ones and rebuild the project
Cod-Father