This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Optionally sanitize globals in user-defined sections


On Wed, Apr 22, 2015 at 11:43:53AM +0300, Yury Gribov wrote:
> @@ -272,7 +273,7 @@ along with GCC; see the file COPYING3.  If not see
>  
>  static unsigned HOST_WIDE_INT asan_shadow_offset_value;
>  static bool asan_shadow_offset_computed;
> -static const char *sanitized_sections;
> +static vec<char *, va_gc> *sanitized_sections;

Why don't you use static vec<char *> sanitized_section instead?

> -set_sanitized_sections (const char *secs)
> +set_sanitized_sections (const char *sections)
>  {
> -  sanitized_sections = secs;
> +  char *pat;
> +  for (unsigned i = 0;
> +       sanitized_sections && sanitized_sections->iterate (i, &pat);
> +       ++i)

This really should be FOR_EACH_VEC_SAFE_ELT (if you keep using va_gc
vec *) or FOR_EACH_VEC_ELT.

> +    {
> +      free (pat);
> +    }

No {}s around single line body.

> @@ -308,16 +325,13 @@ set_sanitized_sections (const char *secs)
>  static bool
>  section_sanitized_p (const char *sec)
>  {
> -  if (!sanitized_sections)
> -    return false;
> -  size_t len = strlen (sec);
> -  const char *p = sanitized_sections;
> -  while ((p = strstr (p, sec)))
> +  char *pat;
> +  for (unsigned i = 0;
> +       sanitized_sections && sanitized_sections->iterate (i, &pat);
> +       ++i)

Similarly.  Also, wonder if won't be too expensive if people use too long
list of sections.  Perhaps we could cache positive as well as negative
answers in a hash table?  Though, perhaps it is worth that only if this
shows up to be a bottleneck.

	Jakub


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