News:

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

Main Menu

UASM 2.55 Update

Started by johnsa, March 29, 2022, 04:07:18 AM

Previous topic - Next topic

lucho

Thank you very much for updating UASM! As I compiled AMD64 code for the first time, I encountered what I think is a bug in listing generation. For example, the simple source file below
.code
testprc proc
        XOR     RAX,RAX         ; RAX = 0
        XOR     RDX,RDX         ; RDX = 0
        RET
testprc endp
end

when compiled using the command line below
uasm -elf64 -q -mf -Fl -Sa -zcw -Zd test.s
results in the listing file below
UASM v2.55, Mar 30 2022, Masm-compatible assembler.

test.s
                            *   .model FLAT
00000000                    *   _TEXT segment PARA FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment PARA FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:NOTHING
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        testprc proc
00000000  4883EC08                      XOR     RAX,RA00000004  48300000007  4833D2                     XOR     RDX,RDX         ; RDX = 0
0000000A                                RET
0000000A  4883C408          *   RETn
0000000F                          stprc endp
                                end
0000000F                    *   _TEXT ends

(Macros are omitted for brevity.) As a comparison, JWASM using the same source file and command line produces the following listing file:
JWasm v2.11a, Apr  8 2015
test.s
                            *   .model FLAT
00000000                    *   _TEXT segment PARA FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment PARA FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:ERROR
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        testprc proc
00000000  4833C0                        XOR     RAX,RAX         ; RAX = 0
00000003  4833D2                        XOR     RDX,RDX         ; RDX = 0
00000006                                RET
00000006  C3                *   RETn
00000007                        testprc endp
                                end
00000007                    *   _TEXT ends

As far as I understand, what corrupts the listing is the generated "SUB RSP,8 / ADD RSP,8" code in the beginning and in the end (before the RET) of the procedure.

LiaoMi

Quote from: johnsa on March 31, 2022, 07:06:45 PM
It should support all the same types as CV1-4, so type defs, structs, primitive types byte/uint8 - qword, float and arrays.
If you have any specific examples where that isn't the case, I would suggest trying with -Zi and -Zi8 to compare in the debugger. If we can produce a small test case the cvdump utility is very useful and we can see the difference between the types exported into the debug data.

Hi John!

The problem was that the pdb parser for some reason did not understand the structure of the debug symbols. In the debugger this problem disappeared. It seemed to me that local variables in procedures could also be added to debug symbols as constants. In fact, all examples do not have constants and local variables in the debug information.

jj2007

Quote from: LiaoMi on April 10, 2022, 03:22:40 AMIt seemed to me that local variables in procedures could also be added to debug symbols as constants.

Several years ago I saw local variable names in OllyDbg, but I can't remember how I did it - and I've tried many options. Does anybody have a clue how to do it?

anta40

Quote from: johnsa on March 29, 2022, 04:07:18 AM
Hi,

UASM 2.55 has been packaged up and ready. Code is, as always, in 2.55 branch on Github. Windows x86/x64 release packages are on the site.


By default, this won't build on OSX.
There's a workaround, though:
sed -i -e 's/-ansi/-Wno-error=implicit-function-declaration/' UASM-2.55/ClangOSX64.mak

LiaoMi

Quote from: jj2007 on April 10, 2022, 05:03:01 AM
Quote from: LiaoMi on April 10, 2022, 03:22:40 AMIt seemed to me that local variables in procedures could also be added to debug symbols as constants.

Several years ago I saw local variable names in OllyDbg, but I can't remember how I did it - and I've tried many options. Does anybody have a clue how to do it?

Hi jj2007,

I also managed to display local variables, but I don't know how. I remember exactly that it was possible. Most likely it was MASM. If you look at the UASM-map file, there are no local variables in it.

HSE

Perhaps old MASM and old Olly?
Equations in Assembly: SmplMath

jj2007

Yes, it might have been Olly 1.0, but I can't get it to work.

HSE

In the phone now, but from memory: there is an option to load the .pdb file? (That file must be in same directory for sure)
Equations in Assembly: SmplMath

jj2007

From OLLYDBG.HLP:

QuoteShow ARGs and LOCALs in procedures
If this option is on and you have analyzed the code, OllyDbg displays addresses like [SS:EBP+8] and [SS:EBP-8] within recognized procedures as [ARG.1] and [LOCAL.2], hinting you that first address is the first argument of the procedure and another is the second word of the local data allocated on stack.

That's what I actually see now: mov eax, arg1 or mov eax, local.1 :sad:
MyTest proc uses esi edi ebx argPassed1, argPassed2
Local l1, l2,l3, l4,wc:WNDCLASSEX, buffer[bufSize+1]:BYTE
  int 3
  mov eax, argPassed1
  mov eax, argPassed2
  mov l1, 11111111h
  mov l2, 22222222h
  mov wc.cbSize, WNDCLASSEX
  mov buffer[0], 1
  mov buffer[bufSize], 99

00401031  |.  8B45 08       mov eax, [arg1]
00401034  |.  8B45 0C       mov eax, [arg2]
00401037  |.  C745 FC 11111 mov dword ptr [local.1], 11111111
0040103E  |.  C745 F8 22222 mov dword ptr [local.2], 22222222
00401045  |.  C745 C0 30000 mov dword ptr [local.16], 30
0040104C  |.  C685 93FEFFFF mov byte ptr [local.92+3], 1
00401053  |.  C645 BF 63    mov byte ptr [local.17+3], 63