Search code examples
windowsassemblylinkerx86-6464-bit

How can I enable function level linking with a Windows 64 bit assembly file


I need to have several hundred functions written in assembler. They will be statically linked into an executable. I only want the functions that are actually referenced to be included in the executable.

I could achieve this by putting each function into a separate assembler file, assembling each file, creating a .lib from all the resulting objects, and linking against the .lib. As the C compiler supports function level linking, I feel there should be a way to do this in a single assembly file.

Each function will have a little block of static data. Again, this should only be included if the function that uses it is referenced.

It must be statically linked. Putting everything into a dll is not an option.


Solution

  • if run

    ML64.exe /?
    

    we can get next line in output:

    /Gy[-] separate functions for linker 
    

    which is coincides with /Gy (Enable Function-Level Linking)