Question about linking files

David Goodenough dg at lakart.UUCP
Sat Apr 15 00:36:19 AEST 1989


Guts of argument:

file1:		proc1() { proc3(); }

file2:		proc2() { }

file3:		proc3() { }

N.B. file2 is not necessary to resolve inclusion of file1.

The question: Should inclusion of file2 on the command line cause
inclusion of the code for proc2, even though it is not needed to
resolve any undefined labels?

The answer: (IMHO) Yes.

There is a difference between object files (UNIX .o) and Libraries (UNIX .a)
ALL stuff in a .o should be included because it may be needed to resolve
a forward reference. When I write programs, I can produce just 14K of
object from 20 source files (OK I'm using Z80 assembler, but the principle
still holds true in any environment), and I have external references all
over hell's half acre. Now I don't want any damn linker trying to second
guess what I mean. As far as I know, the L80 linker ( father of the MS-DOS
mess????? ) had a /S option to search:

So if I said:

L80 FILE1,FILE2,FILE3/S .....

FILE1.REL and FILE2.REL would be linked in their entirity, needed or not,
but FILE3 would be searched, and only used to resolve current undefined
labels. The linker I use now (ZLINK) does it, but automatically, based on
the filename extension: .O for mandatory linkage, and .L for libraries.
Also the internal format of a .L file is a little different, but that's
another story.
-- 
	dg at lakart.UUCP - David Goodenough		+---+
						IHS	| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp at xait.xerox.com		  	  +---+



More information about the Comp.lang.c mailing list