Link time optimizations

jacob@jacob.remcomp.fr (Jacob Navia)
9 Feb 1996 17:00:34 -0500

          From comp.compilers

Related articles
Link time optimizations jacob@jacob.remcomp.fr (1996-02-09)
Re: Link time optimizations jaidi@ubd.edu.bn (1996-02-10)
Re: Link time optimizations richard@atheist.tamu.edu (1996-02-13)
Re: Link time optimizations jaidi@ubd.edu.bn (1996-02-14)
| List of all articles for this month |

From: jacob@jacob.remcomp.fr (Jacob Navia)
Newsgroups: comp.compilers
Date: 9 Feb 1996 17:00:34 -0500
Organization: Compilers Central
Keywords: linker, optimize

Some months ago I developed an object file cross referencing utility
that would investigate all given files and produce a list of all
public names that were exported from a module but never used in any
other.


I'm now finishing a linker (for Windows 95), and I will add that to
the linker. The algorithm that I used was simple: just look at all
symbol tables for symbols of type external and see whether they are
used elsewhere or not. The problem with this rather simplistic
approach is that a symbol could be used in the SAME module, i.e. it's
exported, used nowhere else, but used in that module.


Question is: how can my linker detect that?


For data references, the solution is easy: just see if there is a
relocation for that symbol. If there is, the symbol is used. For
functions (procedures) the problem is much more difficult. Normally
all compilers generate a jump PC relative instruction that generates
no relocation or fixup... Invisible damm it!


The only solution would be to disassemble all the .text section of the
module and see if there is a PC relative jump to that procedure but
this would lengthen considerably the link-time obviously...


Does anyone know of a solution (or a reference to a solution?) My
goal is to make an optimizing linker that would automatically delete
all unused code. Thanks in advance.


--
Jacob Navia Logiciels/Informatique
41 rue Maurice Ravel Tel (1) 48.23.51.44
93430 Villetaneuse Fax (1) 48.23.95.39
France


--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.