박우진

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

...@@ -619,7 +619,15 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts, ...@@ -619,7 +619,15 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
619 (getTriple().getEnvironment() == llvm::Triple::EABI || 619 (getTriple().getEnvironment() == llvm::Triple::EABI ||
620 getTriple().getEnvironment() == llvm::Triple::EABIHF)) 620 getTriple().getEnvironment() == llvm::Triple::EABIHF))
621 Builder.defineMacro("__ELF__"); 621 Builder.defineMacro("__ELF__");
622 - 622 +
623 + // pretend like we are ARM's Compiler which is based on LLVM
624 + // this enable CMSIS to build without miodifications
625 + Builder.defineMacro("__ARMCC_VERSION","6010050");
626 +
627 + // Define annoation macros
628 + 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\");");
629 + 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\");");
630 +
623 // Target properties. 631 // Target properties.
624 Builder.defineMacro("__REGISTER_PREFIX__", ""); 632 Builder.defineMacro("__REGISTER_PREFIX__", "");
625 633
......
...@@ -1032,6 +1032,16 @@ SanitizerMask ToolChain::getSupportedSanitizers() const { ...@@ -1032,6 +1032,16 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
1032 getTriple().isAArch64()) 1032 getTriple().isAArch64())
1033 Res |= SanitizerKind::CFIICall; 1033 Res |= SanitizerKind::CFIICall;
1034 1034
1035 + switch(getTriple().getArch()) {
1036 + case llvm::Triple::arm:
1037 + case llvm::Triple::thumb:
1038 + if (getTriple().getOS() == llvm::Triple::UnknownOS &&
1039 + getTriple().getEnvironment() == llvm::Triple::EABI) {
1040 + Res |= SanitizerKind::SafeStack;
1041 + }
1042 + default:
1043 + ;
1044 + }
1035 if (getTriple().getArch() == llvm::Triple::x86_64 || 1045 if (getTriple().getArch() == llvm::Triple::x86_64 ||
1036 getTriple().isAArch64() || getTriple().isRISCV()) 1046 getTriple().isAArch64() || getTriple().isRISCV())
1037 Res |= SanitizerKind::ShadowCallStack; 1047 Res |= SanitizerKind::ShadowCallStack;
......