[asan] Prevent folding of globals with redzones
authorVitaly Buka <vitalybuka@google.com>
Thu, 20 Dec 2018 00:30:18 +0000 (00:30 +0000)
committerVitaly Buka <vitalybuka@google.com>
Thu, 20 Dec 2018 00:30:18 +0000 (00:30 +0000)
commitd414e1bbb547aabdadecd0fccc23bda41adf5d99
treeee4b3bf3792689216b088d42b9fbd1c410159874
parenta938b9dd3e2ae8813605fcaa760809d7a743c26f
[asan] Prevent folding of globals with redzones

Summary:
ICF prevented by removing unnamed_addr and local_unnamed_addr for all sanitized
globals.
Also in general unnamed_addr is not valid here as address now is important for
ODR violation detector and redzone poisoning.

Before the patch ICF on globals caused:
1. false ODR reports when we register global on the same address more than once
2. globals buffer overflow if we fold variables of smaller type inside of large
type. Then the smaller one will poison redzone which overlaps with the larger one.

Reviewers: eugenis, pcc

Subscribers: hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D55857

llvm-svn: 349706
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll