This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 455
  ARM profiling fault Last modified: 2006-10-31 15:02
     Query page      Enter new bug
Bug#: 455   Hardware:   Reporter: Andy Stewart <andy.andystewart@gmail.com>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: drow@false.org <drow@false.org>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 455 depends on: Show dependency tree
Show dependency graph
Bug 455 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2004-10-17 00:39
A segmentation fault occurs when using the -pg profiling options of gcc for ARM targets.  

The problem is due to how a buffer is allocated for profiling samples.  One allocation is made for 
multiple buffers, and the second buffer is not aligned on a 4 byte boundary.  When _mcount is 
subsequently called, an invalid index is read from the unaligned buffer, and _mcount attempts to store 
the profiling data at an invalid address.

Please include the following patches to gmon/gmon.c, elf/dl-profile.c, and elf/sprof.c in the glibc 
component:

--- glibc-2.3.2/gmon/gmon.c	2004-09-25 10:16:24.000000000 -0700
+++ mod_gmon.c	                2004-09-25 10:09:40.000000000 -0700
@@ -113,7 +113,7 @@
   p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER));
   p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
   p->textsize = p->highpc - p->lowpc;
-  p->kcountsize = p->textsize / HISTFRACTION;
+  p->kcountsize = ((p->textsize / HISTFRACTION) + 3) & ~3;
   p->hashfraction = HASHFRACTION;
   p->log_hashfraction = -1;
   /* The following test must be kept in sync with the corresponding


--- glibc-2.3.2/elf/dl-profile.c	2004-09-25 11:35:11.000000000 -0700
+++ mod-dl-profile.c	                2004-09-25 11:39:40.000000000 -0700
@@ -238,7 +238,7 @@
     }
   else
     log_hashfraction = -1;
-  tossize = textsize / HASHFRACTION;
+  tossize = ((textsize / HASHFRACTION) + 3) & ~3;
   fromlimit = textsize * ARCDENSITY / 100;
   if (fromlimit < MINARCS)
     fromlimit = MINARCS;


--- glibc-2.3.2/elf/sprof.c	2004-09-25 11:52:41.000000000 -0700
+++ mod-sprof.c	                2004-09-25 11:39:06.000000000 -0700
@@ -452,7 +452,7 @@
     printf ("hashfraction = %d\ndivider = %Zu\n",
 	    result->hashfraction,
 	    result->hashfraction * sizeof (struct here_fromstruct));
-  result->tossize = textsize / HASHFRACTION;
+  result->tossize = ((textsize / HASHFRACTION) + 3) & ~3;
   result->fromlimit = textsize * ARCDENSITY / 100;
   if (result->fromlimit < MINARCS)
     result->fromlimit = MINARCS;

------- Additional Comment #1 From Daniel Jacobowitz 2005-10-10 14:56 -------
The gmon.c change is no longer necessary in CVS, but I'm not sure about the
changes to the two ELF profilers; they probably still are.

------- Additional Comment #2 From Daniel Jacobowitz 2006-10-31 15:02 -------
I was wrong.  The ELF profiler uses __attribute__((packed)) so this problem does
not occur.  Combined with Randolph's fix for gmon, there's nothing left of this bug.

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In