aboutsummaryrefslogtreecommitdiff
path: root/gcc/asan.cc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2023-02-17 15:11:02 +0100
committerMartin Liska <mliska@suse.cz>2023-02-24 16:23:15 +0100
commit94c9b1bb79f63d000ebb05efc155c149325e332d (patch)
treecf5f9112f107f340e88b528490e6e05ca320addf /gcc/asan.cc
parent3d1d3ece9bc5a1baa2feb4bf231b709c097b8434 (diff)
downloadgcc-94c9b1bb79f63d000ebb05efc155c149325e332d.zip
gcc-94c9b1bb79f63d000ebb05efc155c149325e332d.tar.gz
gcc-94c9b1bb79f63d000ebb05efc155c149325e332d.tar.bz2
asan: adjust module name for global variables
As mentioned in the PR, when we use LTO, we wrongly use ltrans output file name as a module name of a global variable. That leads to a non-reproducible output. After the suggested change, we emit context name of normal global variables. And for artificial variables (like .Lubsan_data3), we use aux_base_name (e.g. "./a.ltrans0.ltrans"). PR sanitizer/108834 gcc/ChangeLog: * asan.cc (asan_add_global): Use proper TU name for normal global variables (and aux_base_name for the artificial one). gcc/testsuite/ChangeLog: * c-c++-common/asan/global-overflow-1.c: Test line and column info for a global variable.
Diffstat (limited to 'gcc/asan.cc')
-rw-r--r--gcc/asan.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/asan.cc b/gcc/asan.cc
index f56d084..2424cf6 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -3287,7 +3287,17 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
pp_string (&asan_pp, "<unknown>");
str_cst = asan_pp_string (&asan_pp);
- pp_string (&module_name_pp, main_input_filename);
+ if (!in_lto_p)
+ pp_string (&module_name_pp, main_input_filename);
+ else
+ {
+ const_tree tu = get_ultimate_context ((const_tree)decl);
+ if (tu != NULL_TREE)
+ pp_string (&module_name_pp, IDENTIFIER_POINTER (DECL_NAME (tu)));
+ else
+ pp_string (&module_name_pp, aux_base_name);
+ }
+
module_name_cst = asan_pp_string (&module_name_pp);
if (asan_needs_local_alias (decl))