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] Forbid section anchors for ASan build (PR sanitizer/81697)


On Mon, Aug 7, 2017 at 11:15 PM, Slava Barinov <v.barinov@samsung.com> wrote:
>        gcc/
>        * varasm.c (use_object_blocks_p): Forbid section anchors for ASan
>
>        gcc/testsuite/
>        * g++.dg/asan/global-alignment.cc: New test to test global
>        variables alignment.


Can you describe this a little bit more?  What is going wrong here?
Is it because there is no red zone between the variables?
Also I noticed you are using .cc as the testcase file name, why don't
you use .C instead and then you won't need the other patch which you
just posted.

Thanks,
Andrew Pinski

>
> Signed-off-by: Slava Barinov <v.barinov@samsung.com>
> ---
>  gcc/ChangeLog                                 |  6 ++++++
>  gcc/testsuite/ChangeLog                       |  3 +++
>  gcc/testsuite/g++.dg/asan/global-alignment.cc | 17 +++++++++++++++++
>  gcc/varasm.c                                  |  3 ++-
>  4 files changed, 28 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/asan/global-alignment.cc
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index dde91ceea5b..d840825e7c8 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,9 @@
> +2017-08-08  Vyacheslav Barinov  <v.barinov@samsung.com>
> +
> +       PR sanitizer/81697
> +       * varasm.c (use_object_blocks_p): Forbid section anchors for ASan
> +       build.
> +
>  2017-08-08  Martin Liska  <mliska@suse.cz>
>
>         * asan.c: Include header files.
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 315af8361df..0a0a5850c74 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,5 +1,8 @@
>  2017-08-08  Vyacheslav Barinov  <v.barinov@samsung.com>
>
> +       PR sanitizer/81697
> +       * g++.dg/asan/global-alignment.cc: New test to test global
> +       variables alignment.
>         * g++.dg/asan/asan.exp: Switch on *.cc tests.
>
>  2017-08-07  Michael Meissner  <meissner@linux.vnet.ibm.com>
> diff --git a/gcc/testsuite/g++.dg/asan/global-alignment.cc b/gcc/testsuite/g++.dg/asan/global-alignment.cc
> new file mode 100644
> index 00000000000..c011c703ea6
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/asan/global-alignment.cc
> @@ -0,0 +1,17 @@
> +/* { dg-options "-fmerge-all-constants" } */
> +/* { dg-do compile } */
> +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
> +
> +#include <string>
> +#include <map>
> +
> +const char kRecoveryInstallString[] = "NEW";
> +const char kRecoveryUpdateString[] = "UPDATE";
> +const char kRecoveryUninstallationString[] = "UNINSTALL";
> +
> +const std::map<std::string, int> kStringToRequestMap = {
> +  {kRecoveryInstallString, 0},
> +  {kRecoveryUpdateString, 0},
> +  {kRecoveryUninstallationString, 0},
> +};
> +/* { dg-final { scan-assembler-times {\.section\s+\.rodata\n(?:(?!\.section).)*\.(string|ascii|asciz)\s+"NEW} 1 } } */
> diff --git a/gcc/varasm.c b/gcc/varasm.c
> index e0834a1ff3b..dbeb8d9331e 100644
> --- a/gcc/varasm.c
> +++ b/gcc/varasm.c
> @@ -346,7 +346,8 @@ get_section (const char *name, unsigned int flags, tree decl)
>  static bool
>  use_object_blocks_p (void)
>  {
> -  return flag_section_anchors;
> +  return (flag_section_anchors
> +         && !(flag_sanitize & SANITIZE_ADDRESS));
>  }
>
>  /* Return the object_block structure for section SECT.  Create a new
> --
> 2.13.3
>


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