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: Michael Snyder <msnyder at redhat dot com>
- To: Kevin Buettner <kevinb at redhat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Thu, 18 Apr 2002 10:02:23 -0700
- Subject: Re: [PATCH] cvexpr.c: Don't let linker delete unused globals
- Organization: Red Hat, Inc.
- References: <1020418132243.ZM6877@localhost.localdomain>
Kevin Buettner 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. Isn't there some option that you can
give to the linker to tell it not to remove these?
>
> * gdb.base/cvexpr.c (use): New function.
> (main): Invoke use() on all global variables to prevent
> some linkers from deleting these otherwise unused symbols.
>
> Index: cvexpr.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/cvexpr.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 cvexpr.c
> --- cvexpr.c 15 Nov 2001 02:16:59 -0000 1.1
> +++ cvexpr.c 18 Apr 2002 12:59:53 -0000
> @@ -273,8 +273,162 @@ unsigned long long (*v_unsigned_long_lon
> float (*v_float_func) (int, int*);
> double (*v_double_func) (int, int*);
>
> -
> +void use (void *p)
> +{
> +}
>
> int main ()
> {
> + use (&v_char);
> + use (&v_signed_char);
> + use (&v_unsigned_char);
> +
> + use (&v_short);
> + use (&v_signed_short);
> + use (&v_unsigned_short);
> +
> + use (&v_int);
> + use (&v_signed_int);
> + use (&v_unsigned_int);
> +
> + use (&v_long);
> + use (&v_signed_long);
> + use (&v_unsigned_long);
> +
> + use (&v_long_long);
> + use (&v_signed_long_long);
> + use (&v_unsigned_long_long);
> +
> + use (&v_float);
> + use (&v_double);
> +
> + use (v_char_array);
> + use (v_signed_char_array);
> + use (v_unsigned_char_array);
> +
> + use (v_short_array);
> + use (v_signed_short_array);
> + use (v_unsigned_short_array);
> +
> + use (v_int_array);
> + use (v_signed_int_array);
> + use (v_unsigned_int_array);
> +
> + use (v_long_array);
> + use (v_signed_long_array);
> + use (v_unsigned_long_array);
> +
> + use (v_float_array);
> + use (v_double_array);
> +
> + use (v_char_pointer);
> + use (v_signed_char_pointer);
> + use (v_unsigned_char_pointer);
> +
> + use (v_short_pointer);
> + use (v_signed_short_pointer);
> + use (v_unsigned_short_pointer);
> +
> + use (v_int_pointer);
> + use (v_signed_int_pointer);
> + use (v_unsigned_int_pointer);
> +
> + use (v_long_pointer);
> + use (v_signed_long_pointer);
> + use (v_unsigned_long_pointer);
> +
> + use (v_float_pointer);
> + use (v_double_pointer);
> +
> + use (v_char_pointer_pointer);
> + use (v_signed_char_pointer_pointer);
> + use (v_unsigned_char_pointer_pointer);
> +
> + use (v_short_pointer_pointer);
> + use (v_signed_short_pointer_pointer);
> + use (v_unsigned_short_pointer_pointer);
> +
> + use (v_int_pointer_pointer);
> + use (v_signed_int_pointer_pointer);
> + use (v_unsigned_int_pointer_pointer);
> +
> + use (v_long_pointer_pointer);
> + use (v_signed_long_pointer_pointer);
> + use (v_unsigned_long_pointer_pointer);
> +
> + use (v_float_pointer_pointer);
> + use (v_double_pointer_pointer);
> +
> + use (v_char_array_pointer);
> + use (v_signed_char_array_pointer);
> + use (v_unsigned_char_array_pointer);
> +
> + use (v_short_array_pointer);
> + use (v_signed_short_array_pointer);
> + use (v_unsigned_short_array_pointer);
> +
> + use (v_int_array_pointer);
> + use (v_signed_int_array_pointer);
> + use (v_unsigned_int_array_pointer);
> +
> + use (v_long_array_pointer);
> + use (v_signed_long_array_pointer);
> + use (v_unsigned_long_array_pointer);
> +
> + use (v_float_array_pointer);
> + use (v_double_array_pointer);
> +
> + use (v_char_pointer_array);
> + use (v_signed_char_pointer_array);
> + use (v_unsigned_char_pointer_array);
> +
> + use (v_short_pointer_array);
> + use (v_signed_short_pointer_array);
> + use (v_unsigned_short_pointer_array);
> +
> + use (v_int_pointer_array);
> + use (v_signed_int_pointer_array);
> + use (v_unsigned_int_pointer_array);
> +
> + use (v_long_pointer_array);
> + use (v_signed_long_pointer_array);
> + use (v_unsigned_long_pointer_array);
> +
> + use (v_float_pointer_array);
> + use (v_double_pointer_array);
> +
> + use (&v_struct1);
> + use (&v_struct2);
> + use (&v_struct3);
> +
> + use (&v_union);
> + use (&v_union2);
> + use (&v_union3);
> +
> + use (&v_boolean);
> + use (&v_boolean2);
> + use (&v_misordered);
> +
> + use (v_char_func);
> + use (v_signed_char_func);
> + use (v_unsigned_char_func);
> +
> + use (v_short_func);
> + use (v_signed_short_func);
> + use (v_unsigned_short_func);
> +
> + use (v_int_func);
> + use (v_signed_int_func);
> + use (v_unsigned_int_func);
> +
> + use (v_long_func);
> + use (v_signed_long_func);
> + use (v_unsigned_long_func);
> +
> + use (v_long_long_func);
> + use (v_signed_long_long_func);
> + use (v_unsigned_long_long_func);
> +
> + use (v_float_func);
> + use (v_double_func);
> }