NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: ben321 on November 05, 2015, 08:04:55 AM

Title: I noticed something interesting with NASM and GoLink
Post by: ben321 on November 05, 2015, 08:04:55 AM
I notice that I don't need to use GLOBAL for the entry point function such as "main:" when compiling in NASM if I'm going to be linking with GoLink. Unlike ALink, which would say it can't find the entry point function if you don't use GLOBAL with the entry point label in NASM, GoLink is still able to find the entry point. Likewise, in an object file that is going to be part of your main EXE file, but not your main OBJ file (for example, someextrafunctions.obj) that you intent to be linked into the same EXE file as the main object file (such as myprog.obj), while you do need EXTERN in the main OBJ file to specify what functions are located in the other OBJ file, you don't need GLOBAL in the other OBJ file to make the function visible to the main OBJ file. Normally GLOBAL is the other side of EXTERN, but if you are using GoLink it is still able to find the function specified with the EXTERN statement, even if the OBJ file that has that function wasn't assembled with the GLOBAL statement. This is really great, as it means cutting down overhead in your assembly files. Of course if you want to go back to using ALink you will need to add these GLOBAL statements back into your code. This is one of the many reasons that GoLink is far superior to ALink. Of course, you must still use EXPORT statement in DLL files for functions that you intent to be callable in other programs (such as EXE files or other DLL files). Apparantly the technique of making functions visible to outside programs via GLOBAL isn't the same process as making them visible to outside programs via EXPORT, so EXPORT is still required for DLL files.