I have a lot of nasm assembly routines in a library but my program is only using a few of them. Everything works fine but the linker always links ALL the nasm functions in the library, even if they are never called. This results in a binary larger than it could be. C-compiled functions in the same library that are unreferenced are successfully discarded. I am using Windows with nasm 2.05.01, Visual Studio 2005 and Intel Compiler 9.1. Has anyone experienced a similar issue?
I would really like it if the linker does as it should and automatically discards unused functions. You'll see below that objdump outputs looks very different for C and nasm output - the symbol type ("ty") is different and the representation of function, labels, etc. seems to be very different too. I can't find any options or tools to make nasm obj files look more like the C one.
Any ideas appreciated!
==Unreferenced C function example==
Linker message (/verbose):
Discarded _MyCFunction from SomeLib.lib(SomeFile.obj)
objdump output:
[180](sec 26)(fl 0x00)(ty 20)(scl 2) (nx 1) 0x00000000 _MyCFunction
_MyCFunction:
AUX tagndx 182 ttlsiz 0xde lnnos 13929 next 194
_FilterGeneric_doNoiseDetection :
65535 : 00000007
2 : 0000000b
65535 : 0000000d
2 : 00000021
4 : 00000038
6 : 0000003b
7 : 00000049
9 : 00000051
13 : 00000070
14 : 0000007c
13 : 00000080
14 : 00000082
17 : 0000008d
14 : 00000090
15 : 00000092
17 : 00000098
18 : 0000009f
19 : 000000a4
7 : 000000a9
6 : 000000bf
21 : 000000d5
==Unreferenced nasm function example ==
[ 18](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000074c _MyAsmFunction
[ 19](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x000007ef _MyAsmFunction.loop1
[ 20](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000800 _MyAsmFunction.loop2