sanitizer/111736 - skip ASAN for globals in alternate address-space

Message ID 20231205135923.72256385C6FD@sourceware.org
State Accepted
Headers
Series sanitizer/111736 - skip ASAN for globals in alternate address-space |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Richard Biener Dec. 5, 2023, 1:55 p.m. UTC
  Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

	PR sanitizer/111736
	* asan.cc (asan_protect_global): Do not protect globals
	in non-generic address-space.
---
 gcc/asan.cc | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/gcc/asan.cc b/gcc/asan.cc
index 2424cf69ef1..8d0ffb497cc 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -2291,6 +2291,8 @@  asan_protect_global (tree decl, bool ignore_decl_rtl_set_p)
       || (DECL_SECTION_NAME (decl) != NULL
 	  && !symtab_node::get (decl)->implicit_section
 	  && !section_sanitized_p (DECL_SECTION_NAME (decl)))
+      /* Don't protect variables in non-generic address-space.  */
+      || !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (decl)))
       || DECL_SIZE (decl) == 0
       || ASAN_RED_ZONE_SIZE * BITS_PER_UNIT > MAX_OFILE_ALIGNMENT
       || TREE_CODE (DECL_SIZE_UNIT (decl)) != INTEGER_CST