@@ -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,11 @@ ClangExpressionParser::ClangExpressionParser(
467472
468473 auto target_info = TargetInfo::CreateTargetInfo (
469474 m_compiler->getDiagnostics (), m_compiler->getInvocation ().TargetOpts );
475+ bool is_pauthabi = true ;
476+ if (target_machine == llvm::Triple::aarch64 && is_pauthabi) {
477+ // TODO: enable this depending on corresponding tag section in ELF
478+ target_info->getTargetOpts ().Features .push_back (" +pauth" );
479+ }
470480 if (log) {
471481 LLDB_LOGF (log, " Target datalayout string: '%s'" ,
472482 target_info->getDataLayoutString ());
@@ -612,6 +622,14 @@ ClangExpressionParser::ClangExpressionParser(
612622 // additionally enabling them as expandable builtins is breaking Clang.
613623 lang_opts.NoBuiltin = true ;
614624
625+ // TODO: enable this depending on corresponding tag section in ELF
626+ if (is_pauthabi) {
627+ lang_opts.PointerAuthCalls = true ;
628+ lang_opts.PointerAuthReturns = true ;
629+ lang_opts.PointerAuthVTPtrAddressDiscrimination = true ;
630+ lang_opts.PointerAuthVTPtrTypeDiscrimination = true ;
631+ lang_opts.PointerAuthInitFini = true ;
632+ }
615633 // Set CodeGen options
616634 m_compiler->getCodeGenOpts ().EmitDeclMetadata = true ;
617635 m_compiler->getCodeGenOpts ().InstrumentFunctions = false ;
@@ -622,6 +640,10 @@ ClangExpressionParser::ClangExpressionParser(
622640 else
623641 m_compiler->getCodeGenOpts ().setDebugInfo (codegenoptions::NoDebugInfo);
624642
643+ CompilerInvocation::setDefaultPointerAuthOptions (
644+ m_compiler->getCodeGenOpts ().PointerAuth , lang_opts,
645+ target_arch.GetTriple ());
646+
625647 // Disable some warnings.
626648 SetupDefaultClangDiagnostics (*m_compiler);
627649
0 commit comments