Skip to content

Commit e3abd19

Browse files
mstorsjotru
authored andcommitted
[compiler-rt] Support building runtimes for Windows on arm32 (#101462)
In these environments, the architecture name is armv7; recognize that and enable the relevant runtimes. Fix building the sanitizer_common library for this target, by using the right registers for the architecture - this is similar to what 0c39113 did for aarch64. (Still, address sanitizer doesn't support hooking functions at runtime on armv7 or aarch64 - but other runtimes such as ubsan do work.) (cherry picked from commit 5ea9dd8)
1 parent 9b6180e commit e3abd19

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ if(APPLE)
2424
set(X86_64 x86_64 x86_64h)
2525
endif()
2626

27+
if(WIN32)
28+
set(ARM32 ${ARM32} armv7)
29+
endif()
30+
2731
set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64}
2832
${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9}
2933
${HEXAGON} ${LOONGARCH64})

compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,17 @@ void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {
7070
stack_frame.AddrStack.Offset = ctx.Rsp;
7171
# endif
7272
# else
73+
# if SANITIZER_ARM
74+
int machine_type = IMAGE_FILE_MACHINE_ARM;
75+
stack_frame.AddrPC.Offset = ctx.Pc;
76+
stack_frame.AddrFrame.Offset = ctx.R11;
77+
stack_frame.AddrStack.Offset = ctx.Sp;
78+
# else
7379
int machine_type = IMAGE_FILE_MACHINE_I386;
7480
stack_frame.AddrPC.Offset = ctx.Eip;
7581
stack_frame.AddrFrame.Offset = ctx.Ebp;
7682
stack_frame.AddrStack.Offset = ctx.Esp;
83+
# endif
7784
# endif
7885
stack_frame.AddrPC.Mode = AddrModeFlat;
7986
stack_frame.AddrFrame.Mode = AddrModeFlat;

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,13 @@ void SignalContext::InitPcSpBp() {
992992
sp = (uptr)context_record->Rsp;
993993
# endif
994994
# else
995+
# if SANITIZER_ARM
996+
bp = (uptr)context_record->R11;
997+
sp = (uptr)context_record->Sp;
998+
# else
995999
bp = (uptr)context_record->Ebp;
9961000
sp = (uptr)context_record->Esp;
1001+
# endif
9971002
# endif
9981003
}
9991004

0 commit comments

Comments
 (0)