Message-ID: From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: Linker trimming unused code/data Date: Mon, 4 Oct 1999 18:12:10 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Reply-To: djgpp AT delorie DOT com Eli Zaretskii writes: >>> What you need to do is to divide a single module into several smaller >>> modules. Then the linker will only link in those modules which you >>> actually need in your program. >> >> Of course - but in fact (after some inquiry etc.) the `ld' linker is almost >> the only that can't do it itself! > > If you think GNU ld should support this feature, I suggest posting to > gnu.utils.bug I'm fairly sure that this cannot be done using only the information output by gcc. To leave out unused functions, you'd need to know the origin and size for every symbol, and also be sure that there were no relative offsets from one symbol to another, wheras standard object formats only give you a block of code with the origin of each symbol, but no size information. It might be possible to deduce the other data for gcc output (I don't know enough about the compiler to judge that), but certainly isn't possible for manually written asm sources, so this wouldn't be a safe optimisation to apply. I don't think it is at all unusual that GNU ld works this way: most other compilers that I have used do exactly the same thing. Shawn Hargreaves.