News:

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

Main Menu

Assemble Link Symbolic Debug 64bit

Started by LarryC, May 23, 2014, 10:39:05 PM

Previous topic - Next topic

LarryC

Yesterday I didn't have luck finding any good references to start building and debugging 64bit assembler apps, here's some information I came up with.

JWAsm - http://www.japheth.de/JWasm.html
Jwlink - http://www.japheth.de/JWlink.html
WinInc - http://www.japheth.de/WinInc.html
PellesC - http://www.christian-heffner.de/index.php?page=download&lang=en
Visual Studio (Express 2013 for Windows desktop) - http://msdn.microsoft.com/express

br.cmd - Build release, no debug info
jwasm -c -win64 -Zp8 -Sg -Ic:\asm\Include -Fl=%1.txt %1.asm
@Rem Using JWLink
@Rem jwlink.exe file %1.obj name %1.exe libpath c:\asm\Lib64 runtime console
@Rem MS Linker
@Rem link.exe %1.obj /OUT:%1.exe /libpath:c:\asm\Lib64 /subsystem:console
Rem PellesC linker - Smallest output
polink.exe %1.obj /OUT:%1.exe /libpath:c:\asm\Lib64 /subsystem:console

bpd.cmd - Build to debug in PellesC
Rem Debug with PellesC
jwasm -c -win64 -Zd -Zi -Zp8 -Sg -Ic:\asm\Include -Fl=%1.txt %1.asm
polink.exe /debug %1.obj /OUT:%1.exe  /libpath:c:\asm\Lib64 /subsystem:console

bmd.cmd - Build to debug in Visual Studio (Express)
Rem Debug with Visual Studio - use Visual Studio prompt
jwasm -c -win64 -Zd -Zi -Zp8 -Sg -Ic:\asm\Include -Fl=%1.txt %1.asm
link.exe /debug %1.obj /OUT:%1.exe /libpath:c:\asm\Lib64 /subsystem:console

PellesC
To debug in PellesC I created a new Win32 Console application called Test.  I added a source file with the following contents:
int main()
{
}
when saving, I added it to the project.  I opened the exe I want to debug.  From the menu chose Project | Debug.  Click OK, you should be debugging with symbolic information.

VS 2013
To debug in Visual Studio 2013 Express for Windows Desktop, I created a new Win32 Console Application.  Unchecked the additional options, clicked Finish.  From the menu Project | Properties | Configuration Properties | Debugging.  Put the full path to your executable in Command.  Right click on the project Add Existing File, select your source file.  From the menu Debug | Step Into (F11).  You should be debugging with symbolic information.

I'd be interested in better easier ways to do this or with other assemblers as well. 

Gunther

Larry,

it's not clear what you want to do. But that:
Quote from: LarryC on May 23, 2014, 10:39:05 PM
int main()
{
}
won't work. You should write at least:

int main(int argc, char *argv[])
{
    return 0;
}

to jump back to the operating system. But in general I would suggest that you should download the MASM32 package. It contains all tools and information you'll need (tutorials, exasmples etc) to start with Win32 coding. If you're familiar with that, the step to 64-bit coding is not so hard. But as a beginner to start from scratch with 64-bit assembly language is a long and complicated ride.

Gunther
You have to know the facts before you can distort them.

qWord

MREAL macros - when you need floating point arithmetic while assembling!

Gunther

qWord,

Quote from: qWord on May 24, 2014, 02:30:51 AM
That is valid for ISO C.

should give a warning, at least. But that doesn't happen - not very logical. Here is the code of iso.c

int main()
{
}

Here's the compiler command line:

gcc -c -O2 iso.c

That's what objdump brings:

objdump -d -Mintel iso.o

iso.o:     file format pe-x86-64


Disassembly of section .text.startup:

0000000000000000 <main>:
   0:   48 83 ec 28             sub    rsp,0x28
   4:   e8 00 00 00 00          call   9 <main+0x9>
   9:   48 83 c4 28             add    rsp,0x28
   d:   c3                      ret

The compiler generates a return instruction, because the application shouldn't hang.

Gunther
You have to know the facts before you can distort them.

qWord

The main function does return when reaching the closing "}". The return value is zero in this case.
Quote from: C115.1.2.2.3 Program termination
If the return type of the main function is a type compatible with int, a return from the
initial call to the main function is equivalent to calling the exit function with the value returned by the
main function as its argument; reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with
int, the termination status returned to the host environment is unspecified.
MREAL macros - when you need floating point arithmetic while assembling!

Gunther

Hi qWord,

Quote from: qWord on May 24, 2014, 03:32:08 AM
The main function does return when reaching the closing "}". The return value is zero in this case.

that's clear but a bit untidy. But what the heck, it's valid.

Gunther
You have to know the facts before you can distort them.

LarryC

Wasn't meaning to throw you off.  The C program was there because I couldn't get PellesC to debug my assembler app if I didn't have some C app loaded.

The post was mostly just a bunch of links and info for someone getting started.  The information seemed available, but quite scattered.  Since I haven't used any of those tools, getting something to work was one challenge, being able to run through a debugger and watch memory, flags, and registers with symbolic information from my app was even harder.  Could just be my poor searching skills :)

Still interested in how others assemble, create libraries, link, and debug 64 bit apps.


Gunther

Larry,

Quote from: LarryC on May 25, 2014, 03:28:14 AM
Still interested in how others assemble, create libraries, link, and debug 64 bit apps.

you may be interested in this thread. As a 64-bit debugger, I know only gdb.

Gunther
You have to know the facts before you can distort them.

vogelsang

Hi Larry,

JWasm has an example of creating dll in example folder. Look for Win64_9d.asm. It has description how to build it.

For debugging 64 bit apps on Windows you could use WinDbg. Download proper for your Windows SDK. It comes along with it.

For Linux 64 bit debugging you may try EDB. It is similiar to OllyDbg. But it is a bit tricky to install.
http://freecode.com/projects/edebugger

Gunther

Quote from: vogelsang on May 25, 2014, 03:30:31 PM
For debugging 64 bit apps on Windows you could use WinDbg. Download proper for your Windows SDK. It comes along with it.

For Linux 64 bit debugging you may try EDB. It is similiar to OllyDbg. But it is a bit tricky to install.
http://freecode.com/projects/edebugger

good links. Thank for for providing.  :t

Gunther
You have to know the facts before you can distort them.