target/5469: ia64 arc profiling can use the wrong global pointer

janis187@us.ibm.com janis187@us.ibm.com
Wed Jan 23 10:36:00 GMT 2002


>Number:         5469
>Category:       target
>Synopsis:       ia64 arc profiling can use the wrong global pointer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 23 10:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Janis Johnson
>Release:        gcc version 3.1 20020122 (experimental)
>Organization:
>Environment:
ia64-unknown-linux-gnu
>Description:
Arc profiling on ia64 inserts profiling code between a call
and the restore of the global pointer, but the profiling
code uses the global pointer to address the arc count.  If
the call was to a function in a shared library then it uses
the wrong global pointer.  If the user is lucky this will
cause the profiled program to abort; otherwise it might
increment data used by the shared library.

This bug causes the failure of gcc.misc-tests/gcov-7.c for
ia64.  That test uses setjump and longjmp, but the test case
provided here uses C library functions rand and srand and is
much simpler.
>How-To-Repeat:
Compile the test case on ia64-linux with -fprofile-arcs
and execute it.  Examine generated assembly code to see
that the restore of the GP after calls to libc functions
is done after the GP is used to reference the profile
counts.
>Fix:
Unknown.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug.c"
Content-Disposition: inline; filename="bug.c"

/* Check that arc profiling restores the global pointer before using it
   to get the address of a count.  The test calls srand and rand, C library
   functions, assuming that they will be in a shared C library.  The bug
   only affected targets that address all global data using the GP and
   require the caller to save and restore the GP value, including IA-64.  */

/* { dg-options "-fprofile-arcs" } */
/* { dg-do run { target native } } */

int rand (void);
void srand (unsigned int seed);

int globvar;

void
leave (int i)
{
  if (i != 0)
    abort ();
  exit (0);
}

void
doit ()
{
  srand (12);
  globvar = rand ();
  if (rand () > 0)
    globvar = 0;
  leave (globvar);
}

int
main ()
{
  doit ();
}



More information about the Gcc-prs mailing list