llvm-project/compiler-rt/test/hwasan
Leonard Chan 21f72c05c4 [hwasan] Add __hwasan_add_frame_record to the hwasan interface
Hwasan includes instructions in the prologue that mix the PC and SP and store
it into the stack ring buffer stored at __hwasan_tls. This is a thread_local
global exposed from the hwasan runtime. However, if TLS-mechanisms or the
hwasan runtime haven't been setup yet, it will be invalid to access __hwasan_tls.
This is the case for Fuchsia where we instrument libc, so some functions that
are instrumented but can run before hwasan initialization will incorrectly
access this global. Additionally, libc cannot have any TLS variables, so we
cannot weakly define __hwasan_tls until the runtime is loaded.

A way we can work around this is by moving the instructions into a hwasan
function that does the store into the ring buffer and creating a weak definition
of that function locally in libc. This way __hwasan_tls will not actually be
referenced. This is not our long-term solution, but this will allow us to roll
out hwasan in the meantime.

This patch includes:

- A new llvm flag for choosing to emit a libcall rather than instructions in the
  prologue (off by default)
- The libcall for storing into the ringbuffer (__hwasan_add_frame_record)

Differential Revision: https://reviews.llvm.org/D128387
2022-07-13 15:15:15 -07:00
..
TestCases [hwasan] Add __hwasan_add_frame_record to the hwasan interface 2022-07-13 15:15:15 -07:00
CMakeLists.txt [compiler-rt] Fix lld dependency for sanitizers 2021-07-22 18:02:19 -07:00
lit.cfg.py [HWASan] Remove -Wa,-mrelax-relocations=no flag. 2021-11-22 11:21:27 -08:00
lit.site.cfg.py.in [HWASan] Add aliasing flag and enable HWASan to use it. 2021-05-14 09:47:20 -07:00