[PATCH REVIEW 10/10] bfd, ld, libctf: skip zero-refcount strings in CTF string reporting

Nick Clifton nickc@redhat.com
Mon Mar 1 15:17:10 GMT 2021


Hi Nick,

> bfd/ChangeLog
> 2021-02-26  Nick Alcock  <nick.alcock@oracle.com>
> 
> 	* elf-strtab.c (_bfd_elf_strtab_str): Skip strings with zero refcount.
> 
> ld/ChangeLog
> 2021-02-26  Nick Alcock  <nick.alcock@oracle.com>
> 
> 	* ldelfgen.c (ldelf_ctf_strtab_iter_cb): Skip zero-refcount strings.

This patch is approved, although I have a few minor formatting nits that you
might like to correct:


> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
> index 2fef817d734..f1b4e8a2a46 100644
> --- a/bfd/ChangeLog
> +++ b/bfd/ChangeLog
> @@ -1,3 +1,7 @@
> +2021-02-26  Nick Alcock  <nick.alcock@oracle.com>
> +
> +	* elf-strtab.c (_bfd_elf_strtab_str): Skip strings with zero refcount.
> +

Please can changelog entries not be submitted as context diffs.
They almost never apply cleanly...

> @@ -302,6 +302,8 @@ _bfd_elf_strtab_str (struct elf_strtab_hash *tab, size_t idx,
>       return 0;
>     BFD_ASSERT (idx < tab->size);
>     BFD_ASSERT (tab->sec_size);
> +  if (tab->array[idx]->refcount == 0)
> +    return 0;

This should really be "return NULL;".  (I know that there is a 'return 0;' a few
lines above, but that one is wrong too).


> @@ -375,13 +375,19 @@ ldelf_ctf_strtab_iter_cb (uint32_t *offset, void *arg_)
>     if (arg->next_i == 0)
>       arg->next_i = 1;
>   
> -  if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
> +  /* Hunt through strings until we fall off the end or find one with
> +     a nonzero refcount.  */
> +  do
>       {
> -      arg->next_i = 0;
> -      return NULL;
> -    }
> +      if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
> +	{
> +	  arg->next_i = 0;
> +	  return NULL;
> +	}
> +
> +      ret = _bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
> +    } while (ret == 0);

The while statement should be on its own line.  IE:

     }
   while (ret == 0);

Cheers
   Nick



More information about the Binutils mailing list