News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Imported-only symbols problem

Started by sapero, December 03, 2009, 02:41:41 AM

Previous topic - Next topic

sapero

When an external symbol...if (!symbol->SectionNumber && (symbol->StorageClass == IMAGE_SYM_CLASS_EXTERNAL))
... is not referenced in any relocation, the linker still tries to find a module X with this symbol and appends it to the final binary, although no symbol from X is directly referenced. Example (masm)
; start
segment .text
extern _blah ; has no references
global _main
_main: ret
; end

Same bug has MS linker. I have a set of OOP compilers where such dummy symbols are imported, and this makes impossible to link such module with link or polink. But I have recently created a plugin which loads all object files before the linker loads them, and changes symbol->SectionNumber = IMAGE_SYM_ABSOLUTE;
symbol->StorageClass = IMAGE_SYM_CLASS_STATIC;
for all imported only symbols, so this is no more problem for me.