diff mbox

Fix bootstrap with gcc 4.3

Message ID alpine.LSU.2.11.1407141518120.19154@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener July 14, 2014, 1:18 p.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2014-07-14  Richard Biener  <rguenther@suse.de>

	* libgcov.h (struct gcov_fn_info): Make ctrs size 1.

Comments

Gerald Pfeifer July 19, 2014, 5:27 p.m. UTC | #1
On Mon, 14 Jul 2014, Richard Biener wrote:
> 2014-07-14  Richard Biener  <rguenther@suse.de>
> 
> 	* libgcov.h (struct gcov_fn_info): Make ctrs size 1.

I actually had the same patch ready and tested already, but realized
this would increase memory consumption (though just a bit) and over-
allocate gcov_fn_info dynamically:

> Index: libgcc/libgcov.h

This now defines struct gcov_fn_info as
  {
    const struct gcov_info *key;          /* comdat key */
    gcov_unsigned_t ident;                /* unique ident of function */
    gcov_unsigned_t lineno_checksum;      /* function lineo_checksum */
    gcov_unsigned_t cfg_checksum;         /* function cfg checksum */
    struct gcov_ctr_info ctrs[1];         /* instrumented counters */
  };

whereas libgcov-util.c has

  curr_fn_info = (struct gcov_fn_info *) xcalloc (sizeof (struct gcov_fn_info)
                   + GCOV_COUNTERS * sizeof (struct gcov_ctr_info), 1);

Gerald
Richard Biener July 22, 2014, 12:58 p.m. UTC | #2
On Sat, 19 Jul 2014, Gerald Pfeifer wrote:

> On Mon, 14 Jul 2014, Richard Biener wrote:
> > 2014-07-14  Richard Biener  <rguenther@suse.de>
> > 
> > 	* libgcov.h (struct gcov_fn_info): Make ctrs size 1.
> 
> I actually had the same patch ready and tested already, but realized
> this would increase memory consumption (though just a bit) and over-
> allocate gcov_fn_info dynamically:
> 
> > Index: libgcc/libgcov.h
> 
> This now defines struct gcov_fn_info as
>   {
>     const struct gcov_info *key;          /* comdat key */
>     gcov_unsigned_t ident;                /* unique ident of function */
>     gcov_unsigned_t lineno_checksum;      /* function lineo_checksum */
>     gcov_unsigned_t cfg_checksum;         /* function cfg checksum */
>     struct gcov_ctr_info ctrs[1];         /* instrumented counters */
>   };
> 
> whereas libgcov-util.c has
> 
>   curr_fn_info = (struct gcov_fn_info *) xcalloc (sizeof (struct gcov_fn_info)
>                    + GCOV_COUNTERS * sizeof (struct gcov_ctr_info), 1);

Yes.  Though in some other thread David agreed to the patch and 
explicitely didn't care about this possible issue.

Richard.
diff mbox

Patch

Index: libgcc/libgcov.h
===================================================================
--- libgcc/libgcov.h	(revision 212515)
+++ libgcc/libgcov.h	(working copy)
@@ -181,7 +181,7 @@  struct gcov_fn_info
   gcov_unsigned_t ident;		/* unique ident of function */
   gcov_unsigned_t lineno_checksum;	/* function lineo_checksum */
   gcov_unsigned_t cfg_checksum;		/* function cfg checksum */
-  struct gcov_ctr_info ctrs[0];		/* instrumented counters */
+  struct gcov_ctr_info ctrs[1];		/* instrumented counters */
 };
 
 /* Type of function used to merge counters.  */