Just to put this out there, NASM-X already removes the need of having to extern files manually. That's been there since the first version. The NASM-X INVOKE macro checks to see if a procedure name is already defined. If not, the macro then inserts an EXTERN on the fly. The reason for this was, the same as it is for assemblers like GAS and GoASM. Using EXTERN bloats your object files. Okay, so that's not entirely true. When NASM sees an EXTERN, an entry is put into the symbol table that then ends up in the object file. If the user never satisfies that external dependency, nothing is changed. This means that if I did something like:
BITS 32
EXTERN a_proc
EXTERN b_proc
EXTERN c_proc
EXTERN d_proc
EXTERN e_proc
EXTERN f_proc
EXTERN g_proc
EXTERN h_proc
EXTERN i_proc
EXTERN j_proc
EXTERN k_proc
EXTERN l_proc
EXTERN m_proc
EXTERN n_proc
EXTERN o_proc
EXTERN p_proc
EXTERN q_proc
EXTERN r_proc
EXTERN s_proc
EXTERN t_proc
EXTERN u_proc
EXTERN v_proc
EXTERN w_proc
EXTERN x_proc
EXTERN y_proc
EXTERN z_proc
GLOBAL _start
SECTION .text
_start:
mov eax, 1
mov ebx, 0
int 0x80
BITS 32
GLOBAL _start
SECTION .text
_start:
mov eax, 1
mov ebx, 0
int 0x80
Now I assemble and link these exactly the same.
bryant@desktop:~/Projects/bloat$ ls
bloat.asm slim.asm
bryant@desktop:~/Projects/bloat$ for i in *.asm ; do nasm -f elf $i; done
bryant@desktop:~/Projects/bloat$ for i in *.o ; do ld $i -o ${i%.*}; done
bryant@desktop:~/Projects/bloat$ ls -lh
total 24K
-rwxr-xr-x 1 bryant bryant 1.1K Feb 11 13:19 bloat
-rw-r--r-- 1 bryant bryant 450 Feb 11 13:12 bloat.asm
-rw-r--r-- 1 bryant bryant 1.0K Feb 11 13:19 bloat.o
-rwxr-xr-x 1 bryant bryant 497 Feb 11 13:19 slim
-rw-r--r-- 1 bryant bryant 84 Feb 11 13:12 slim.asm
-rw-r--r-- 1 bryant bryant 432 Feb 11 13:19 slim.o
bryant@desktop:~/Projects/bloat$
As you can see in the above example, bloat.asm is considerably larger than slim.asm. This is the reason for EXTERNDEF in MASM. I had this conversation several years back with various members of the NASM team and it was decided that the need for such an extension wasn't worth the effort. Especially when you can simulate it using NASM's macros. The problem is that you need to overload your instructions to insert the extern on the fly, that's why it became part of NASM-X instead of standard.mac. In fact, you could probably add something like:
%imacro externdef 1-*.nolist
%rep %0
%ifndef __defined_%{1}
%define __defined_%{1}
%endif
%rotate 1
%endrep
%endmacro
%imacro call 1.nolist
%ifdef __defined_%{1}
[extern %1]
%endif
call %{1}
%endmacro
To your own standard.mac file before compiling nASM and this would simulate the MASM style EXTERNDEF.
BITS 32
%imacro externdef 1-*.nolist
%rep %0
%ifndef __defined_%{1}
%define __defined_%{1}
%endif
%rotate 1
%endrep
%endmacro
%imacro call 1.nolist
%ifdef __defined_%{1}
[extern %1]
%endif
call %{1}
%endmacro
EXTERNDEF a_proc
EXTERNDEF b_proc
EXTERNDEF c_proc
EXTERNDEF d_proc
EXTERNDEF e_proc
EXTERNDEF f_proc
EXTERNDEF g_proc
EXTERNDEF h_proc
EXTERNDEF i_proc
EXTERNDEF j_proc
EXTERNDEF k_proc
EXTERNDEF l_proc
EXTERNDEF m_proc
EXTERNDEF n_proc
EXTERNDEF o_proc
EXTERNDEF p_proc
EXTERNDEF q_proc
EXTERNDEF r_proc
EXTERNDEF s_proc
EXTERNDEF t_proc
EXTERNDEF u_proc
EXTERNDEF v_proc
EXTERNDEF w_proc
EXTERNDEF x_proc
EXTERNDEF y_proc
EXTERNDEF z_proc
EXTERNDEF puts
GLOBAL _start
SECTION .text
_start:
push dword message
call puts
add esp, 4
mov eax, 1
mov ebx, 0
int 0x80
SECTION .data
message: db "Hello, World!", 0
BITS 32
EXTERN puts
GLOBAL _start
SECTION .text
_start:
push dword message
call puts
add esp, 4
mov eax, 1
mov ebx, 0
int 0x80
SECTION .data
message: db "Hello, World!", 0
bryant@desktop:~/Projects/bloat$ ls
bloat.asm slim.asm
bryant@desktop:~/Projects/bloat$ for i in *.asm ; do nasm -f elf $i; done
bryant@desktop:~/Projects/bloat$ for i in *.o ; do gcc -nostartfiles $i -o ${i%.*}; done
bryant@desktop:~/Projects/bloat$ ls -lh
total 24K
-rwxr-xr-x 1 bryant bryant 2.3K Feb 11 13:34 bloat
-rw-r--r-- 1 bryant bryant 868 Feb 11 13:29 bloat.asm
-rw-r--r-- 1 bryant bryant 624 Feb 11 13:34 bloat.o
-rwxr-xr-x 1 bryant bryant 2.3K Feb 11 13:34 slim
-rw-r--r-- 1 bryant bryant 191 Feb 11 13:30 slim.asm
-rw-r--r-- 1 bryant bryant 624 Feb 11 13:34 slim.o
bryant@desktop:~/Projects/bloat$
As you can see, both files are now the same size. Both are considerably larger because we have introduced the C runtime, but now unused EXTERN's aren't polluting the executable files' symbol table. Keep in mind, all of this is stuff that NASM-X already does for you. This is probably one of the reasons that NASM-X seems to have considerably slower build times is due to the large amount of symbol management. These slower build times were the breaker for this feature in NASM. As it is, NASM builds pretty quick and penalizing the users who have become accustomed to the responsiveness of NASM simply to add a feature that most NASM users won't use would be a hard pill to swallow for the majority of the NASM user-base.
But that's just my two-cents...
Regards,
Bryant Keller