NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on December 31, 2005, 12:48:55 AM
-
When I write a program like the following:
(myprogram.asm)
struc mystruc
.a: resb 1
endstruc
segment Mydata public use32 class=data
; programs data
segment Mycode public use32 class=code
; programs code
(nasmw -s -fobj myprogram.asm)
nasm creates a segment
segment text public use16 class=''
(as seen in the map-File of my linker Alink)
in addition to the segments Mydata and Mycode.
When I try to put the structure-definition
into another segment (in order to avoid the
creation of the text-segment), I get this
warning from nasm:
warning: section attributes specified on
redeclaration of segment: ignoring
Could anyone tell me, why nasm creates this
warning and how to avoid it?
Is it not possible to use the struc-macro
in any of my segments?
I use a win32n.inc file and I get lots of
disturbing warnings because of all the
struc-macros inside of it.
-
Easiest way (short of simply ignoring the warning) is to declare your sections twice:
segment Mydata public use32 class=data
segment Mydata
...now your section still has the "attributes" you declared on it, but the _SECT_ macro (used by the "struc" macro) isn't lugging them around, and Nasm doesn't delude itself that you're trying to change them. (if you were *actually* trying to change them, it *would* be an error!)
The other way would be to use the "xstruc" macros, available in the "contributions" package, instead of the built-in "struc". They don't use _SECT_, and shouldn't cause the problem. (so I'm told - haven't actually used 'em)
You can put "bits 32" at the beginning of the file (-f obj defaults to 16-bit), which will at least make the "default" section 32-bits - shuts up the linker's complaining about the 16-bit section, but you still get a section you don't want or need...
I just declare the sections twice, if I run into it.
Best,
Frank
-
Thank you very much for your support Frank.
I declared my segment twice and everything worked
just fine. I would have had a hard time to figure
this out by myself.
-
Thank you very much for your support Frank.
I declared my segment twice and everything worked just fine. I would have had a hard time to figure this out by myself.