This enables private aliases on ELF/Mach-O/WebAssembly platforms even if
-fsanitize-address-use-odr-indicator is not specified.
Note that GCC also uses private aliases.
Pros: the following issues are fixed
- Bogus The following global variable is not properly aligned. error for interposed global variables.
(PR37545 (this patch should allow us to restore D46665) and https://github.com/google/sanitizers/issues/1017)
Global variables of non-hasExactDefinition() linkages (i.e.
linkonce/linkonce_odr/weak/weak_odr/common/external_weak) are not instrumented.
If an instrumented variable gets interposed to an uninstrumented variable due to symbol
interposition (e.g. in PR37545, _ZTS1A in foo.so is resolved to _ZTS1A in the
executable), there may be a bogus error.
With private aliases, the register code will not resolve to a definition in another module,
and thus prevent the issue.
Similar to the above, but about an instrumented global variable gets interposed
to an uninstrumented global variable (not using address sanitizer) in another
module.
Cons:
- vtable ODR issues due to interposition are no longer detectable, e.g. compiler-rt/test/asan/TestCases/Linux/odr_vtable.cpp
- ODR issues due to mixed instrumented and non-instrumented globals (interposition) are no longer detectable, e.g. compiler-rt/test/asan/TestCases/Linux/odr_c_test.c
- Can't catch overflows in globals relocated by R_*_COPY
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68016)
This affects -fno-pic and -fpie -mpie-copy-relocations.
However, -fpie (without -mpie-copy-relocations) produced code can still
catch the overflow.
// foo.so int f[5] = {1}; // a.out extern int f[5]; int main() { return f[5]; }
- For ELF, minor object file size increases due to extra STT_SECTION
symbols in the symbol table (private aliases replace some relocations
referencing global symbols with .L symbols which are typically lower to
STT_SECTION symbols). The linked image usually has no size difference.
now we don't test default behavior
can you add CHECKs for alias=1 as well?
same below