views:

35

answers:

1

hi, i'm kinda having some issues with linking my assembly. I use NASM for assembly and then I link it with ld. One minor problem is that the GLOBAL directive only works if I define .data section which.. I believe has something reasonable behind it, but still how is that importnant for exporting symbols? (I decided to use coff since that was the most similar format with what came out from g++ with -c option). The major problem is, that even after I managed to link it, the calls lead to some address and the function is not there. Thx for your time reading and if you had some advices or maybe keywords I should google to get something about linking and symbols, that would be totally great.

+1  A: 

I haven't used nasm on Windows, but from looking at the output of nasm -hf I'd guess you want the win32 format, not coff. The COFF format is an older object file format of which the PE-COFF (or just "PE") format now used on Windows is a newer version.

As for why you need to specify a SECTION before your GLOBAL directives takes effect, I'm not seeing that behavior. Is it possible you weren't declaring your GLOBAL prior to the label? Or possibly the symbol is being emitted, but was unable to provide correct linkage if e.g. it was intended as data variable but had space allocated in the .text section.

llasram
yep win32 format pretty much saves the day.. which i would else spend with trial and error. thx a lot. about the global directive thing, is it perhaps possible that nasm generates some default section? I have read somewhere that masm does it.. anyway although my problem is solved i am still open to some deeper info about how the object formats work
stupid_idiot