This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optionally sanitize globals in user-defined sections
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Yury Gribov <y dot gribov at samsung dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Andi Kleen <andi at firstfloor dot org>, Andrey Ryabinin <a dot ryabinin at samsung dot com>, Dmitry Vyukov <dvyukov at google dot com>
- Date: Wed, 22 Apr 2015 11:00:24 +0200
- Subject: Re: [PATCH] Optionally sanitize globals in user-defined sections
- Authentication-results: sourceware.org; auth=none
- References: <5530B739 dot 5000306 at samsung dot com> <5530B84E dot 7030709 at samsung dot com> <87vbgu1x4d dot fsf at tassilo dot jf dot intel dot com> <55335F51 dot 3080900 at samsung dot com> <20150419151142 dot GZ1725 at tucnak dot redhat dot com> <55375C7C dot 40804 at samsung dot com> <55375F49 dot 6010701 at samsung dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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