This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] cvexpr.c: Don't let linker delete unused globals
- From: Kevin Buettner <kevinb at redhat dot com>
- To: Michael Snyder <msnyder at redhat dot com>, Kevin Buettner <kevinb at redhat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Thu, 18 Apr 2002 11:49:19 -0700
- Subject: Re: [PATCH] cvexpr.c: Don't let linker delete unused globals
- References: <1020418132243.ZM6877@localhost.localdomain> <3CBEFC1F.3F0B6D1D@redhat.com>
On Apr 18, 10:02am, Michael Snyder wrote:
> > On AIX, I was seeing lots of failures in gdb.base/code-expr.exp and
> > gdb.base/cvexpr.exp due to the fact that the linker deletes unused
> > symbols. The patch below fixes these failures.
> >
> > Committed as obvious.
>
> Wow, that's really sad, to have to add all that code
> for such a trivial reason. I'm sure there are other
> tests in gdb.base that also make use of symbols that
> don't get called.
Yeah. I ran across some of these in the past and added some similar
looking code. E.g, here's a ChangeLog entry for one of them:
2000-03-21 Kevin Buettner <kevinb@redhat.com>
* gdb.base/pointers.c (usevar): New function.
(main): Make sure that global variables v_int_pointer2, rptr,
and y are all referenced someplace in the program by calling
usevar() on them. [Some linkers delete symbols which are
never referenced. The space remains, but there's no way to
get a (symbolic) handle on the variable from the debugger.]
> Isn't there some option that you can
> give to the linker to tell it not to remove these?
Apparently there is, but in my opinion, it's easier to maintain
changes to C code than bits of configury involving the linker
which can change over time. Also, the testsuite will just work
without the need to specify any additional linker options for
other (future) linkers which choose to also garbage collect unused
symbols.
Kevin