[all-commits] [llvm/llvm-project] 1ada81: [asan] Default to -fsanitize-address-use-odr-indic...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Nov 2 19:21:45 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1ada819c237bf724e6eaa1c82b2742e3eb57a5d5
      https://github.com/llvm/llvm-project/commit/1ada819c237bf724e6eaa1c82b2742e3eb57a5d5
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-11-02 (Wed, 02 Nov 2022)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/SanitizerArgs.cpp
    M clang/test/CodeGen/asan-globals-odr.cpp
    M clang/test/CodeGen/asan-static-odr.cpp
    M clang/test/Driver/fsanitize.c
    M compiler-rt/test/asan/TestCases/Linux/odr-violation.cpp
    M compiler-rt/test/asan/TestCases/Linux/odr_indicators.cpp
    M llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
    M llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    M llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
    M llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
    M llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
    M llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
    M llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll

  Log Message:
  -----------
  [asan] Default to -fsanitize-address-use-odr-indicator for non-Windows

This enables odr indicators on all platforms and private aliases on non-Windows.
Note that GCC also uses private aliases: this fixes bogus
`The following global variable is not properly aligned.` errors for interposed global variables

Fix https://github.com/google/sanitizers/issues/398
Fix https://github.com/google/sanitizers/issues/1017
Fix https://github.com/llvm/llvm-project/issues/36893 (we can restore D46665)

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 issue 36893, _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.

Cons: minor size increase. This is mainly due to extra `__odr_asan_gen_*` symbols.
(ELF) In addition, in relocatable files private aliases replace some relocations
referencing global symbols with .L symbols and may introduce some STT_SECTION symbols.

For lld, with -g0, the size increase is 0.07~0.09% for many configurations I
have tested: -O0, -O1, -O2, -O3, -O2 -ffunction-sections -fdata-sections
-Wl,--gc-sections. With -g1 or above, the size increase ratio will be even smaller.

This patch obsoletes D92078.

Don't migrate Windows for now: the static data member of a specialization
`std::num_put<char>::id` is a weak symbol, as well as its ODR indicator.
Unfortunately, link.exe (and lld without -lldmingw) generally doesn't support
duplicate weak definitions (weak symbols in different TUs likely pick different
defined external symbols and conflict).

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




More information about the All-commits mailing list