This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] cvexpr.c: Don't let linker delete unused globals


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]