Reduce alloca 'ted memory in dwarf2out.c

Christophe Jaillet christophe.jaillet@wanadoo.fr
Mon Feb 14 13:47:00 GMT 2005


Description : in gcc/dwarf2out.c, some memory allocated with alloca request
too much. Just ask for what is needed

Note : the first part of the patch assume that %x of comdat_symbol_number is
less than 10 bytes
The second part is always OK.


Bootstrapped on my i686-pc-cygwin.


2005-02-13  Christophe Jaillet <christophe.jaillet@wanadoo.fr>

    * dwarf2out.c (assign_symbol_names): reduce memory requested by alloca
to what is really needed


*** gcc-4.0-20050130/gcc/dwarf2out.c Thu Feb 10 19:27:48 2005
--- my_patch/dwarf2out.c Sun Feb 13 18:39:34 2005
*************** assign_symbol_names (dw_die_ref die)
*** 6098,6104 ****
      {
        if (comdat_symbol_id)
   {
!    char *p = alloca (strlen (comdat_symbol_id) + 64);

     sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX,
       comdat_symbol_id, comdat_symbol_number++);
--- 6098,6104 ----
      {
        if (comdat_symbol_id)
   {
!    char *p = alloca (sizeof (DIE_LABEL_PREFIX) + 1 + strlen
(comdat_symbol_id) + 1 + 10);

     sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX,
       comdat_symbol_id, comdat_symbol_number++);
*************** output_comp_unit (dw_die_ref die, int ou
*** 7046,7052 ****
    oldsym = die->die_symbol;
    if (oldsym)
      {
!       tmp = alloca (strlen (oldsym) + 24);

        sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym);
        secname = tmp;
--- 7046,7052 ----
    oldsym = die->die_symbol;
    if (oldsym)
      {
!       tmp = alloca (17 + strlen (oldsym) + 1);

        sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym);
        secname = tmp;








More information about the Gcc-patches mailing list