flat assembler
Message board for the users of flat assembler.

Index > Main > Use of "select"

Author
Thread Post new topic Reply to topic
Crinan



Joined: 05 Dec 2006
Posts: 28
Location: New Zealand
Crinan
I have come across a strange error in compiling a fasm program. If I include the word "select" as a code reference and call it in the code, the following output from fasm occurs.

flat assembler version 1.67.2
C:\COBOLF\Cplr.fsm [410]:
.end start
\Fasm\Include\win32ax.inc [158] .end [14]:
import_wsock32
\Fasm\Include\win32ax.inc [119] import_wsock32 [0]:
{ common macro import_#lib \{ import lib,functions \} }
\Fasm\Include\macro/import32.inc [45] import [22]:
label dd RVA _label
error: symbol already defined.
> Execution finished.

It is easily overcome by changing the reference, but is "select" some sort of reserved word?
Post 20 Jun 2011, 20:43
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
select. Since by using win32ax.inc you're automatically including wsock32.inc you get the clash (note that this doesn't mean your application imports from wsock32 if no function is used).

I hope I understood what you meant, it would be better if you include at least a few lines of code to see the reference you mention.
Post 20 Jun 2011, 20:51
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
I had this strange thing once. If any of the predefined macros from FASM header files will be used in a place of your own functions, labels, etc. it may produce the clash. Simply rename the clashing keyword - call it Select<something> to be more readable and avoid the clash.
Post 21 Jun 2011, 02:39
View user's profile Send private message Send e-mail Reply with quote
Crinan



Joined: 05 Dec 2006
Posts: 28
Location: New Zealand
Crinan
LocoDelAssembly:
I'm afraid I don't understand your reply.
Here is a super-simple example of what I mean.

include '\Fasm\Include\win32ax.inc'
start:
call select
invoke ExitProcess,0
select:
ret

AsmGuru62:
Yes, I did rename the reference, but I don't know what the clash might have been.
Post 21 Jun 2011, 03:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
"select" is a Win32 API name.

It is used in the Winsock API.

So when you include 'win32ax.inc' you also get 'wsock32.inc'.

And 'wsock32.inc' defines the label "select".

So when you try to define the label "select" there is a clash with the definition inside 'wsock32.inc'.
Post 21 Jun 2011, 03:49
View user's profile Send private message Visit poster's website Reply with quote
Crinan



Joined: 05 Dec 2006
Posts: 28
Location: New Zealand
Crinan
Thanks Revolution - that explains the situation.
Post 21 Jun 2011, 05:30
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
btw, the worst thing is that FASM gives incorrect error message - something completely different than what is going on. It should simply say on the line where I define the function: "<name>: identifier already defined". Maybe Tomasz will see this post and fix it?..
Post 21 Jun 2011, 13:41
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
AsmGuru62, the problem is that it is actually the includes that are redifining since the "offending line" in wsock32.inc doesn't gets assembled until the programmer uses the ".end entry_point" macro invocation which happens at the end of the source (i.e. after "select:ret").

Still, what you say is somewhat doable by using this inside the official includes:
Code:
if defined label
  err `label "is an API function which is clashing with some label in your code"
end if    
But this won't tell which line of your source is causing this problem so you'll still need to search.
Post 21 Jun 2011, 18:17
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
Good point.

I have IDE which generates code, so I have all the function entries, locals - all generated, so I do not use the end macro. That is why the message was so cryptic.
Post 22 Jun 2011, 01:05
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.