Hi, All
I haven't seen this discussed (obviously) in a topic search so I thought I'd stick my head above the parapet...
I am curious about NASM's implementation of the "EXTERN" word in two respects, both in comparison to C's. Context: suppose one has a large library of assembly language functions, maybe 30 functions, with each function having its own implementation file but you have just one single header file to declare each function as EXTERN. The idea being a bit like libc where you only have to include a few header files but you have access to a large range of functions and you only get the ones in your binary that you actually used. I am using NASM v2.09.08 from Ubuntu 11.10.
So:
1. If one declares something EXTERN in a header file in NASM, then you can't later provide a definition for it. In C, one can declare something extern in a header file and then provide the implementation and the C compiler doesn't complain. This makes it tricky to have a file in the library build which includes the library's own header file(s) without also having to use macros to declare a symbol correctly as EXTERN/GLOBAL depending upon whether it's currently the file being assembled. My reading of the manual is that this is quite intentional.
2. If one declares a symbol EXTERN in NASM, then any object file produced seems to contain an undefined reference to said symbol regardless of whether the symbol was actually referenced by an instruction or data element. This makes it difficult to use only the bits of the library actually used in your code.
So maybe I am doing something obviously wrong in my use of NASM. Any pointers therefore would be greatly appreciated.
Best regards,
Aidan