diff --git a/compiler-rt/lib/asan/asan_globals.cpp b/compiler-rt/lib/asan/asan_globals.cpp --- a/compiler-rt/lib/asan/asan_globals.cpp +++ b/compiler-rt/lib/asan/asan_globals.cpp @@ -92,6 +92,10 @@ if (info.line != 0) { Report(" location: name=%s, %d\n", info.file, static_cast(info.line)); } + else if (g.gcc_location != 0) { + // Fallback to Global::gcc_location + Report(" location: name=%s, %d\n", g.gcc_location->filename, g.gcc_location->line_no); + } } static u32 FindRegistrationSite(const Global *g) { @@ -302,6 +306,11 @@ if (info.line != 0) { str->append("%s:%d", info.file, static_cast(info.line)); + } else if (g.gcc_location != 0) { + // Fallback to Global::gcc_location + str->append("%s", g.gcc_location->filename ? g.gcc_location->filename : g.module_name); + if (g.gcc_location->line_no) str->append(":%d", g.gcc_location->line_no); + if (g.gcc_location->column_no) str->append(":%d", g.gcc_location->column_no); } else { str->append("%s", g.module_name); } diff --git a/compiler-rt/lib/asan/asan_interface_internal.h b/compiler-rt/lib/asan/asan_interface_internal.h --- a/compiler-rt/lib/asan/asan_interface_internal.h +++ b/compiler-rt/lib/asan/asan_interface_internal.h @@ -53,9 +53,10 @@ const char *module_name; // Module name as a C string. This pointer is a // unique identifier of a module. uptr has_dynamic_init; // Non-zero if the global has dynamic initializer. - uptr windows_padding; // TODO: Figure out how to remove this padding - // that's simply here to make the MSVC incremental - // linker happy... + __asan_global_source_location *gcc_location; // Source location of a global, + // used by GCC compiler. LLVM uses + // llvm-symbolizer that relies + // on DWARF debugging info. uptr odr_indicator; // The address of the ODR indicator symbol. };