박우진

clang: add ARM CMSIS Macros and arm-none-eabi sanitizer

......@@ -619,7 +619,15 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
(getTriple().getEnvironment() == llvm::Triple::EABI ||
getTriple().getEnvironment() == llvm::Triple::EABIHF))
Builder.defineMacro("__ELF__");
// pretend like we are ARM's Compiler which is based on LLVM
// this enable CMSIS to build without miodifications
Builder.defineMacro("__ARMCC_VERSION","6010050");
// Define annoation macros
Builder.defineMacro("__EDIVERT_ELEVATE","__asm volatile(\"push {r0}\\n\\t\" \"mrs r0, apsr \\n\\t\" \" push {r0}\\n\\t\" \" mrs r0, control \\n\\t\" \" tst r0, 1\\n\\t\" \" it ne \\n\\t\" \" svcne 254 \\n\\t\" \" pop {r0} \\n\\t\" \" msr apsr, r0 \\n\\t\" \" pop {r0} \\n\\t\":::\"r0\",\"r1\",\"r2\",\"r3\",\"r4\",\"r5\",\"r6\",\"r7\",\"r8\",\"r9\",\"r10\",\"r11\",\"r12\",\"r13\",\"r14\",\"lr\",\"memory\");");
Builder.defineMacro("__EDIVERT_DROP","__asm volatile(\"push{r0}\\n\\t\" \" mrs r0, control\\n\\t\" \" orr r0, 1\\n\\t\" \" msr control, r0 \\n\\t\" \" pop {r0} \\n\\t\":::\"r0\",\"r1\",\"r2\",\"r3\",\"r4\",\"r5\",\"r6\",\"r7\",\"r8\",\"r9\",\"r10\",\"r11\",\"r12\",\"r13\",\"r14\",\"lr\",\"memory\");");
// Target properties.
Builder.defineMacro("__REGISTER_PREFIX__", "");
......
......@@ -1032,6 +1032,16 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
getTriple().isAArch64())
Res |= SanitizerKind::CFIICall;
switch(getTriple().getArch()) {
case llvm::Triple::arm:
case llvm::Triple::thumb:
if (getTriple().getOS() == llvm::Triple::UnknownOS &&
getTriple().getEnvironment() == llvm::Triple::EABI) {
Res |= SanitizerKind::SafeStack;
}
default:
;
}
if (getTriple().getArch() == llvm::Triple::x86_64 ||
getTriple().isAArch64() || getTriple().isRISCV())
Res |= SanitizerKind::ShadowCallStack;
......