Re: link-optimization in C (Ben Combee)
22 May 1999 02:57:15 -0400

          From comp.compilers

Related articles
link-optimization in C (S. Bochkarev) (1999-05-21)
Re: link-optimization in C (Christopher Brian Colohan) (1999-05-22)
Re: link-optimization in C (1999-05-22)
Re: link-optimization in C (Jan Gray) (1999-05-22)
Re: link-optimization in C (Bill A.) (1999-05-27)
Re: link-optimization in C (Jeffrey A Law) (1999-05-27)
Re: link-optimization in C (Bill Fahle) (1999-06-27)
| List of all articles for this month |

From: (Ben Combee)
Newsgroups: comp.compilers
Date: 22 May 1999 02:57:15 -0400
Organization: Metrowerks
References: 99-05-091
Keywords: linker

> [I've seen linkers that garbage collect unused procedures, but not on
> Windows systems. I suppose a compiler could put the code for each routine
> into a separate COFF section, then the linker could try to figure out what
> references what, but it'd be a mess. There is a provision for deleting
> duplicate expanded templates and the like, but that depends on all of the
> duplicates having an identical mangled name and deleting all but one
> of the identically named sections. -John]

Actually, CodeWarrior for Win32 (by default) and MS Visual C++ (when
used with the /Gy switch) both perform this procedure you mention --
we put each procedure in its own section, and the respective linkers
dead-strip out unused functions in the final executable.

In the CodeWarrior linker, we use a sweep-mark algorithm from all the
entry point and all the exported symbols to mark used section
contributions. We then allocate the sections to the final link,
ignoring those contributions that were missed by the sweep pass.
Without something like this, using template instantiations would incur
a huge final program size cost.

Ben Combee <> -- x86/Win32/NetWare CompilerWarrior

Post a followup to this message

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