@@ -445,6 +445,11 @@ ClangExpressionParser::ClangExpressionParser(
445445 // Supported subsets of x86
446446 if (target_machine == llvm::Triple::x86 ||
447447 target_machine == llvm::Triple::x86_64) {
448+ // FIXME: shouldn't this be placed after
449+ // `auto target_info = TargetInfo::CreateTargetInfo(...)`
450+ // (see `if (target_machine == llvm::Triple::aarch64)`)?
451+ // It computes `Features` from `FeatureMap` and `FeaturesAsWritten` and
452+ // erases initial `Features` vector.
448453 m_compiler->getTargetOpts ().Features .push_back (" +sse" );
449454 m_compiler->getTargetOpts ().Features .push_back (" +sse2" );
450455 }
@@ -467,6 +472,10 @@ ClangExpressionParser::ClangExpressionParser(
467472
468473 auto target_info = TargetInfo::CreateTargetInfo (
469474 m_compiler->getDiagnostics (), m_compiler->getInvocation ().TargetOpts );
475+ if (target_machine == llvm::Triple::aarch64) {
476+ // TODO: enable this depending on corresponding tag section in ELF
477+ target_info->getTargetOpts ().Features .push_back (" +pauth" );
478+ }
470479 if (log) {
471480 LLDB_LOGF (log, " Target datalayout string: '%s'" ,
472481 target_info->getDataLayoutString ());
@@ -612,6 +621,13 @@ ClangExpressionParser::ClangExpressionParser(
612621 // additionally enabling them as expandable builtins is breaking Clang.
613622 lang_opts.NoBuiltin = true ;
614623
624+ // TODO: enable this depending on corresponding tag section in ELF
625+ lang_opts.PointerAuthCalls = true ;
626+ lang_opts.PointerAuthReturns = true ;
627+ lang_opts.PointerAuthVTPtrAddressDiscrimination = true ;
628+ lang_opts.PointerAuthVTPtrTypeDiscrimination = true ;
629+ lang_opts.PointerAuthInitFini = true ;
630+
615631 // Set CodeGen options
616632 m_compiler->getCodeGenOpts ().EmitDeclMetadata = true ;
617633 m_compiler->getCodeGenOpts ().InstrumentFunctions = false ;
@@ -622,6 +638,10 @@ ClangExpressionParser::ClangExpressionParser(
622638 else
623639 m_compiler->getCodeGenOpts ().setDebugInfo (codegenoptions::NoDebugInfo);
624640
641+ CompilerInvocation::setDefaultPointerAuthOptions (
642+ m_compiler->getCodeGenOpts ().PointerAuth , lang_opts,
643+ target_arch.GetTriple ());
644+
625645 // Disable some warnings.
626646 SetupDefaultClangDiagnostics (*m_compiler);
627647
0 commit comments