* dead code removal
@ 1999-11-25 1:10 Jim Reekes
1999-11-25 6:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jim Reekes @ 1999-11-25 1:10 UTC (permalink / raw)
To: linuxppc-dev
I have a little program that contains a routine DummyFunc() which is
never reference in the code. Building this single source file in any way
I've tried results in a binary which contains DummyFunc(). Using nm and
objdump, as far as I can determine GCC 2.95 does not dead-code strip.
(which I find amazing!). So I have two questions.
Am I missing something and GCC actually does dead-code stripping?
- or -
How can I find unused/unreferenced symbols in my code so that I can bury
the dead code manually?
Jim
P.S. I have always compared programming to ditch digging, and now I'm
convinced.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: dead code removal
1999-11-25 1:10 dead code removal Jim Reekes
@ 1999-11-25 6:53 ` Daniel Jacobowitz
1999-11-25 22:32 ` Jeffrey Karl Lassahn
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 1999-11-25 6:53 UTC (permalink / raw)
To: linuxppc-dev
That kind of stripping can not be done by the compiler. It could
theoretically be done by the linker, and there MIGHT be a linker option
to give the warnings you want - what if another object file in your
program called DummyFunc? Or worse, what if a shared library expected
DummyFunc to be available?
On Wed, Nov 24, 1999 at 05:10:03PM -0800, Jim Reekes wrote:
>
> I have a little program that contains a routine DummyFunc() which is
> never reference in the code. Building this single source file in any way
> I've tried results in a binary which contains DummyFunc(). Using nm and
> objdump, as far as I can determine GCC 2.95 does not dead-code strip.
> (which I find amazing!). So I have two questions.
>
> Am I missing something and GCC actually does dead-code stripping?
>
> - or -
>
> How can I find unused/unreferenced symbols in my code so that I can bury
> the dead code manually?
>
>
> Jim
>
> P.S. I have always compared programming to ditch digging, and now I'm
> convinced.
>
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| SCS Class of 2002 |
| Debian GNU/Linux Developer __ Carnegie Mellon University |
| dan@debian.org | | dmj+@andrew.cmu.edu |
\--------------------------------/ \--------------------------------/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: dead code removal
1999-11-25 6:53 ` Daniel Jacobowitz
@ 1999-11-25 22:32 ` Jeffrey Karl Lassahn
1999-12-18 20:08 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 4+ messages in thread
From: Jeffrey Karl Lassahn @ 1999-11-25 22:32 UTC (permalink / raw)
To: linuxppc-dev
On Thu, 25 Nov 1999, Daniel Jacobowitz wrote:
>
> That kind of stripping can not be done by the compiler. It could
> theoretically be done by the linker, and there MIGHT be a linker option
> to give the warnings you want - what if another object file in your
> program called DummyFunc? Or worse, what if a shared library expected
> DummyFunc to be available?
>
In principle it can be if the function is marked static (so the compiler
knows it will never link outside the module.) Does anyone know if GCC
does remove the code in this case?
>
> On Wed, Nov 24, 1999 at 05:10:03PM -0800, Jim Reekes wrote:
> >
> > I have a little program that contains a routine DummyFunc() which is
> > never reference in the code. Building this single source file in any way
> > I've tried results in a binary which contains DummyFunc(). Using nm and
> > objdump, as far as I can determine GCC 2.95 does not dead-code strip.
> > (which I find amazing!). So I have two questions.
> >
> > Am I missing something and GCC actually does dead-code stripping?
> >
> > - or -
> >
> > How can I find unused/unreferenced symbols in my code so that I can bury
> > the dead code manually?
> >
> >
> > Jim
> >
> > P.S. I have always compared programming to ditch digging, and now I'm
> > convinced.
> >
>
>
> Dan
>
> /--------------------------------\ /--------------------------------\
> | Daniel Jacobowitz |__| SCS Class of 2002 |
> | Debian GNU/Linux Developer __ Carnegie Mellon University |
> | dan@debian.org | | dmj+@andrew.cmu.edu |
> \--------------------------------/ \--------------------------------/
>
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: dead code removal
1999-11-25 22:32 ` Jeffrey Karl Lassahn
@ 1999-12-18 20:08 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Fitzhardinge @ 1999-12-18 20:08 UTC (permalink / raw)
To: Jeffrey Karl Lassahn; +Cc: linuxppc-dev
On 25-Nov-99 Jeffrey Karl Lassahn wrote:
> In principle it can be if the function is marked static (so the compiler
> knows it will never link outside the module.) Does anyone know if GCC
> does remove the code in this case?
No, only if its inline. Just because the compiler can't see a reference, it
doesn't mean one isn't there - inline assember may refer to the static function.
Basically, you need the linker to strip dead functions, because nothing else
has enough information to do it right.
J
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-12-18 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-11-25 1:10 dead code removal Jim Reekes
1999-11-25 6:53 ` Daniel Jacobowitz
1999-11-25 22:32 ` Jeffrey Karl Lassahn
1999-12-18 20:08 ` Jeremy Fitzhardinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).