home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!usc!hacgate!SDFSERV!johnl
- From: johnl@SDFSERV.hac.com (John Lee)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Version Strings...
- Message-ID: <24689@hacgate.SCG.HAC.COM>
- Date: 12 Jan 93 01:42:40 GMT
- References: <Per_Salmi.0lxs@augs.se> <24661@hacgate.SCG.HAC.COM> <C0KBM1.Kun@well.sf.ca.us>
- Sender: news@hacgate.SCG.HAC.COM
- Organization: Hughes Aircraft Company, El Segundo, CA
- Lines: 61
-
- In article <C0KBM1.Kun@well.sf.ca.us> comeau@csanta.attmail.com (Greg Comeau) writes:
- >In article <24661@hacgate.SCG.HAC.COM> johnl@SDFSERV.hac.com (John Lee) writes:
- >>.... By then, it's too late since the
- >>linker can't throw out things in a module.
- >
- >What can't it throw it away? (I obviously feel it can).
-
- The answer is...it _can_! *BUT* the linker and the object code
- generators (be it assembler or compiler) must cooperate in a way that
- they current don't.
-
- Currently, BLink and most traditional linkers operate at the "module"
- level, where (usually) one source file equals one object module. At
- this level, the linker can detect that a module has no references to
- it, assuming that it's not the startup module, and easily throw it
- out. (I don't know of any linker that does this, however.) It can't
- throw out parts of a module because of internal references (i.e.
- offsets) not mentioned in the symbol table. It can't removing strings
- from the middle of a module without adjusting those internal
- references.
-
- Moreover, the linker has no idea of what in a module can be left out.
- The object module has no information about the smaller units that make
- up the module (e.g., strings or arrays.) But enhance the assembler or
- compiler to add this info and to create object modules in the right
- way, and the linker can throw away non-referenced objects.
-
- But why complicate an already complicated link process? The whole
- point is to clean up stuff the programmer has left in by accident. I
- have a better idea...
-
-
- >>Now, if it had been declared:
- >>
- >> static UBYTE Version[] = "\0$VER: ProgName 1.0 (7.1.92)";
- >>
- >>then the compiler might have noticed the lack of references and
- >>optimized it away.
- >
- >Which leads to the earlier question of: but should it.
- >I certainly don't want nonsense cluttering up my executables,
- >OTOH, there are things like Version (I've seen similar on other systems
- >and have even written said type of situations myself), and other things.
-
- Good question. My answer is "No." If you don't want nonsense to
- clutter your executables, use "lint"-like tools or have the compiler
- warn you about the nonsense. I think SAS/C will warn you about
- non-referenced statics, but not about non-referenced globals
- (externally-visible symbols.) "lint" will warn you about both. With
- "lint" I can ensure things that belong (like a Version string) belong,
- and things that don't are caught.
-
- The bottom line? "lint" is your _friend_. Everybody should get to know
- their friends.
-
- -------------------------------------------------------------------------------
- The crew faces deadly GURUs! Next time on AmigaDOS: The Next Generation.
- +--------+ John Lee
- | HUGHES |
- +--------+ Internet: jhlee@hac2arpa.hac.com
- The above opinions are those of the user and not of those of this machine.
-