Author Topic: Function-level linking  (Read 9016 times)

nobody

  • Guest
Function-level linking
« on: May 07, 2008, 10:49:25 AM »
Can I use function-level linking to eliminate dead code from NASM object files when linking with Microsoft's linker, and if so how do I go about using it? Similarly is there an equivalent of -ffunction-sections/-fdata-sections when linking with GCC?

You see I'm working on a graphics library for which a suite of macros generate a combinatorial explosion of code, little of which a single user will ever need. Not surprisingly this scheme is unmaintainable in the long run if we want to continue adding further blitter functions, bitmap formats and processor specializations.
And having the compiler eliminate dead code seems like the most straightforward solution to the problem, because as far as I can tell the only alternatives are to split up everything into lots and lots of object files or attempt to do runtime code generation.

Frankly I don't know how function-level linking really works and information on the subject seems to be scarce. I would think that separating everything into unique segments, together with the normal symbol references in the object format, ought to provide the linker with enough information to prune dead code. But I fear there's more to it, for one thing Microsoft 's tools tries to merge identical function as well.

/doynax

nobody

  • Guest
Re: Function-level linking
« Reply #1 on: May 08, 2008, 03:03:01 AM »
Simply put each function in its own seperate source file and then use the library tool to generate a "*.lib" static library.

Nathan.

nobody

  • Guest
Re: Function-level linking
« Reply #2 on: May 08, 2008, 11:59:54 AM »
But if I did that I'd already have about two hundred files, eventually growing into the thousands or even tens of thousands. Not exactly what I'd call friendly for the build times..

Anyone know of a useful runtime assembler package with support for all the latest and greatest instruction sets?