[all-commits] [llvm/llvm-project] d2ac27: [compiler-rt] Introduce the notion of an intercept...

Marco Elver via All-commits all-commits at lists.llvm.org
Thu May 25 03:01:50 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d2ac2776021def69e9d0e64c9a958e0c361a919a
      https://github.com/llvm/llvm-project/commit/d2ac2776021def69e9d0e64c9a958e0c361a919a
  Author: Marco Elver <elver at google.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M compiler-rt/lib/interception/interception.h
    M compiler-rt/lib/interception/interception_linux.cpp
    M compiler-rt/lib/interception/interception_linux.h

  Log Message:
  -----------
  [compiler-rt] Introduce the notion of an interceptor trampoline

To make the interceptor implementation more flexible, allowing for 2
levels of indirection instead of just 1 in the current scheme (where the
intercepted function aliases the interceptor implementation), introduce
the notion of an interceptor "trampoline".

A trampoline may be a real function (and not just an alias, where
aliases of aliases do not work), which will simply forward to the
interceptor implementation; the intercepted function will then alias the
trampoline:

	func -[alias]-> trampoline -[call]-> interceptor

Make the necessary changes to prepare for introducing real trampolines.

This change does not yet introduce any real trampolines, and so
trampoline == interceptor, and we currently still just have:

	func -[alias]-> interceptor

NFC.

Reviewed By: dvyukov, vitalybuka, MaskRay

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


  Commit: 15711bd631894985c1342953747e77ffc091a4f3
      https://github.com/llvm/llvm-project/commit/15711bd631894985c1342953747e77ffc091a4f3
  Author: Marco Elver <elver at google.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
    M compiler-rt/lib/hwasan/hwasan_setjmp_riscv64.S
    M compiler-rt/lib/hwasan/hwasan_setjmp_x86_64.S
    M compiler-rt/lib/sanitizer_common/sanitizer_asm.h
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_loongarch64.inc.S
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_riscv64.inc.S
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S

  Log Message:
  -----------
  [compiler-rt] Introduce asm macros for interceptor trampolines

This introduces macros for asm sources to define trampolines, and
aliases to trampolines.

Because we currently do not yet have any real trampolines, this change
is a NFC.

Reviewed By: dvyukov, vitalybuka

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


  Commit: 19b137f0c2be6955f2712d2f79b72aebed5feb42
      https://github.com/llvm/llvm-project/commit/19b137f0c2be6955f2712d2f79b72aebed5feb42
  Author: Marco Elver <elver at google.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M compiler-rt/lib/interception/interception.h

  Log Message:
  -----------
  [compiler-rt] Unify Linux and *BSD interceptors more

The Linux and *BSD interceptors are almost identical, except for *BSD,
where the overridden intercepted function is not defined weak due to
some incompliant linker behaviour.

Since most of the interception machinery is shared between Linux and
*BSD (see INTERCEPT_FUNCTION macro), it makes sense to unify interceptor
definition and declarations as much as possible to ease future changes.

NFC.

Reviewed By: dvyukov, vitalybuka

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


  Commit: 01cea39f8e11012ac96b36ef60bfaf2f3b64320b
      https://github.com/llvm/llvm-project/commit/01cea39f8e11012ac96b36ef60bfaf2f3b64320b
  Author: Marco Elver <elver at google.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
    M compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp
    M compiler-rt/lib/tsan/rtl/tsan_report.cpp

  Log Message:
  -----------
  [sanitizer_common] Support stripping interceptor prefixes in RenderFrame()

Rather than having every tool pass the right interceptor prefix, just
move this logic into RenderFrame().

Note that currently there are a few cases where due to aliasing the
intercepted function -> interceptor, the unwinder sees the intercepted
function - however this is never guaranteed. In a later change this
becomes more apparent, and other non-tsan sanitizer tests would fail as
well. By making the default RenderFrame() strip interceptor prefixes, we
don't rely on the linker aliasing preferences.

Reviewed By: dvyukov, vitalybuka, MaskRay

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


  Commit: 5732cdc1be519eba3fe176cae2c8fea1e0ce7ea7
      https://github.com/llvm/llvm-project/commit/5732cdc1be519eba3fe176cae2c8fea1e0ce7ea7
  Author: Marco Elver <elver at google.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M compiler-rt/lib/msan/msan_report.cpp
    M compiler-rt/lib/msan/msan_report.h
    M compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
    M compiler-rt/test/msan/Linux/b64.cpp
    M compiler-rt/test/msan/Linux/sendmsg.cpp
    M compiler-rt/test/msan/fgets_fputs.cpp
    M compiler-rt/test/msan/fread_fwrite.cpp
    M compiler-rt/test/msan/getaddrinfo-positive.cpp
    M compiler-rt/test/msan/scoped-interceptors.cpp
    M compiler-rt/test/msan/strndup.cpp

  Log Message:
  -----------
  [msan] Strip __interceptor_ from reports

Showing __interceptor_ as part of the function name in reports does not
make sense and is distracting.

Strip the interceptor function name before printing.

Reviewed By: dvyukov, vitalybuka

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


  Commit: 215a742b8804f33c84f866d3c5aacd8d35129c49
      https://github.com/llvm/llvm-project/commit/215a742b8804f33c84f866d3c5aacd8d35129c49
  Author: Marco Elver <elver at google.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp

  Log Message:
  -----------
  [sanitizer_common] Check 'demangle' flag in StripFunctionName and DemangleFunctionName

To allow getting the original stack trace.

Reviewed By: dvyukov

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


Compare: https://github.com/llvm/llvm-project/compare/f3c3f63672a0...215a742b8804


More information about the All-commits mailing list