|
26 | 26 | #include "GenDecl.h"
|
27 | 27 | #include "GenMeta.h"
|
28 | 28 | #include "GenOpaque.h"
|
| 29 | +#include "GenPointerAuth.h" |
29 | 30 | #include "GenProto.h"
|
30 | 31 | #include "GenType.h"
|
31 | 32 | #include "IRGenDebugInfo.h"
|
@@ -589,9 +590,26 @@ static llvm::Value *lookupWitnessTable(IRGenFunction &IGF, llvm::Value *witness,
|
589 | 590 | assert(Lowering::TypeConverter::protocolRequiresWitnessTable(protocol));
|
590 | 591 |
|
591 | 592 | auto &IGM = IGF.IGM;
|
592 |
| - auto *protocolDescriptor = IGM.getAddrOfProtocolDescriptor(protocol); |
| 593 | + llvm::Value *protocolDescriptor = IGM.getAddrOfProtocolDescriptor(protocol); |
| 594 | + |
| 595 | + bool signedProtocolDescriptor = IGM.getAvailabilityRange().isContainedIn( |
| 596 | + IGM.Context.getSignedConformsToProtocolAvailability()); |
| 597 | + |
| 598 | + auto conformsToProtocolFunctionPointer = signedProtocolDescriptor ? |
| 599 | + IGM.getConformsToProtocol2FunctionPointer() : |
| 600 | + IGM.getConformsToProtocolFunctionPointer(); |
| 601 | + |
| 602 | + // Sign the protocol descriptor. |
| 603 | + auto schema = IGF.IGM.getOptions().PointerAuth.ProtocolDescriptorsAsArguments; |
| 604 | + if (schema && signedProtocolDescriptor) { |
| 605 | + auto authInfo = PointerAuthInfo::emit( |
| 606 | + IGF, schema, nullptr, |
| 607 | + PointerAuthEntity::Special::ProtocolDescriptorAsArgument); |
| 608 | + protocolDescriptor = emitPointerAuthSign(IGF, protocolDescriptor, authInfo); |
| 609 | + } |
| 610 | + |
593 | 611 | auto *witnessTable = IGF.Builder.CreateCall(
|
594 |
| - IGM.getConformsToProtocolFunctionPointer(), {witness, protocolDescriptor}); |
| 612 | + conformsToProtocolFunctionPointer, {witness, protocolDescriptor}); |
595 | 613 |
|
596 | 614 | auto failBB = IGF.createBasicBlock("missing-witness");
|
597 | 615 | auto contBB = IGF.createBasicBlock("");
|
|
0 commit comments