The MASM Forum

64 bit assembler => UASM Assembler Development => Topic started by: johnsa on March 01, 2021, 01:14:16 AM

Title: UASM 2.51
Post by: johnsa on March 01, 2021, 01:14:16 AM
Hi all,

I've updated the git repo, new branch v2.51 and the binaries are on the site for Windows 32bit and 64bit.

Not too much change this release, just rolling up what should have been in 2.50 +
1. Removed option zerolocals totally, it's silly and wasn't implemented fully.
2. Added a warning if win64 options automatically change the stackbase from rbp to rsp (that had caught me out once or twice)
3. Moved some more instructions into codegen v2
4. Some more cleanup and refactoring
5. A data declaration in a proc is now generated AFTER the prologue.. for some reason before hand due to the parser ordering it would put it before the prologue (This was at the request of Vid512).
6. The biggest one, with huge thanks to Nidud for his input, I've added in CV5 / CV8 debug support and followed Nidud's lead.. cmd line switches -Zi5 or -Zi8

I still have very little time for Uasm these days, but am trying to keep it from rotting.. If anyone has the time/will to contribute it would be hugely appreciated.

Thanks!
John
Title: Re: UASM 2.51
Post by: TouEnMasm on March 01, 2021, 02:33:38 AM
 :thumbsup:
Trying to compile the source with VS 2019 I get
Quote
\UASM-master\x86macros.c(317,41): error C2065: 'LANG_REGCALL' : identificateur not declared
Any help ?
Title: Re: UASM 2.51
Post by: jimg on March 01, 2021, 03:06:16 AM
When I try to download 2.51 from the link on the site, it gives me http://www.terraspace.co.uk/uasm249_x64.zip, you have to manually change the link to http://www.terraspace.co.uk/uasm251_x64.zip
Title: Re: UASM 2.51
Post by: jj2007 on March 01, 2021, 03:26:02 AM
Thanks, John - so far it works fine with my fat sources, with one minor hickup in 22+42=64kLines of code:
Code: [Select]
include \masm32\include\masm32rt.inc

buffersize=4000
.data
somedd1 dd 3839
somedd2 dd 3840

.code
start:
  cls
  movsx eax, sbyte ptr somedd1[1]
  print str$(eax), " for sbyte ptr somedd1[1]", 13, 10
  print str$(buffersize/256-255), " for buffersize/256-255", 13, 10
  .if sbyte ptr somedd1[1]<buffersize/256-255
print "dd1 ok", 13, 10
  .else
print "dd1 too big", 13, 10
  .endif
  .if sbyte ptr somedd2[1]<buffersize/256-255
print "dd2 ok", 13, 10
  .else
print "dd2 too big", 13, 10
  .endif
  exit

end start

This assembles fine with the June 2019 version (and Masm, AsmC) but throws an error in UAsm 2.51. I guess it should throw an error, given that buffersize/256-255 = -240 (which gets translated to +16 by Masm, so it most probably means I had a little bug in my code for the last 3 years or so - I expected a positive number). There might be scenarios where -240 is ok for a comparison.

Btw UAsm has become a little bit faster - congrats :thup:
Title: Re: UASM 2.51
Post by: johnsa on March 01, 2021, 05:58:07 AM
Doh... link fixed .. it's been so long since I did an update I've forgotten how haha ;)
Title: Re: UASM 2.51
Post by: hutch-- on March 04, 2021, 05:11:31 AM
Come on guys, John has done great work with UASM but he needs some support in keeping UASM going. If you don't want UASM to fade away, assist with source, write some decent libraries and help out with the support files and you will ensure that it remains available for the many people who need an alternative to Microsoft.
Title: Re: UASM 2.51
Post by: LiaoMi on March 04, 2021, 07:26:50 AM
Hi johnsa,

old bug still exists  :arrow_down:

Code: [Select]
OPTION FLAT:1

includelib c:\masm32\lib\msvcrt.lib
printf proto C :ptr, :vararg

.data
msg32 db "Hello from 32 bit!", 10,0

.code

mainCRTStartup proc C
push eax
push edx
push offset msg32
call printf
add esp, 12
ret
mainCRTStartup endp

end

Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

mywindow2Bug.asm : Error A2197: Unknown fixup type: 9 at .debug$S.19D
mywindow2Bug.asm : Error A2197: Unknown fixup type: 9 at .debug$S.1FE
mywindow2Bug.asm: 28 lines, 2 passes, 2 ms, 0 warnings, 2 errors

Code: [Select]
Starting pass 1
mywindow2Bug.obj : fatal error LNK1190: invalid fixup found, type 0x0001

Quote
I still have very little time for Uasm these days, but am trying to keep it from rotting.. If anyone has the time/will to contribute it would be hugely appreciated.
To contribute, we need to know exactly where to start, it would be nice to have a small tutorial, which describes how to transfer instructions into codegen v2.

Thank you John for your hard work! Thanks Nidud for the updated debug format CV8!
Title: Re: UASM 2.51
Post by: jj2007 on March 04, 2021, 09:19:41 AM
Thank you John for your hard work! Thanks Nidud for the updated debug format CV8!

I echo that :thumbsup:

It would be even better if Hutch' precious efforts could be used with UAsm and AsmC :cool:

I would be interested to see if Japheth's JWASM could be used with the libraries and includes that I already have using the macros I have done but it would still require some of Vasily's macros and I gather that JWASM may not run them properly.

it would still require some of Vasily's macros

It would require disabling the .if, invoke etc macros with e.g. IFIDNI @Assembler, <ML> then .if macro ...

Perhaps like this:
Code: [Select]
IFIDNI @Assembler, <ML>
  include VasilysMacros4ML64.inc   ; invoke, if else endif, repeat ... until, while ... wend, switch .. case .. endsw
ENDIF
include Macros4allAssemblers.inc
Title: Re: UASM 2.51
Post by: hutch-- on March 04, 2021, 11:08:34 AM
JJ,

You had a forlorn hope there of crippling MASM to fit into the sphere of Watcom derivatives. I posted here because it does not seem that John is getting enough support to keep UASM going and that would be unfortunate as it serves the interests of folks who don't want to use Microsoft tools.

Now surely there must be at least some of the UASM followers that could write library modules, provide some decent documentation, come up with some code designs or even help out with the source code. If a community was to develop, it would share the load around and ensure that the project survived.
Title: Re: UASM 2.51
Post by: jj2007 on March 04, 2021, 12:31:46 PM
You had a forlorn hope there of crippling MASM

No, I never had the intention to cripple MASM. Actually, my 64-bit code does build with ML64.exe :cool:
Title: Re: UASM 2.51
Post by: hutch-- on March 04, 2021, 10:45:46 PM
 :biggrin:

I wonder why you keep trying to change the subject about helping John out when you have been flogging the virtues of UASM for such a long time while having criticised MASM for a very long time. If the faithful who have been waxing lyrical about the virtues of UASM actually formed a community to support UASM, it could become a force to be reckoned with.
Title: Re: UASM 2.51
Post by: TouEnMasm on March 05, 2021, 12:52:20 AM
  old bug steel exists ???
Quote
mainCRTStartup proc C
   push eax
   push edx
   push offset msg32
   call printf
   add esp, 12                                              <<<< here is an epilogue who is not needed with uasm (he do it itself)
   ret
mainCRTStartup endp
Title: Re: UASM 2.51
Post by: LiaoMi on March 05, 2021, 03:07:37 AM
  old bug steel exists ???
Quote
mainCRTStartup proc C
   push eax
   push edx
   push offset msg32
   call printf
   add esp, 12                                              <<<< here is an epilogue who is not needed with uasm (he do it itself)
   ret
mainCRTStartup endp

Hi TouEnMasm,

it doesn't change anything, the code is not going to be built  :sad:
Code: [Select]
%UASM%\UASM64 /c /coff /Cp -Zp8 /Cu /nologo /W2 -Zi0 -Zi1 -Zi2 -Zi3 -Zi5 -Zi8 /Zd -Zf %appname%.asm >> %appname%_%stamp%.assemblylog.txt
Title: Re: UASM 2.51
Post by: johnsa on March 05, 2021, 06:15:28 AM
Hi johnsa,

old bug still exists  :arrow_down:

Code: [Select]
OPTION FLAT:1

includelib c:\masm32\lib\msvcrt.lib
printf proto C :ptr, :vararg

.data
msg32 db "Hello from 32 bit!", 10,0

.code

mainCRTStartup proc C
push eax
push edx
push offset msg32
call printf
add esp, 12
ret
mainCRTStartup endp

end

Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

mywindow2Bug.asm : Error A2197: Unknown fixup type: 9 at .debug$S.19D
mywindow2Bug.asm : Error A2197: Unknown fixup type: 9 at .debug$S.1FE
mywindow2Bug.asm: 28 lines, 2 passes, 2 ms, 0 warnings, 2 errors

Code: [Select]
Starting pass 1
mywindow2Bug.obj : fatal error LNK1190: invalid fixup found, type 0x0001

Quote
I still have very little time for Uasm these days, but am trying to keep it from rotting.. If anyone has the time/will to contribute it would be hugely appreciated.
To contribute, we need to know exactly where to start, it would be nice to have a small tutorial, which describes how to transfer instructions into codegen v2.

Thank you John for your hard work! Thanks Nidud for the updated debug format CV8!

I don't think the purpose of option flat is understood here, it should only be used with .BIN output not OBJ. It does not write debug info or generate anything linkable. It's for use when you need to write out sections exactly as is in a way compatible with bootloaders etc. What were you expecting OPTION FLAT to do for you and maybe there are better options to set?
Title: Re: UASM 2.51
Post by: LiaoMi on March 05, 2021, 06:51:23 AM
Hi johnsa,

old bug still exists  :arrow_down:

Code: [Select]
OPTION FLAT:1

includelib c:\masm32\lib\msvcrt.lib
printf proto C :ptr, :vararg

.data
msg32 db "Hello from 32 bit!", 10,0

.code

mainCRTStartup proc C
push eax
push edx
push offset msg32
call printf
add esp, 12
ret
mainCRTStartup endp

end

Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

mywindow2Bug.asm : Error A2197: Unknown fixup type: 9 at .debug$S.19D
mywindow2Bug.asm : Error A2197: Unknown fixup type: 9 at .debug$S.1FE
mywindow2Bug.asm: 28 lines, 2 passes, 2 ms, 0 warnings, 2 errors

Code: [Select]
Starting pass 1
mywindow2Bug.obj : fatal error LNK1190: invalid fixup found, type 0x0001

Quote
I still have very little time for Uasm these days, but am trying to keep it from rotting.. If anyone has the time/will to contribute it would be hugely appreciated.
To contribute, we need to know exactly where to start, it would be nice to have a small tutorial, which describes how to transfer instructions into codegen v2.

Thank you John for your hard work! Thanks Nidud for the updated debug format CV8!

I don't think the purpose of option flat is understood here, it should only be used with .BIN output not OBJ. It does not write debug info or generate anything linkable. It's for use when you need to write out sections exactly as is in a way compatible with bootloaders etc. What were you expecting OPTION FLAT to do for you and maybe there are better options to set?

Thank you, everything is clear, it looks logical. The example is taken from here - http://masm32.com/board/index.php?topic=7900.msg86586#msg86586, the goal was to have debug symbols for mixed mode. But in mixed mode, even the debugger does not always work correctly.
Title: Re: UASM 2.51
Post by: mabdelouahab on March 05, 2021, 10:00:21 AM
Thank you John, is a great work!
It works well on Linux

Assemble started...UASM v2.50, Mar  4 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

main.asm: 35 lines, 5 passes, 131509 ms, 0 warnings, 0 errors
... SUCCESS

The previous version (UASM v2.50, Oct 10 2020) was generating: Error A2169: General Failure
Title: Re: UASM 2.51
Post by: KradMoonRa on March 15, 2021, 01:35:07 AM
Thank you John,

From Your insights and code changes I managed to debug the code properly with gdb.

* Fix VPTESTMW VPTESTMM VPTESTNMW VPTESTMB
* Finally found the bug that I have added by adding the calling conventions to 32bits, reference pointer never initialized in if statement. Seg faults. That's as hard to debug.
* Added Setup Project for windows.
* Added ubuntu/debian package manager project.
* Fix dbgcv.c (_getcwd) to portable code.
* Fix dbgcv.c (_pgmptr) to portable code.
* Striped macrolib to *.inc files, for better contribution without the need to recompile UASM. 
* And more...

Check setup installer for.

Windows Setup, add the necessary path environment variables, and MSBuild BuildCustomizations for VS2019.

windows:
 Win Setup (https://github.com/Navegos/UASM/releases/download/2.51.1_WIN/UASM.Setup.7z)

Linux installs to /usr/bin/uasm and inc files to /usr/include/uasm

Linux:
Instructions:
add the sign key to your trusted keys
Code: [Select]
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 10649EA8D069C51Dor
Code: [Select]
curl -fsSL https://apt.navegos.net/pub.key | sudo apt-key add -Source Links:
add package as sudo
Code: [Select]
sudo add-apt-repository "deb [arch=amd64] https://apt.navegos.net/ubuntu/uasm/ $(lsb_release -cs) main"or
Code: [Select]
echo "deb [arch=amd64] https://apt.navegos.net/ubuntu/uasm/ focal main" | sudo tee /etc/apt/sources.list.d/uasm.listupdate and install
Code: [Select]
sudo apt-get update && sudo apt-get install uasm

I go for a pull request to the master branch or new branch if good insights that's it's ok here.


Some test:
Download attached zip.

linux enviroment
assemble linux object
Code: [Select]
uasm -c -Cp -archAVX -W0 -Gy -zf4 -mf -elf64 -pie -I /usr/include/uasm -Fo testlinux.o testlinux.asm
assemble windows object
Code: [Select]
uasm -c -Cp -archAVX -W0 -Gv -zf3 -mf -win64 -I /usr/include/uasm -Fo testwindows.obj testwindows.asm
windows enviroment
assemble linux object
command prompt
Code: [Select]
uasm -c -Cp -archAVX -W0 -Gy -zf4 -mf -elf64 -pie -I %UASM_INC_DIR% -Fo testlinux.o testlinux.asmbash
Code: [Select]
uasm -c -Cp -archAVX -W0 -Gy -zf4 -mf -elf64 -pie -I $UASM_INC_DIR -Fo testlinux.o testlinux.asm
assemble windows object
command prompt
Code: [Select]
uasm -c -Cp -archAVX -W0 -Gv -zf3 -mf -win64 -I %UASM_INC_DIR% -Fo testwindows.obj testwindows.asmbash
Code: [Select]
uasm -c -Cp -archAVX -W0 -Gv -zf3 -mf -win64 -I $UASM_INC_DIR -Fo testwindows.obj testwindows.asm
Title: Re: UASM 2.51
Post by: six_L on March 18, 2021, 03:28:12 AM
Code: [Select]
mov dqData,0FFFFFFFF00h
the following Error happens.
Quote
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

ij_4.asm(131) : Error A2237: Constant value too large: FFFFFFFF00h
ij_4.asm: 220 lines, 1 passes, 108 ms, 0 warnings, 1 errors
Title: Re: UASM 2.51
Post by: jj2007 on March 18, 2021, 03:33:15 AM
mov is a 32-bit instruction
Title: Re: UASM 2.51
Post by: six_L on March 18, 2021, 03:48:15 AM
Code: [Select]
N_COLUMN STRUCT
JJ qword 16 dup(?)
N_COLUMN ENDS

MCRYPT_AES_256_KEY_STATE STRUCT
Key byte 32 dup(?)
IV byte 16 dup(?)
EncryIJ N_COLUMN 15 dup(<>)
DecryIJ N_COLUMN 15 dup(<>)
Feedback        byte 16 dup(?)
MCRYPT_AES_256_KEY_STATE ENDS
.data?
Xm_Stc MCRYPT_AES_256_KEY_STATE <>
.data
Xm_Stc1 MCRYPT_AES_256_KEY_STATE <>
why don't support this express?
Code: [Select]
N_COLUMN STRUCT
JJ qword 16 dup(?)
N_COLUMN ENDS

MCRYPT_AES_256_KEY_STATE STRUCT
Key byte 32 dup(?)
IV byte 16 dup(?)
EncryIJ N_COLUMN 15 dup(<?>)
DecryIJ N_COLUMN 15 dup(<?>)
Feedback        byte 16 dup(?)
MCRYPT_AES_256_KEY_STATE ENDS
.data?
Xm_Stc MCRYPT_AES_256_KEY_STATE <?>
.data
Xm_Stc1 MCRYPT_AES_256_KEY_STATE <0>
Title: Re: UASM 2.51
Post by: HSE on March 18, 2021, 04:31:25 AM
Code: [Select]
N_COLUMN STRUCT
JJ qword 16 dup(?)
N_COLUMN ENDS

I think in first place must be:
Code: [Select]
N_COLUMN STRUCT
JJ byte 16 dup(?)
N_COLUMN ENDS

And it's an structure with several elements, you can't initialize that with one element.
Title: Re: UASM 2.51
Post by: KradMoonRa on March 18, 2021, 05:51:09 AM
So:
Code: [Select]
mov dqData,0FFFFFFFF00h
the intel manual as no info about
mov MEM, imm64
or here (https://www.felixcloutier.com/x86/mov) for an idea.

can be done:
Code: [Select]
mov rax,0FFFFFFFF00h
mov dqData,rax
or
Code: [Select]
mov64 dqData, 0FFFFFFFF00hmov64 John macro to overcome this and other approaches
Code: [Select]
    MOV64 MACRO dst:REQ, imm:REQ
        MOV DWORD PTR dst, LOW32(imm)
        MOV DWORD PTR dst + 4, HIGH32(imm)
    ENDM

for  dup(?) initializer in one string, gonna think about that. I have done one fixed size macro for sub-struct initializer but not with dup.
Title: Re: UASM 2.51
Post by: six_L on March 18, 2021, 07:07:08 PM
thanks all who responed quickly. :thumbsup:

@HSE
Code: [Select]
typedef struct _CRYPT_AES_256_KEY_STATE {
  unsigned char Key[32];
  unsigned char IV[16];
  unsigned char EncryptionState[15][16];
  unsigned char DecryptionState[15][16];
  unsigned char Feedback[16];
} CRYPT_AES_256_KEY_STATE, *PCRYPT_AES_256_KEY_STATE;
on the basis of the above struct, it's correct. but Word(DWORD,QWORD) are required as units for encryption or decryption at sometimes, such as Unicode,UTF-8,UTF-16.

@KradMoonRa
hope you are keeping the great work to update.

Title: Re: UASM 2.51
Post by: LiaoMi on March 18, 2021, 09:32:09 PM
Hi,

maybe someone also has a random error that disappears with the second recompilation of the source code - Fatal error A1105: Out of Memory ?!
Title: Re: UASM 2.51
Post by: KradMoonRa on March 19, 2021, 06:02:19 AM
#six_L hey i'm trying, but no success for mixed structs with dup yet( :dazzled:)...

* produces the correct results, but mixing struct with dup with sub struct with dup no. all struct with dup ok, all struct with sub struct with dup ok.

Code: [Select]
.data?
N_COLUMN STRUCT
    JJ qword 16 dup(?)
N_COLUMN ENDS

N_COLUMB STRUCT
    jbb byte 1 dup(?)
N_COLUMB ENDS

MCRYPT_AES_256_KEY_STATE STRUCT
    Key     N_COLUMB 32 dup(<?>)
    IV      N_COLUMB 16 dup(<?>)
    EncryIJ     N_COLUMN 15 dup(<?>)
    DecryIJ     N_COLUMN 15 dup(<?>)
    Feedback    N_COLUMB 16 dup(<?>)
MCRYPT_AES_256_KEY_STATE ENDS

.data?
;public Xm_StcN
;Xm_StcN     N_COLUMN  < {?} >                      ;ok
;public Xm_StcM
;Xm_StcM     MCRYPT_AES_256_KEY_STATE <>            ;ok only byte struct
;public Xm_StcK
;Xm_StcK     MCRYPT_AES_256_KEY_STATE { < {} > }     ;ok only dup of struct with dup
public Xm_StcX
Xm_StcX     MCRYPT_AES_256_KEY_STATE { < {} >, < {} >, < {} >, < {} >, < {} > }  ;ok only if all dup of sub struct with dup
.data
;public Xm_Stc1N
;Xm_Stc1N     N_COLUMN  < {0} >                     ;ok
;public Xm_Stc1M
;Xm_Stc1M     MCRYPT_AES_256_KEY_STATE  {''}        ;ok only byte struct
;public Xm_Stc1K
;Xm_Stc1K     MCRYPT_AES_256_KEY_STATE { < {} > }    ;ok only dup of struct with dup
public Xm_Stc1X
Xm_Stc1X     MCRYPT_AES_256_KEY_STATE { < {} >, < {} >, < {} >, < {} >, < {} > }  ;ok only if all dup of sub struct with dup
Title: Re: UASM 2.51
Post by: LiaoMi on March 19, 2021, 08:23:48 AM
Hi johnsa,

with a new CodeView (-Zi5 -Zi8), I get this message during linking

security.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info

Without these flags, there is no message.

Code: [Select]
E:\security\security_20210318_221959.exe: failed to load pdb info.

Do you want to browse for the pdb file on disk?

Code: [Select]
Translated Windows SDK 10.0 32 bits
security.asm: 257 lines, 2 passes, 2046 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Starting pass 1
Processed /DEFAULTLIB:ntdll.lib
Processed /DEFAULTLIB:ntdllp.lib
security.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info
Processed /DEFAULTLIB:kernel32.Lib
Processed /DEFAULTLIB:User32.Lib
Processed /DEFAULTLIB:ntoskrnl.lib
Processed /DEFAULTLIB:Advapi32.lib
Processed /DEFAULTLIB:ucrt.lib
Processed /DEFAULTLIB:crt10_32.lib
module 'security.obj' unsafe for SAFESEH image.
Title: Re: UASM 2.51
Post by: johnsa on March 19, 2021, 08:02:22 PM
Hi,

I too have found this corrupt debugging info in one of my projects. 100 other test-cases and projects were fine.
I spent some time trying to nail it down, what was odd is that the error seemed to come and go depending on which lines of code I commented, ie. it looked like it was related to symbol positioning.
It was hard to follow in my one example where it occurred as the project is about 10k lines, having a smaller test-case that does this would help.

I'm not sure if Nidud has encountered this yet and maybe has some ideas?
Title: Re: UASM 2.51
Post by: six_L on March 19, 2021, 08:45:14 PM
@KradMoonRa:
Hi, That was my mistake.
All is ok.
Code: [Select]
EncryIJ N_COLUMN 15 dup(<?>) ======>EncryIJ N_COLUMN 15 dup(<{?}>)
DecryIJ N_COLUMN 15 dup(<?>) ======>DecryIJ N_COLUMN 15 dup(<{?}>)
.data?
Xm_Stc MCRYPT_AES_256_KEY_STATE <?> ============>Xm_Stc MCRYPT_AES_256_KEY_STATE <{?}>
.data
Xm_Stc MCRYPT_AES_256_KEY_STATE <0> ============>Xm_Stc MCRYPT_AES_256_KEY_STATE <{0}>


Code: [Select]
N_COLUMN STRUCT
JJ dword 16 dup(?)
N_COLUMN ENDS

MCRYPT_AES_256_KEY_STATE STRUCT
Key byte 32 dup(?)
IV byte 16 dup(?)
EncryIJ N_COLUMN 15 dup(<{?}>)
DecryIJ N_COLUMN 15 dup(<{?}>)
Feedback        byte 16 dup(?)
MCRYPT_AES_256_KEY_STATE ENDS
Title: Re: UASM 2.51
Post by: LiaoMi on March 19, 2021, 08:59:36 PM
Hi,

I too have found this corrupt debugging info in one of my projects. 100 other test-cases and projects were fine.
I spent some time trying to nail it down, what was odd is that the error seemed to come and go depending on which lines of code I commented, ie. it looked like it was related to symbol positioning.
It was hard to follow in my one example where it occurred as the project is about 10k lines, having a smaller test-case that does this would help.

I'm not sure if Nidud has encountered this yet and maybe has some ideas?

Hi John,

this is probably the same bug
Quote
maybe someone also has a random error that disappears with the second recompilation of the source code - Fatal error A1105: Out of Memory ?!

Since the results are different every time, it is as if the error occurs in a random manner. This time the error occurred in a different place...

Code: [Select]
Starting pass 1
Processed /DEFAULTLIB:ntdll.lib
Processed /DEFAULTLIB:ntdllp.lib
Processed /DEFAULTLIB:kernel32.Lib
Processed /DEFAULTLIB:User32.Lib
Processed /DEFAULTLIB:ntoskrnl.lib
Processed /DEFAULTLIB:Advapi32.lib
Processed /DEFAULTLIB:ucrt.lib
Processed /DEFAULTLIB:crt10_32.lib
security.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info

And here is the second example - test.obj : warning LNK4200: corrupt line number information in object file; ignored
Code: [Select]
Starting pass 2
     test.obj
test.obj : warning LNK4200: corrupt line number information in object file; ignored
     ntdllp.lib(ntdll.dll)
     ntdllp.lib(ntdll.dll)
     ntdllp.lib(ntdll.dll)
     ntdllp.lib(ntdll.dll)
     ntdllp.lib(ntdll.dll)
     kernel32.Lib(KERNEL32.dll)
     kernel32.Lib(KERNEL32.dll)
     kernel32.Lib(KERNEL32.dll)
     kernel32.Lib(KERNEL32.dll)
Finished pass 2

On the third try, I received the already known message - test.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info
Code: [Select]
Translated Windows SDK 10.0 32 bits
test.asm: 129 lines, 2 passes, 1190 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Starting pass 1
Processed /DEFAULTLIB:ntdll.lib
Processed /DEFAULTLIB:ntdllp.lib
test.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info
Processed /DEFAULTLIB:kernel32.Lib
Processed /DEFAULTLIB:User32.Lib
Processed /DEFAULTLIB:ntoskrnl.lib
Processed /DEFAULTLIB:ucrt.lib
module 'test.obj' unsafe for SAFESEH image.

Different symptoms occur each time. This one is the most serious - Fatal error A1105: Out of Memory, but it is very difficult to get it. I have attached a test case with different results, you can see two log files - test_20210319_104316.assemblylog, test_20210319_104510.assemblylog. Please note that both pdb files differ in size! (!!!)



Title: Re: UASM 2.51
Post by: KradMoonRa on March 20, 2021, 03:08:05 AM
#six_L
Hi
Good catch...

But definitively, the data initiator only initiates 1 byte all the other bytes defaults to 0.

Code: [Select]
.data?
N_COLUMN STRUCT
    JJ dword 16 dup(?)      ;64 bytes
N_COLUMN ENDS

MCRYPT_AES_256_KEY_STATE STRUCT
    Key     byte 32 dup(?)              ;32 bytes
    IV      byte 16 dup(?)              ;16 bytes
    EncryIJ     N_COLUMN 15 dup(<{?}>)  ;960 bytes
    DecryIJ     N_COLUMN 15 dup(<{?}>)  ;960 bytes
    Feedback    byte 16 dup(?)          ;16 bytes
MCRYPT_AES_256_KEY_STATE ENDS

.data?
public Xm_Stc
Xm_Stc      MCRYPT_AES_256_KEY_STATE <{?}>
.data
public Xm_Stc1
Xm_Stc1     MCRYPT_AES_256_KEY_STATE <{-1,-1,-1,-1,-1,-1,-1}>  ; Here the value can grow but only the first 7 bytes are changed the other bytes defaults to 0 empty initiator. Or write 1984 times -1

Title: Re: UASM 2.51
Post by: nidud on March 20, 2021, 05:57:36 AM
Hi,

I too have found this corrupt debugging info in one of my projects. 100 other test-cases and projects were fine.
I spent some time trying to nail it down, what was odd is that the error seemed to come and go depending on which lines of code I commented, ie. it looked like it was related to symbol positioning.
It was hard to follow in my one example where it occurred as the project is about 10k lines, having a smaller test-case that does this would help.

I'm not sure if Nidud has encountered this yet and maybe has some ideas?

Same here, however the last test case made also fails. From the looks of it section F4 (source file info) is misaligned. The section above (F3 - source filename string table) overflows the buffer, so the error depends on the number of files.
Code: [Select]
WIN32_LEAN_AND_MEAN equ 1
include windows.inc

.pragma comment(linker,"/DEFAULTLIB:libcmtd.lib")

.code

main proc
    ret
main endp

    end

It fails if WIN32_LEAN_AND_MEAN is removed.
Title: Re: UASM 2.51
Post by: nidud on March 20, 2021, 06:17:58 AM
Found the (silly) bug (https://github.com/nidud/asmc/commit/fef92f4732cdaf4128ef15e16d8edf3973a71db3).

Files where copied before the size-check.

void cv_write_debug_tables( struct dsym *symbols, struct dsym *types, void *pv )
      name = cv.currdir;
       }
       len = strlen( name ) + 1;
   -   memcpy( cv.ps, name, len );
       p = cv.ps;
       cv.ps = checkflush( cv.symbols, cv.ps, len, cv.param );
   +   memcpy( cv.ps, name, len );
       if ( p == cv.ps )
           cv.ps += len;
       cv.section->length += len;
Title: Re: UASM 2.51
Post by: KradMoonRa on March 21, 2021, 10:31:45 AM
UASM 2.51.2

* regcall implementation for 64bits win/linux/mach, it follows the same principe off the base OS system convention. Now fixed the segfault using language convention with proto for linux/mac 64bits.
* regcall atempt implementation for 32bits win/linux. Now fixed the segfault using language convention with proto for all 32bits system's
* thiscal for 32 bits win.
* syscall linux kernel parameters, only the 6 arguments are implemented, the UASM user must be aware of the return address and system call number etc...
* Fix VPTESTMW VPTESTMM VPTESTNMW VPTESTMB.
* Fix dbgcv.c (_getcwd) to portable code.
* Fix dbgcv.c (_pgmptr) to portable code.
* Add getexec.c with code for get current executable directory path, heart of portable code for getExecutablePath().
* Striped macrolib to *.inc files, for better contribution without the need to recompile UASM, now executable low as 700kb win / 800kb linux.
* and added new macro lib utilities.
* Added Setup Project for windows, using the free version of Advanced Installer.
* Added ubuntu/debian package manager project.
* Small fix for elf64_relocations now using R_X86_64_GOTPCREL64 = 28, /* G + GOT - P + A */
* added option frame:none for linux/mac 64bits only and for manual procedure optimization.
* all code now is aligned for 64bits builds to 16 bytes, but the packed 1 byte code stays the same.
* Pull request Terraspace#138 define alloca only if not defined and not the proposed pointer casting changes it will break uasm.
* Pull request Terraspace#141 strlen() moved from the body for cycle.
* Pull request Terraspace#137 Allow overriding the SWITCHCHAR option by passing -DSWITCHCHAR=0/1 when building.
* Fix by @nidud dbgcv.c corrupted debug info.
* Updated debian package manager distribution for multiple build release and debug files.

Check setup installer for.

Windows Setup, add the necessary path environment variables, and MSBuild BuildCustomizations for VS2019.

Windows setup also installs uasmd debug version and also has 32 bits binaries.

windows:
 Win Setup (https://github.com/Navegos/UASM/releases/download/2.51.2/UASM.Setup.msi)
or
 Win binaries files (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_win64_bin.zip)

linux:
 Linux 64 bits binaries (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_linux64_bin.tar.gz)

Linux installs to /usr/bin/uasm and inc files to /usr/include/uasm

ubuntu apt package manager:
Instructions:
add the sign key to your trusted keys
Code: [Select]
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 10649EA8D069C51Dor
Code: [Select]
curl -fsSL https://apt.navegos.net/pub.key | sudo apt-key add -Source Links:
add package as sudo
Code: [Select]
sudo add-apt-repository "deb [arch=amd64] https://apt.navegos.net/ubuntu/uasm/ $(lsb_release -cs) main main/debug"or
Code: [Select]
echo "deb [arch=amd64] https://apt.navegos.net/ubuntu/uasm/ focal main main/debug" | sudo tee /etc/apt/sources.list.d/uasm.listclean, update and install
Code: [Select]
sudo apt-get update && sudo apt-get purge uasm && sudo apt-get install uasm uasmd
now you have both uasm release and debug versions, if you need debug symbols can be installed with
Code: [Select]
sudo apt-get install uasmd-dbgsym
Source:
 2.51.2.zip (https://github.com/Navegos/UASM/archive/refs/tags/2.51.2.zip)
 2.51.2.tar.gz (https://github.com/Navegos/UASM/archive/refs/tags/2.51.2.tar.gz)
Title: Re: UASM 2.51
Post by: jj2007 on March 21, 2021, 10:56:31 AM
Win7-64: fails for shlx eax, eax, edx: "illegal instruction"

Btw the msi installation takes ages...
Title: Re: UASM 2.51
Post by: KradMoonRa on March 21, 2021, 11:20:17 AM
Win7-64: fails for shlx eax, eax, edx: "illegal instruction"

Btw the msi installation takes ages...

tested and shlx eax, eax, edx works in windows and linux assembling

try this:

linux way:
Code: [Select]
;.x64p
.sysv64
option casemap:none
option stackbase:rbp ;Default and the only possible for SYSV64
;option language:systemv ;Default we have regcall also
option frame:auto ;Default and now possible frame none, check below
option sysv64:7 ;The max possible for SYSV64
;option literals:on
;option vtable:on
;option framepreserveflags:on

.xmm
option arch:avx
option evex:1

include macrolib.inc

.code


windows way:
Code: [Select]
;.x64p
.win64
option casemap:none
option stackbase:rsp ;
;option language:vectorcall ; we have regcall also
option frame:auto ;Default
option win64:15 ;
;option literals:on
;option vtable:on
;option framepreserveflags:on

.xmm
option arch:avx
option evex:1

include macrolib.inc

.code

command line: change -Fo and .asm file for your needs.
Code: [Select]
linux enviroment
assemble linux object
uasm -c -Cp -archAVX -W0 -Gy -zf4 -mf -elf64 -pie -I /usr/include/uasm -Fo testlinux.o testlinux.asm

assemble windows object
uasm -c -Cp -archAVX -W0 -Gv -zf3 -mf -win64 -I /usr/include/uasm -Fo testwindows.obj testwindows.asm

windows enviroment
assemble linux object
command prompt
uasm -c -Cp -archAVX -W0 -Gy -zf4 -mf -elf64 -pie -I %UASM_INC_DIR% -Fo testlinux.o testlinux.asm
bash
uasm -c -Cp -archAVX -W0 -Gy -zf4 -mf -elf64 -pie -I $UASM_INC_DIR -Fo testlinux.o testlinux.asm

assemble windows object
command prompt
uasm -c -Cp -archAVX -W0 -Gv -zf3 -mf -win64 -I %UASM_INC_DIR% -Fo testwindows.obj testwindows.asm
bash
uasm -c -Cp -archAVX -W0 -Gv -zf3 -mf -win64 -I $UASM_INC_DIR -Fo testwindows.obj testwindows.asm

msi file do checks for current environments PATHS, yep slow with earlier version of windows

zip file also added above. Win binaries files (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_win64_bin.zip)
Title: Re: UASM 2.51
Post by: jj2007 on March 21, 2021, 11:43:28 AM
tested and shlx eax, eax, edx works in windows and linux assembling

Sorry, misunderstanding: not my code crashes, but yours: UAsm itself crashes because my very, very old Core i5 doesn't understand shlx :cool:
Title: Re: UASM 2.51
Post by: KradMoonRa on March 21, 2021, 12:04:34 PM
Quote
Sorry, misunderstanding: not my code crashes, but yours: UAsm itself crashes because my very, very old Core i5 doesn't understand shlx :cool:

RIP i5  :rofl:
Title: Re: UASM 2.51
Post by: jj2007 on March 21, 2021, 12:09:16 PM
No problem, version v2.51 of Feb 27 works perfectly on my stone age hardware :tongue:
Code: [Select]
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz (MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX)
Title: Re: UASM 2.51
Post by: TimoVJL on March 21, 2021, 06:45:25 PM
Is this branch v2.51.2 in Git too ?

Windows 7:
UASM Assembler has stopped working
Title: Re: UASM 2.51
Post by: KradMoonRa on March 21, 2021, 07:56:22 PM
Sorry guys, not everyone has AVX2, my mistake  :biggrin:

Rebuild defaults no AVX or higher.

windows:
 Win Setup (https://github.com/Navegos/UASM/releases/download/2.51.2/UASM.Setup.msi) Uninstall and Install again.
or
 Win binaries files (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_win64_bin.zip) Copy hover.

Source:
 2.51.2.zip (https://github.com/Navegos/UASM/archive/refs/tags/2.51.2.zip)
 2.51.2.tar.gz (https://github.com/Navegos/UASM/archive/refs/tags/2.51.2.tar.gz)
Title: Re: UASM 2.51
Post by: TimoVJL on March 21, 2021, 08:35:50 PM
Thanks, we will test it :thumbsup:

Speedtest
17.546s       uasm-2.51.2.exe
9.390s        uasm64.exe
5.335s        asmc.exe   2.30.35
Title: Re: UASM 2.51
Post by: jj2007 on March 21, 2021, 08:45:49 PM
Some glitches to resolve... attached example works fine with MASM 6.14 and others.
Title: Re: UASM 2.51
Post by: LiaoMi on March 21, 2021, 09:36:58 PM
Hi John,

I managed to identify a bug that was not present in the previous version 2.50. The bug occurs on large projects when there are too many include files. An error and an unexpected stop always occur in a different place. I have attached a test case, I can consistently repeat this error.

(https://i.ibb.co/ckvFCmQ/2021-03-21-11-26-22-C-Windows-system32-cmd-exe.png)

Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.


***********
ASCII build
***********

C:\masm32\include\winspool.inc(597) : Fatal error A1105: Out of Memory
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'Test_x86.obj'
Press any key to continue . . .
or
Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.


***********
ASCII build
***********

C:\masm32\include\winspool.inc(574) : Fatal error A1105: Out of Memory
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'Test_x86.obj'
Press any key to continue . . .

(https://i.ibb.co/wzVHMFs/2021-03-21-11-25-51-C-Windows-system32-cmd-exe.png)
Title: Re: UASM 2.51
Post by: LiaoMi on March 21, 2021, 09:39:56 PM
Thanks, we will test it :thumbsup:

Speedtest
17.546s       uasm-2.51.2.exe
9.390s        uasm64.exe
5.335s        asmc.exe   2.30.35

Why is there a big difference in timing ?!  :dazzled:
Title: Re: UASM 2.51
Post by: LiaoMi on March 21, 2021, 09:48:13 PM
Sorry guys, not everyone has AVX2, my mistake  :biggrin:

Rebuild defaults no AVX or higher.

windows:
 Win Setup (https://github.com/Navegos/UASM/releases/download/2.51.2/UASM.Setup.msi) Uninstall and Install again.
or
 Win binaries files (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_win64_bin.zip) Copy hover.

Source:
 2.51.2.zip (https://github.com/Navegos/UASM/archive/refs/tags/2.51.2.zip)
 2.51.2.tar.gz (https://github.com/Navegos/UASM/archive/refs/tags/2.51.2.tar.gz)

Hi KradMoonRa,

could You please add a version for AVX2 to the releases folder? It can be separately marked as AVX2. What options are required in Visual Studio for AVX2, to compile with optimization?
Title: Re: UASM 2.51
Post by: KradMoonRa on March 21, 2021, 10:25:38 PM
Hi LiaoMi

/Oi /arch:AVX2

But i think it will not get significant improvement.

Installing masm32sdk and investigating all above...


windows:
 Win Setup AVX2 (https://github.com/Navegos/UASM/releases/download/2.51.2/UASM.Setup_AVX2.msi) Uninstall and Install again.
or
 Win binaries files AVX2 (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_win64_bin_AVX2.zip) Copy hover.

Title: Re: UASM 2.51
Post by: TimoVJL on March 21, 2021, 10:41:24 PM
[Why is there a big difference in timing ?!  :dazzled:
Just a dynamic linking to vcruntime140.dll
If a your software is too fast, just link it with ucrt and those speed problems are gone :tongue:
Title: Re: UASM 2.51
Post by: jj2007 on March 21, 2021, 10:42:39 PM
/Oi /arch:AVX2

 Win binaries files AVX2 (https://github.com/Navegos/UASM/releases/download/2.51.2/uasm_2.51.2_win64_bin_AVX2.zip)
That's the crashing version. Above I attached a tiny demo that builds fine with MASM 6.14 and all others but doesn't work with your latest non-AVX2 UAsm.
Title: Re: UASM 2.51
Post by: KradMoonRa on March 21, 2021, 11:41:44 PM
Hi,

@jj2007
Chr$ macro has this error to my, figuring how to fix and test.

***********
ASCII build
***********

NewMasm32.asm(148) : Error A2056: Symbol already defined: NewString
 Chr$(106)[NewMasm32.asm]: Macro called from
  NewMasm32.asm(148): Main line code

@LiaoMi

MemOut assembles fines after comment out missing fltlib.inc and rstrtmgr.inc from my masm32sdk
Code: [Select]
        include winspool.inc
        ;include fltlib.inc
        include secur32.inc
        ;include rstrtmgr.inc
Title: Re: UASM 2.51
Post by: jj2007 on March 22, 2021, 12:22:07 AM
See reply #41 (http://masm32.com/board/index.php?topic=9211.msg101563#msg101563). No MasmBasic, just plain Masm32 SDK - and it throws errors.
Title: Re: UASM 2.51
Post by: LiaoMi on March 22, 2021, 12:45:50 AM
Hi,

@jj2007
Chr$ macro has this error to my, figuring how to fix and test.

***********
ASCII build
***********

NewMasm32.asm(148) : Error A2056: Symbol already defined: NewString
 Chr$(106)[NewMasm32.asm]: Macro called from
  NewMasm32.asm(148): Main line code

@LiaoMi

MemOut assembles fines after comment out missing fltlib.inc and rstrtmgr.inc from my masm32sdk
Code: [Select]
        include winspool.inc
        ;include fltlib.inc
        include secur32.inc
        ;include rstrtmgr.inc

@KradMoonRa the same thing after deleting these lines, as I already wrote, the number of include files affects the appearance of this error  :rolleyes:

Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.


***********
ASCII build
***********

C:\masm32\include\winspool.inc(585) : Fatal error A1105: Out of Memory
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'Test_x86.obj'
Press any key to continue . . .
Title: Re: UASM 2.51
Post by: KradMoonRa on March 22, 2021, 12:57:11 AM
Hi,

@jj2007
Chr$ macro has this error to my, figuring how to fix and test.

***********
ASCII build
***********

NewMasm32.asm(148) : Error A2056: Symbol already defined: NewString
 Chr$(106)[NewMasm32.asm]: Macro called from
  NewMasm32.asm(148): Main line code

@LiaoMi

MemOut assembles fines after comment out missing fltlib.inc and rstrtmgr.inc from my masm32sdk
Code: [Select]
        include winspool.inc
        ;include fltlib.inc
        include secur32.inc
        ;include rstrtmgr.inc

@KradMoonRa the same thing after deleting these lines, as I already wrote, the number of include files affects the appearance of this error  :rolleyes:

Code: [Select]
UASM v2.51, Feb 27 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.


***********
ASCII build
***********

C:\masm32\include\winspool.inc(585) : Fatal error A1105: Out of Memory
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'Test_x86.obj'
Press any key to continue . . .


Something is wrong i can't direct reproduce in different system: just to debug trace the exit it ill help find the pointer in cause.
Title: Re: UASM 2.51
Post by: nidud on March 22, 2021, 01:21:27 AM
If you refer to the last version that is most likely the CV8 bug as this will trash random memory locations based on the number of source and include files.

The reason why this was not picked up earlier has to do with the size of the buffer as it is roomy enough for all the test cases used.

This may be tested by omitting the -Zi8 switch (assuming that is used in the test).
Title: Re: UASM 2.51
Post by: LiaoMi on March 22, 2021, 02:17:34 AM
If you refer to the last version that is most likely the CV8 bug as this will trash random memory locations based on the number of source and include files.

The reason why this was not picked up earlier has to do with the size of the buffer as it is roomy enough for all the test cases used.

This may be tested by omitting the -Zi8 switch (assuming that is used in the test).

Hi nidud,

the compilation flag -Zi8 does not affect the error in this case. Fresh installation of masm32 really does not display any error.

@KradMoonRa Try to replace with this folder https://anonfiles.com/w9pdGflfu1/include_zip
Title: Re: UASM 2.51
Post by: jj2007 on March 22, 2021, 02:19:54 AM
Fresh installation of masm32 really does not display any error.
What do you mean with this? Everybody should reinstall Masm32 to make UAsm work??
Title: Re: UASM 2.51
Post by: LiaoMi on March 22, 2021, 02:28:43 AM
Fresh installation of masm32 really does not display any error.
What do you mean with this? Everybody should reinstall Masm32 to make UAsm work??

Hi jj2007,

 :biggrin: :biggrin: :biggrin: these are my test results, nothing more, KradMoonRa has installed a fresh release, so I wanted to find out why he does not have a memory error in his case. The fact is, the previous version did not have this problem. I'm talking about my test sample, not your macro  :tongue: This means that my include files are different from the standard ones.
Title: Re: UASM 2.51
Post by: KradMoonRa on March 22, 2021, 02:32:17 AM
Yep, probably some weird binary symbol in text file...

LiaoMi
This inc files are 32bit or 64bits version?
Title: Re: UASM 2.51
Post by: LiaoMi on March 22, 2021, 02:47:44 AM
Yep, probably some weird binary symbol in text file...

LiaoMi
This inc files are 32bit or 64bits version?

32Bit only

UASM v2.51.2 Test results -> http://masm32.com/board/index.php?topic=9211.msg101525#msg101525
Code: [Select]
UASM v2.51.2, Mar 20 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

Translated Windows SDK 10.0 32 bits
test.asm: 129 lines, 2 passes, 2972 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Starting pass 1
test.obj : fatal error LNK1276: invalid directive 'lib:ucrt.lib' found; does not start with '/'
test.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info

Title: Re: UASM 2.51
Post by: KradMoonRa on March 22, 2021, 02:55:26 AM
Yep, probably some weird binary symbol in text file...

LiaoMi
This inc files are 32bit or 64bits version?

32Bit only

Test results -> http://masm32.com/board/index.php?topic=9211.msg101525#msg101525
Code: [Select]
UASM v2.51.2, Mar 20 2021, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

Translated Windows SDK 10.0 32 bits
test.asm: 129 lines, 2 passes, 2972 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.28.29337.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Starting pass 1
test.obj : fatal error LNK1276: invalid directive 'lib:ucrt.lib' found; does not start with '/'
test.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info

Yep that is the error that @nidud has talking about, fixed Reply #31 (http://masm32.com/board/index.php?topic=9211.msg101529#msg101529)
Title: Re: UASM 2.51
Post by: johnsa on March 30, 2021, 09:11:11 PM
Unfortunately#31 hasn't fixed my corrupt debug info yet. Annoyingly it is only occurring on a massive project, and as I comment lines out/add back in the result changes so it's near on impossible to pin it down :(
I think I'll just have to carry on ignoring it until I can find a reproducable test case of it.

LiaoMi, I tested your MemOut file and it works fine for me with uasm32 and uasm64? Perhaps someone else can try too.

KradMoonRa, I'm thinking it's very confusing that you've got a fork going of UASM with different version numbers and the same name, perhaps we could agree on a name change for your package ?
Maybe something like Kuasm (just a thought following tradition with the naming) ?
Title: Re: UASM 2.51
Post by: nidud on March 30, 2021, 10:28:31 PM
Added a fixup for the CV8 line number table section.

This also fails on large files similar to the filename string table (http://masm32.com/board/index.php?topic=9211.msg101529#msg101529).

In addition to the Section-Header the Lines-Header and Lines-File-Block-Header also needs to be moved into the code buffer. Otherwise these pointers will be lost when the memory block is flushed.

https://github.com/nidud/asmc/commit/cdf2a750936451e8005651d53c1f59712cd5156f
Title: Re: UASM 2.51
Post by: LiaoMi on March 31, 2021, 02:50:32 AM
Unfortunately#31 hasn't fixed my corrupt debug info yet. Annoyingly it is only occurring on a massive project, and as I comment lines out/add back in the result changes so it's near on impossible to pin it down :(
I think I'll just have to carry on ignoring it until I can find a reproducable test case of it.

LiaoMi, I tested your MemOut file and it works fine for me with uasm32 and uasm64? Perhaps someone else can try too.

KradMoonRa, I'm thinking it's very confusing that you've got a fork going of UASM with different version numbers and the same name, perhaps we could agree on a name change for your package ?
Maybe something like Kuasm (just a thought following tradition with the naming) ?

Hi John,

thanks for testing  :thup:, you need to replace the folder with headers (http://masm32.com/board/index.php?topic=9211.msg101583#msg101583 - https://anonfiles.com/w9pdGflfu1/include_zip), then the error will appear. This bug was not present in the previous 2.50 version.
Title: Re: UASM 2.51
Post by: KradMoonRa on March 31, 2021, 04:42:12 AM
KradMoonRa, I'm thinking it's very confusing that you've got a fork going of UASM with different version numbers and the same name, perhaps we could agree on a name change for your package ?
Maybe something like Kuasm (just a thought following tradition with the naming) ?
[/quote]

I'm ok with name change, or a highly dev branch.
Sorry abou push for master branch with overwrite git syncked work, but I work in my dev branch, and git can't do a clear comparison with massive changes.
Right now stopped git push to master, and cancel my push merge to your repo.
Title: Re: UASM 2.51
Post by: johnsa on March 31, 2021, 06:02:42 AM
I'd like to spend some time with you at some point and go through the changes, maybe we can do another set of PRs in small bits back into the main UASM, I'm busy on 2.52 branch now, perhaps for 2.53
so that we can keep everything in sync. I'm quite keen to help support the work you've done on debian etc package manager / installers etc too. Perhaps we can use my hosting if it would help you out.

Applied Nidud's additional cvdbg.c changes, and now my large project no longer has the corrupt debug info. So I think that is another huge win thanks to Nidud!

My next thing to investigate there is RSP vs RBP stack frames, as these don't always show the symbol names in VS Debug. RBP is 98% correct, the the RSP ones are very far off, I'm guessing due to the different stack layout, although the dbg symbols should all have their Relative offsets stored, I'm think it might be that they're not taking RSP as their base and still trying to use RBP.
Title: Re: UASM 2.51
Post by: johnsa on March 31, 2021, 06:04:01 AM
LiaoMi, can you send the includes file folder directly ? That link wants me to install all sorts of chrome extensions and things
Title: Re: UASM 2.51
Post by: LiaoMi on March 31, 2021, 07:01:48 AM
LiaoMi, can you send the includes file folder directly ? That link wants me to install all sorts of chrome extensions and things

I sent you files via google drive  :thup: With ad blockers, I have never had ads there. Nowadays, you need to have this add-on, otherwise advertising can bring all kinds of spies.

Title: Re: UASM 2.51
Post by: KradMoonRa on March 31, 2021, 09:51:56 PM
I'd like to spend some time with you at some point and go through the changes, maybe we can do another set of PRs in small bits back into the main UASM, I'm busy on 2.52 branch now, perhaps for 2.53
so that we can keep everything in sync. I'm quite keen to help support the work you've done on debian etc package manager / installers etc too. Perhaps we can use my hosting if it would help you out.

We can select one or new branch of yours just to get my checks for the diverse changes by theme or fix type. For example implementation of Intel's regcall convention, as a lot of changes in code, not only for x86-64 but also for x86-32, the proc invoke assemble preproc options command-line .c files i have refactored the code for my to read it better. So my idea is I ill-do a clean off repo compare add of small themes/types batch's in one off your's new branch. This way we can track the sync changes better if you are okay with that. I'm ok with importing the packages to you space page. I have made-it for that.
Title: Re: UASM 2.51
Post by: LiaoMi on March 31, 2021, 10:08:49 PM
Hi John,

Memory Leak in CodeGenv2.c .. AllocInstruction() -> return malloc(sizeof(struct Instr_Def)) -> InsertInstruction(pInstr, hash) ->pInstruction Leak

Code: [Select]
void BuildInstructionTable(void)
{
uint_32 hash = 0;
struct Instr_Def* pInstrTbl = &InstrTableV2;
uint_32 i = 0;
uint_32 instrCount = sizeof(InstrTableV2) / sizeof(struct Instr_Def);

memset(InstrHash, 0, sizeof(InstrHash));

for (i = 0; i < instrCount; i++, pInstrTbl++)
{
struct Instr_Def* pInstr = AllocInstruction();
memcpy(pInstr, pInstrTbl, sizeof(struct Instr_Def));
hash = GenerateInstrHash(pInstr);
InsertInstruction(pInstr, hash);
}
}

Code: [Select]
struct Instr_Def* AllocInstruction()
{
return malloc(sizeof(struct Instr_Def));
}

Code: [Select]
void InsertInstruction(struct Instr_Def* pInstruction, uint_32 hash)
{
struct Instr_Def* curPtr = NULL;
curPtr = InstrHash[hash];
if (curPtr == NULL)
{
InstrHash[hash] = pInstruction;
return;
}
while (curPtr->next != NULL)
{
curPtr = curPtr->next;
}
curPtr->next = pInstruction;
}

strcpy vs strcpy_s - Buffer overflow errors may occur if safe functions are not used, there is no information about it even in debug build (https://en.cppreference.com/w/c/string/byte/strcpy)

Overflow with a size of 1 byte (CodeGenv2.c):
uint_32 GenerateInstrHash(struct Instr_Def* pInstruction)
{
   uint_8 hashBuffer[32];
   int len = 0;
   char* pDst = (char*)&hashBuffer;
   strcpy(pDst, pInstruction->mnemonic);

   /* String hash is case-insensitive. */
   for (int i = 0; i < strlen(pInstruction->mnemonic); i++)
   {
      hashBuffer = tolower(hashBuffer);
   }

   len += strlen(pInstruction->mnemonic);
   pDst += len;
   *(pDst + 0) = pInstruction->operand_types[0];
   *(pDst + 1) = pInstruction->operand_types[1];
   *(pDst + 2) = pInstruction->operand_types[2];
   *(pDst + 3) = pInstruction->operand_types[3];
   *(pDst + 4) = pInstruction->operand_types[4];
   len += 4;
   pDst += 4;
   return hash(&hashBuffer, len);
}

orgfixup.c memory leak

void AddOrgFixup(int curPos, int orgValue)
{
   struct orgFixup *curPtr = pOrgTable;
   struct orgFixup *pFixup = (struct orgFixup*)malloc(sizeof(struct orgFixup));
   pFixup->startPos = curPos;
   pFixup->orgValue = orgValue;
   pFixup->pNext = NULL;
   if (!curPtr)
   {
      curPtr = pFixup;
      pOrgTable = pFixup;
   }
   else
   {
      while (curPtr->pNext != NULL)
         curPtr = curPtr->pNext;
      curPtr->pNext = pFixup;
   }
   return;
}

macho64.c memory leak

int macho_build_string_tbl(struct symtab_command *pSymCmd, struct macho_module *mm)
{
   int tblSize = 0;
   int i = 0;
   struct asym *sym = NULL;
   struct strentry *pstr = NULL;
   int totalSymCount = 0;

   /* Normal local symbols */
   while (sym = SymEnum(sym, &i))
   {
      if (strcmp(sym->name, "$xdatasym") == 0) continue;
      if (sym->state != SYM_MACRO && sym->state != SYM_SEG && sym->state != SYM_TMACRO && sym->predefined == 0 && sym->state != SYM_GRP && sym->isequate == 0)
      {
         if (sym->state != SYM_EXTERNAL && !sym->ispublic && sym->used)
         {
            tblSize += strlen(sym->name) + 1;
            pstr = malloc(sizeof(struct strentry));
            memset(pstr, 0, sizeof(struct strentry));
            pstr->pstr = sym->name;
            pstr->sym = sym;
            macho_add_string(pstr, mm);
            mm->symCount++;
            totalSymCount++;
         }
      }
   }
Title: Re: UASM 2.51
Post by: jj2007 on March 31, 2021, 10:24:37 PM
strcpy vs strcpy_s - Buffer overflow errors may occur if safe functions are not used

Coder suicide may occur if M$'s ultraslow "safe" functions are being used :cool:

(remember AsmC is about 25% faster than UAsm; if Nidud had not decided to declare "type" a non-reserved word, I would be tempted to switch...)