This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

PATCH: Re: A patch for dl-profile


On Thu, May 17, 2001 at 12:26:04AM -0700, Ulrich Drepper wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
> 
> > The reason is the profile data file is BAD for some reason. But ld.so
> > shouldn't segfault like that.
> 
> That's the reason for ld.so getting into trouble.  What is the actual
> code in ld.so which is having problems and why you want to bail out
> that early?  The intention definitely is to continue running the
> application but without profiling.
> 

Here is a new patch. Basically, we shouldn't touch textsize unless
we know it is ok to do so.


H.J.
----
2001-05-17  H.J. Lu  <hjl@gnu.org>

	* elf/dl-profile.c (_dl_start_profile): Set textsize only if
	everything is ok.

--- elf/dl-profile.c.check	Tue Feb 27 22:22:10 2001
+++ elf/dl-profile.c	Thu May 17 11:54:38 2001
@@ -190,6 +190,7 @@ _dl_start_profile (struct link_map *map,
   off_t expected_size;
   /* See profil(2) where this is described.  */
   int s_scale;
+  size_t new_textsize;
 #define SCALE_1_TO_1	0x10000L
 
   /* Compute the size of the sections which contain program code.  */
@@ -213,8 +214,8 @@ _dl_start_profile (struct link_map *map,
 		     HISTFRACTION * sizeof (HISTCOUNTER));
   highpc = ROUNDUP (mapend + map->l_addr,
 		    HISTFRACTION * sizeof (HISTCOUNTER));
-  textsize = highpc - lowpc;
-  kcountsize = textsize / HISTFRACTION;
+  new_textsize = highpc - lowpc;
+  kcountsize = new_textsize / HISTFRACTION;
   hashfraction = HASHFRACTION;
   if ((HASHFRACTION & (HASHFRACTION - 1)) == 0)
     /* If HASHFRACTION is a power of two, mcount can use shifting
@@ -222,8 +223,8 @@ _dl_start_profile (struct link_map *map,
     log_hashfraction = __ffs (hashfraction * sizeof (*froms)) - 1;
   else
     log_hashfraction = -1;
-  tossize = textsize / HASHFRACTION;
-  fromlimit = textsize * ARCDENSITY / 100;
+  tossize = new_textsize / HASHFRACTION;
+  fromlimit = new_textsize * ARCDENSITY / 100;
   if (fromlimit < MINARCS)
     fromlimit = MINARCS;
   if (fromlimit > MAXARCS)
@@ -424,6 +425,7 @@ _dl_start_profile (struct link_map *map,
   __profil ((void *) kcount, kcountsize, lowpc, s_scale);
 
   /* Turn on profiling.  */
+  textsize = new_textsize;
   state = GMON_PROF_ON;
 }
 


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