Xref: utzoo comp.lang.c:17705 comp.sys.ibm.pc:27576 Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Question about linking files Message-ID: <497@lakart.UUCP> Date: 14 Apr 89 14:36:19 GMT References: <16356@cup.portal.com> Distribution: na Organization: Lakart Corporation, Newton, MA Lines: 40 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@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+