Probly the second one.

Now that FASM is 1.40, I've decided to start using it.

My first project was to see if I could make VC7 assemble and attach to the process and debug it.

My test source was TUT03 from the tutorial file Privalov posted.

It will assemble PE GUI 4.0, but VC7 cannot attach to the process.

So I decided to try COFF.

I changed the line 'format PE GUI 4.0' to 'format MS COFF'.

This is the command line and error I get:


fasm tut03.asm test.obj
flat assembler version 1.40
tut03.asm [83]:
section '.idata' import data readable writeable
error: extra characters on line


The only part of the code I've touched is the format and an int 3 after the WinMain entry point.

Is there some form of structural difference needed for MS COFF to work? Are PE GUI 4.0 and MS COFF not supposed to be interchangable? Am I missing something else?

Thanks.


edit: another quick question. Can I use 'fasm c:\program\program.asm c:\debug\program.exe'?? So far I have not been able to assemble without the fasm exe being in the same directory.
Posted on 2002-08-23 08:01:11 by ThoughtCriminal
The "import" flag doesn't work with MS COFF format, PE data directories are generated by the linker.
Posted on 2002-08-23 08:06:00 by Tomasz Grysztar
I've only use MASM, so I'm trying to understand this. I looked at the COFF tutorial by Eoin.

So COFF does not use the .idata section?

Eoin's tutorial has no .idata, but he can still 'invoke SendMessage....'

If I remove .idata and try to make an obj...

tut03.asm [23] stdcall [3]:
invoke GetModuleHandle, NULL
error: invalid value.

I have the includes. Please help me understand when assembling for COFF, where does it get the API name from, if not from the includes? Or am I reading the above error wrong?

Thanks.
Posted on 2002-08-23 08:46:47 by ThoughtCriminal


tut03.asm [23] stdcall [3]:
invoke GetModuleHandle, NULL
error: invalid value.


It happens in line 3 of the stdcall macro, so I guess you have no equate for NULL :)
Try to replace it with 0 .
Posted on 2002-08-23 08:57:32 by bazik
Not, not having an equate for NULL is not the problem, it errors on 0 also.

I looked close at Eoin's tutorial. He has a kernel32.inc and kernel32.ext. kernel32.ext defines the names:

extrn __imp__AddAtomA@4:dword
AddAtomA equ __imp__AddAtomA@4
AddAtom equ AddAtomA

kernel32.inc is the same as the FASM distributions kernel.inc with one line added at the top:

include 'include\kernel32.ext'

.....Hmmm COFF does not like 'entry start'. Figures becasue the linker sets the entry.

uhoh..

tut03.asm [45] stdcall [3]:
invoke LoadIcon, NULL, IDI_APPLICATION
error: invalid value.

Well Eoin's tutorial uses some other includes besides kernel32, better grab those :grin:





Figured it out!!! Thanks for the hint Privalov, and thanks to Eoin for his COFF tutorial. I never would have know about the .ext files..

:alright:
Posted on 2002-08-23 09:17:50 by ThoughtCriminal
TheExt files were just something I threw together to make make life easier for myself. I like to use libraries and resources so I really only changed over to Fasm when coff support appeared.

Here attached are all the ext files I've needed so far, plus the prog I use to make them. IncToExt as it's called will convert Masm inc format files to the ext files. It's not exactly a robust program, and is probably quite intollerent so stick to files supplied with Masm32.
Posted on 2002-08-25 16:32:00 by Eóin
Eoin, or some kind person more familar with FASM than I...



I've assembled Privalov's tut03.asm to an obj.

But I can only link an exe using /FORCE becasue of a bunch of unresolved externals.

I'm not sure if it is something I'm doing wrong with FASM, or perhaps I do not know link well enough.

I'm using Eoin's ext files, so I guess FASM is including the references in the obj. I have no idea yet how to exclude them.

I like to use libs too.(but tut03 is not a good cannidite for a lib)
Posted on 2002-08-26 08:35:26 by ThoughtCriminal
I've never seen that problem before, nor am I seeing it now :grin: . When I remove the FORCE directive and run the batch file the exe is made perfectly.

What exact problem are you having?
Posted on 2002-08-26 19:54:30 by Eóin
I've posted the output when I link without /FORCE I get when linking. I wonder if it is my version of link? (VC7)

I looked at the /FORCEd exe with a debugger and the jump table contains EVERY function listed in the included ext files.

That means every function is included in the obj file too. So Eoin, I'm wondering how you set up your tutorial to only include the needed functions int the obj file? Thats is probably where my problem is.

Thanks.
Posted on 2002-08-26 22:22:07 by ThoughtCriminal
It must be a difference between the link version, I use the one that comes with masm32. The only thing I can suggest is trying the /OPT:REF directive, or perhaps it should be /OPT:NOREF, I can't remeber which one so try both :alright:
Posted on 2002-08-27 04:07:00 by Eóin
Thanks Eoin. I'll try both, maybe even the old linker.
Posted on 2002-08-27 06:23:09 by ThoughtCriminal
Hmmm get the same error with MASM32 link and VC7 link /OPT:REF or /OPT/NOREF

Also get the error with your example project. I've made no changes except file paths...

Weird.
Posted on 2002-08-27 07:51:03 by ThoughtCriminal
I'm at a loss then, the only warning link gives me is

LINK : warning LNK4089: all references to "GDI32.dll" discarded by /OPT:REF

And it only gives this for libraries where I included all the extern definitions but then don't actually use any of the functions in that library.

Its a bit strange as I never actually use the /OPT:REF directive, it seems to assume it by default.

Someone else here must know more about link.
Posted on 2002-08-27 12:11:01 by Eóin
Maybe you should ask in Main, people there may know more about link.
Posted on 2002-08-27 13:55:32 by Tomasz Grysztar
Thanks for trying. :(

Perhaps I shall trying in main.

Privalov, since you wrote the COFF support, I assume you understand it? If so, when an obj is made containing references to a lib(ie. kernel32.lib), is the COFF standard to put every function available in the obj? If that is how it works, I then know it is the linkers job to select what funtions to add to the exe. If that is not how it works, I know I'm doing something wrong in FASM.

Also since FASM can save as a bin, couldn't someone devise there own lib format for FASM? If so, once I understand FASM better, I might just try to do that.

Thanks.
Posted on 2002-08-27 20:46:09 by ThoughtCriminal
It has to be something small ThoughtCriminal as I don't seem to be doing anything special, yet the version of Link (5.12.8078) I got with masm32 is discarding all the unneeded references. And its telling me that the /OPT:REF directive is responsible for it doing that.

If you can't figure it out try a specific thread in main about this, someone is bound to know. :)

Perhaps also, though I don't know know what the lisence is for your version of link, you could upload it so someone else could give it a try. Just take care to avoid doing anything illegal, it ain't fair to get the board or Hiro in trouble :alright:
Posted on 2002-08-27 21:18:38 by Eóin