1*7c3d14c8STreehugger Robotimport lit.formats 2*7c3d14c8STreehugger Robotimport os 3*7c3d14c8STreehugger Robot 4*7c3d14c8STreehugger Robotconfig.name = 'cfi' 5*7c3d14c8STreehugger Robotconfig.suffixes = ['.c', '.cpp', '.test'] 6*7c3d14c8STreehugger Robotconfig.test_source_root = os.path.dirname(__file__) 7*7c3d14c8STreehugger Robot 8*7c3d14c8STreehugger Robotclangxx = ' '.join([config.clang] + config.cxx_mode_flags) 9*7c3d14c8STreehugger Robot 10*7c3d14c8STreehugger Robotconfig.substitutions.append((r"%clang ", ' '.join([config.clang]) + ' ')) 11*7c3d14c8STreehugger Robotconfig.substitutions.append((r"%clangxx ", clangxx + ' ')) 12*7c3d14c8STreehugger Robotif config.lto_supported: 13*7c3d14c8STreehugger Robot clang_cfi = ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-flto -fsanitize=cfi ']) 14*7c3d14c8STreehugger Robot 15*7c3d14c8STreehugger Robot if config.cfi_lit_test_mode == "Devirt": 16*7c3d14c8STreehugger Robot config.available_features.add('devirt') 17*7c3d14c8STreehugger Robot clang_cfi += '-fwhole-program-vtables ' 18*7c3d14c8STreehugger Robot config.substitutions.append((r"%expect_crash_unless_devirt ", "")) 19*7c3d14c8STreehugger Robot else: 20*7c3d14c8STreehugger Robot config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash)) 21*7c3d14c8STreehugger Robot 22*7c3d14c8STreehugger Robot cxx = ' '.join(config.cxx_mode_flags) + ' ' 23*7c3d14c8STreehugger Robot diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi ' 24*7c3d14c8STreehugger Robot non_dso = '-fvisibility=hidden ' 25*7c3d14c8STreehugger Robot dso = '-fsanitize-cfi-cross-dso -fvisibility=default ' 26*7c3d14c8STreehugger Robot config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso)) 27*7c3d14c8STreehugger Robot config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso)) 28*7c3d14c8STreehugger Robot config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag)) 29*7c3d14c8STreehugger Robot config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag)) 30*7c3d14c8STreehugger Robot config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso)) 31*7c3d14c8STreehugger Robot config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag)) 32*7c3d14c8STreehugger Robotelse: 33*7c3d14c8STreehugger Robot config.unsupported = True 34*7c3d14c8STreehugger Robot 35*7c3d14c8STreehugger Robotif lit_config.params.get('check_supported', None) and config.unsupported: 36*7c3d14c8STreehugger Robot raise BaseException("Tests unsupported") 37