1//===- FileAnalysis.cpp -----------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "FileAnalysis.h"
10#include "GraphBuilder.h"
11
12#include "llvm/BinaryFormat/ELF.h"
13#include "llvm/DebugInfo/DWARF/DWARFContext.h"
14#include "llvm/MC/MCAsmInfo.h"
15#include "llvm/MC/MCContext.h"
16#include "llvm/MC/MCDisassembler/MCDisassembler.h"
17#include "llvm/MC/MCInst.h"
18#include "llvm/MC/MCInstPrinter.h"
19#include "llvm/MC/MCInstrAnalysis.h"
20#include "llvm/MC/MCInstrDesc.h"
21#include "llvm/MC/MCInstrInfo.h"
22#include "llvm/MC/MCObjectFileInfo.h"
23#include "llvm/MC/MCRegisterInfo.h"
24#include "llvm/MC/MCSubtargetInfo.h"
25#include "llvm/MC/MCTargetOptions.h"
26#include "llvm/MC/TargetRegistry.h"
27#include "llvm/Object/Binary.h"
28#include "llvm/Object/COFF.h"
29#include "llvm/Object/ELFObjectFile.h"
30#include "llvm/Object/ObjectFile.h"
31#include "llvm/Support/Casting.h"
32#include "llvm/Support/CommandLine.h"
33#include "llvm/Support/Error.h"
34#include "llvm/Support/raw_ostream.h"
35
36using Instr = llvm::cfi_verify::FileAnalysis::Instr;
37using LLVMSymbolizer = llvm::symbolize::LLVMSymbolizer;
38
39namespace llvm {
40namespace cfi_verify {
41
42bool IgnoreDWARFFlag;
43
44static cl::opt<bool, true> IgnoreDWARFArg(
45 "ignore-dwarf",
46 cl::desc(
47 "Ignore all DWARF data. This relaxes the requirements for all "
48 "statically linked libraries to have been compiled with '-g', but "
49 "will result in false positives for 'CFI unprotected' instructions."),
50 cl::location(L&: IgnoreDWARFFlag), cl::init(Val: false));
51
52StringRef stringCFIProtectionStatus(CFIProtectionStatus Status) {
53 switch (Status) {
54 case CFIProtectionStatus::PROTECTED:
55 return "PROTECTED";
56 case CFIProtectionStatus::FAIL_NOT_INDIRECT_CF:
57 return "FAIL_NOT_INDIRECT_CF";
58 case CFIProtectionStatus::FAIL_ORPHANS:
59 return "FAIL_ORPHANS";
60 case CFIProtectionStatus::FAIL_BAD_CONDITIONAL_BRANCH:
61 return "FAIL_BAD_CONDITIONAL_BRANCH";
62 case CFIProtectionStatus::FAIL_REGISTER_CLOBBERED:
63 return "FAIL_REGISTER_CLOBBERED";
64 case CFIProtectionStatus::FAIL_INVALID_INSTRUCTION:
65 return "FAIL_INVALID_INSTRUCTION";
66 }
67 llvm_unreachable("Attempted to stringify an unknown enum value.");
68}
69
70Expected<FileAnalysis> FileAnalysis::Create(StringRef Filename) {
71 // Open the filename provided.
72 Expected<object::OwningBinary<object::Binary>> BinaryOrErr =
73 object::createBinary(Path: Filename);
74 if (!BinaryOrErr)
75 return BinaryOrErr.takeError();
76
77 // Construct the object and allow it to take ownership of the binary.
78 object::OwningBinary<object::Binary> Binary = std::move(BinaryOrErr.get());
79 FileAnalysis Analysis(std::move(Binary));
80
81 Analysis.Object = dyn_cast<object::ObjectFile>(Val: Analysis.Binary.getBinary());
82 if (!Analysis.Object)
83 return make_error<UnsupportedDisassembly>(Args: "Failed to cast object");
84
85 switch (Analysis.Object->getArch()) {
86 case Triple::x86:
87 case Triple::x86_64:
88 case Triple::aarch64:
89 case Triple::aarch64_be:
90 break;
91 default:
92 return make_error<UnsupportedDisassembly>(Args: "Unsupported architecture.");
93 }
94
95 Analysis.ObjectTriple = Analysis.Object->makeTriple();
96 Expected<SubtargetFeatures> Features = Analysis.Object->getFeatures();
97 if (!Features)
98 return Features.takeError();
99
100 Analysis.Features = *Features;
101
102 // Init the rest of the object.
103 if (auto InitResponse = Analysis.initialiseDisassemblyMembers())
104 return std::move(InitResponse);
105
106 if (auto SectionParseResponse = Analysis.parseCodeSections())
107 return std::move(SectionParseResponse);
108
109 if (auto SymbolTableParseResponse = Analysis.parseSymbolTable())
110 return std::move(SymbolTableParseResponse);
111
112 return std::move(Analysis);
113}
114
115FileAnalysis::FileAnalysis(object::OwningBinary<object::Binary> Binary)
116 : Binary(std::move(Binary)) {}
117
118FileAnalysis::FileAnalysis(const Triple &ObjectTriple,
119 const SubtargetFeatures &Features)
120 : ObjectTriple(ObjectTriple), Features(Features) {}
121
122const Instr *
123FileAnalysis::getPrevInstructionSequential(const Instr &InstrMeta) const {
124 std::map<uint64_t, Instr>::const_iterator KV =
125 Instructions.find(x: InstrMeta.VMAddress);
126 if (KV == Instructions.end() || KV == Instructions.begin())
127 return nullptr;
128
129 if (!(--KV)->second.Valid)
130 return nullptr;
131
132 return &KV->second;
133}
134
135const Instr *
136FileAnalysis::getNextInstructionSequential(const Instr &InstrMeta) const {
137 std::map<uint64_t, Instr>::const_iterator KV =
138 Instructions.find(x: InstrMeta.VMAddress);
139 if (KV == Instructions.end() || ++KV == Instructions.end())
140 return nullptr;
141
142 if (!KV->second.Valid)
143 return nullptr;
144
145 return &KV->second;
146}
147
148bool FileAnalysis::usesRegisterOperand(const Instr &InstrMeta) const {
149 for (const auto &Operand : InstrMeta.Instruction) {
150 if (Operand.isReg())
151 return true;
152 }
153 return false;
154}
155
156const Instr *FileAnalysis::getInstruction(uint64_t Address) const {
157 const auto &InstrKV = Instructions.find(x: Address);
158 if (InstrKV == Instructions.end())
159 return nullptr;
160
161 return &InstrKV->second;
162}
163
164const Instr &FileAnalysis::getInstructionOrDie(uint64_t Address) const {
165 const auto &InstrKV = Instructions.find(x: Address);
166 assert(InstrKV != Instructions.end() && "Address doesn't exist.");
167 return InstrKV->second;
168}
169
170bool FileAnalysis::isCFITrap(const Instr &InstrMeta) const {
171 const auto &InstrDesc = MII->get(Opcode: InstrMeta.Instruction.getOpcode());
172 return InstrDesc.isTrap() || willTrapOnCFIViolation(InstrMeta);
173}
174
175bool FileAnalysis::willTrapOnCFIViolation(const Instr &InstrMeta) const {
176 const auto &InstrDesc = MII->get(Opcode: InstrMeta.Instruction.getOpcode());
177 if (!InstrDesc.isCall())
178 return false;
179 uint64_t Target;
180 if (!MIA->evaluateBranch(Inst: InstrMeta.Instruction, Addr: InstrMeta.VMAddress,
181 Size: InstrMeta.InstructionSize, Target))
182 return false;
183 return TrapOnFailFunctionAddresses.contains(V: Target);
184}
185
186bool FileAnalysis::canFallThrough(const Instr &InstrMeta) const {
187 if (!InstrMeta.Valid)
188 return false;
189
190 if (isCFITrap(InstrMeta))
191 return false;
192
193 const auto &InstrDesc = MII->get(Opcode: InstrMeta.Instruction.getOpcode());
194 if (InstrDesc.mayAffectControlFlow(MI: InstrMeta.Instruction, RI: *RegisterInfo))
195 return InstrDesc.isConditionalBranch();
196
197 return true;
198}
199
200const Instr *
201FileAnalysis::getDefiniteNextInstruction(const Instr &InstrMeta) const {
202 if (!InstrMeta.Valid)
203 return nullptr;
204
205 if (isCFITrap(InstrMeta))
206 return nullptr;
207
208 const auto &InstrDesc = MII->get(Opcode: InstrMeta.Instruction.getOpcode());
209 const Instr *NextMetaPtr;
210 if (InstrDesc.mayAffectControlFlow(MI: InstrMeta.Instruction, RI: *RegisterInfo)) {
211 if (InstrDesc.isConditionalBranch())
212 return nullptr;
213
214 uint64_t Target;
215 if (!MIA->evaluateBranch(Inst: InstrMeta.Instruction, Addr: InstrMeta.VMAddress,
216 Size: InstrMeta.InstructionSize, Target))
217 return nullptr;
218
219 NextMetaPtr = getInstruction(Address: Target);
220 } else {
221 NextMetaPtr =
222 getInstruction(Address: InstrMeta.VMAddress + InstrMeta.InstructionSize);
223 }
224
225 if (!NextMetaPtr || !NextMetaPtr->Valid)
226 return nullptr;
227
228 return NextMetaPtr;
229}
230
231std::set<const Instr *>
232FileAnalysis::getDirectControlFlowXRefs(const Instr &InstrMeta) const {
233 std::set<const Instr *> CFCrossReferences;
234 const Instr *PrevInstruction = getPrevInstructionSequential(InstrMeta);
235
236 if (PrevInstruction && canFallThrough(InstrMeta: *PrevInstruction))
237 CFCrossReferences.insert(x: PrevInstruction);
238
239 const auto &TargetRefsKV = StaticBranchTargetings.find(Val: InstrMeta.VMAddress);
240 if (TargetRefsKV == StaticBranchTargetings.end())
241 return CFCrossReferences;
242
243 for (uint64_t SourceInstrAddress : TargetRefsKV->second) {
244 const auto &SourceInstrKV = Instructions.find(x: SourceInstrAddress);
245 if (SourceInstrKV == Instructions.end()) {
246 errs() << "Failed to find source instruction at address "
247 << format_hex(N: SourceInstrAddress, Width: 2)
248 << " for the cross-reference to instruction at address "
249 << format_hex(N: InstrMeta.VMAddress, Width: 2) << ".\n";
250 continue;
251 }
252
253 CFCrossReferences.insert(x: &SourceInstrKV->second);
254 }
255
256 return CFCrossReferences;
257}
258
259const std::set<object::SectionedAddress> &
260FileAnalysis::getIndirectInstructions() const {
261 return IndirectInstructions;
262}
263
264const MCRegisterInfo *FileAnalysis::getRegisterInfo() const {
265 return RegisterInfo.get();
266}
267
268const MCInstrInfo *FileAnalysis::getMCInstrInfo() const { return MII.get(); }
269
270const MCInstrAnalysis *FileAnalysis::getMCInstrAnalysis() const {
271 return MIA.get();
272}
273
274Expected<DIInliningInfo>
275FileAnalysis::symbolizeInlinedCode(object::SectionedAddress Address) {
276 assert(Symbolizer != nullptr && "Symbolizer is invalid.");
277
278 return Symbolizer->symbolizeInlinedCode(ModuleName: Object->getFileName(), ModuleOffset: Address);
279}
280
281CFIProtectionStatus
282FileAnalysis::validateCFIProtection(const GraphResult &Graph) const {
283 const Instr *InstrMetaPtr = getInstruction(Address: Graph.BaseAddress);
284 if (!InstrMetaPtr)
285 return CFIProtectionStatus::FAIL_INVALID_INSTRUCTION;
286
287 const auto &InstrDesc = MII->get(Opcode: InstrMetaPtr->Instruction.getOpcode());
288 if (!InstrDesc.mayAffectControlFlow(MI: InstrMetaPtr->Instruction, RI: *RegisterInfo))
289 return CFIProtectionStatus::FAIL_NOT_INDIRECT_CF;
290
291 if (!usesRegisterOperand(InstrMeta: *InstrMetaPtr))
292 return CFIProtectionStatus::FAIL_NOT_INDIRECT_CF;
293
294 if (!Graph.OrphanedNodes.empty())
295 return CFIProtectionStatus::FAIL_ORPHANS;
296
297 for (const auto &BranchNode : Graph.ConditionalBranchNodes) {
298 if (!BranchNode.CFIProtection)
299 return CFIProtectionStatus::FAIL_BAD_CONDITIONAL_BRANCH;
300 }
301
302 if (indirectCFOperandClobber(Graph) != Graph.BaseAddress)
303 return CFIProtectionStatus::FAIL_REGISTER_CLOBBERED;
304
305 return CFIProtectionStatus::PROTECTED;
306}
307
308uint64_t FileAnalysis::indirectCFOperandClobber(const GraphResult &Graph) const {
309 assert(Graph.OrphanedNodes.empty() && "Orphaned nodes should be empty.");
310
311 // Get the set of registers we must check to ensure they're not clobbered.
312 const Instr &IndirectCF = getInstructionOrDie(Address: Graph.BaseAddress);
313 DenseSet<unsigned> RegisterNumbers;
314 for (const auto &Operand : IndirectCF.Instruction) {
315 if (Operand.isReg())
316 RegisterNumbers.insert(V: Operand.getReg());
317 }
318 assert(RegisterNumbers.size() && "Zero register operands on indirect CF.");
319
320 // Now check all branches to indirect CFs and ensure no clobbering happens.
321 for (const auto &Branch : Graph.ConditionalBranchNodes) {
322 uint64_t Node;
323 if (Branch.IndirectCFIsOnTargetPath)
324 Node = Branch.Target;
325 else
326 Node = Branch.Fallthrough;
327
328 // Some architectures (e.g., AArch64) cannot load in an indirect branch, so
329 // we allow them one load.
330 bool canLoad = !MII->get(Opcode: IndirectCF.Instruction.getOpcode()).mayLoad();
331
332 // We walk backwards from the indirect CF. It is the last node returned by
333 // Graph.flattenAddress, so we skip it since we already handled it.
334 DenseSet<unsigned> CurRegisterNumbers = RegisterNumbers;
335 std::vector<uint64_t> Nodes = Graph.flattenAddress(Address: Node);
336 for (auto I = Nodes.rbegin() + 1, E = Nodes.rend(); I != E; ++I) {
337 Node = *I;
338 const Instr &NodeInstr = getInstructionOrDie(Address: Node);
339 const auto &InstrDesc = MII->get(Opcode: NodeInstr.Instruction.getOpcode());
340
341 for (auto RI = CurRegisterNumbers.begin(), RE = CurRegisterNumbers.end();
342 RI != RE; ++RI) {
343 unsigned RegNum = *RI;
344 if (InstrDesc.hasDefOfPhysReg(MI: NodeInstr.Instruction, Reg: RegNum,
345 RI: *RegisterInfo)) {
346 if (!canLoad || !InstrDesc.mayLoad())
347 return Node;
348 canLoad = false;
349 CurRegisterNumbers.erase(I: RI);
350 // Add the registers this load reads to those we check for clobbers.
351 for (unsigned i = InstrDesc.getNumDefs(),
352 e = InstrDesc.getNumOperands(); i != e; i++) {
353 const auto &Operand = NodeInstr.Instruction.getOperand(i);
354 if (Operand.isReg())
355 CurRegisterNumbers.insert(V: Operand.getReg());
356 }
357 break;
358 }
359 }
360 }
361 }
362
363 return Graph.BaseAddress;
364}
365
366void FileAnalysis::printInstruction(const Instr &InstrMeta,
367 raw_ostream &OS) const {
368 Printer->printInst(MI: &InstrMeta.Instruction, Address: 0, Annot: "", STI: *SubtargetInfo, OS);
369}
370
371Error FileAnalysis::initialiseDisassemblyMembers() {
372 std::string TripleName = ObjectTriple.getTriple();
373 ArchName = "";
374 MCPU = "";
375 std::string ErrorString;
376
377 Triple TheTriple(TripleName);
378
379 LLVMSymbolizer::Options Opt;
380 Opt.UseSymbolTable = false;
381 Symbolizer.reset(p: new LLVMSymbolizer(Opt));
382
383 ObjectTarget =
384 TargetRegistry::lookupTarget(ArchName, TheTriple&: ObjectTriple, Error&: ErrorString);
385 if (!ObjectTarget)
386 return make_error<UnsupportedDisassembly>(
387 Args: (Twine("Couldn't find target \"") + ObjectTriple.getTriple() +
388 "\", failed with error: " + ErrorString)
389 .str());
390
391 RegisterInfo.reset(p: ObjectTarget->createMCRegInfo(TT: TheTriple));
392 if (!RegisterInfo)
393 return make_error<UnsupportedDisassembly>(
394 Args: "Failed to initialise RegisterInfo.");
395
396 MCTargetOptions MCOptions;
397 AsmInfo.reset(
398 p: ObjectTarget->createMCAsmInfo(MRI: *RegisterInfo, TheTriple, Options: MCOptions));
399 if (!AsmInfo)
400 return make_error<UnsupportedDisassembly>(Args: "Failed to initialise AsmInfo.");
401
402 SubtargetInfo.reset(p: ObjectTarget->createMCSubtargetInfo(
403 TheTriple, CPU: MCPU, Features: Features.getString()));
404 if (!SubtargetInfo)
405 return make_error<UnsupportedDisassembly>(
406 Args: "Failed to initialise SubtargetInfo.");
407
408 MII.reset(p: ObjectTarget->createMCInstrInfo());
409 if (!MII)
410 return make_error<UnsupportedDisassembly>(Args: "Failed to initialise MII.");
411
412 Context.reset(p: new MCContext(Triple(TripleName), *AsmInfo, *RegisterInfo,
413 *SubtargetInfo));
414
415 Disassembler.reset(
416 p: ObjectTarget->createMCDisassembler(STI: *SubtargetInfo, Ctx&: *Context));
417
418 if (!Disassembler)
419 return make_error<UnsupportedDisassembly>(
420 Args: "No disassembler available for target");
421
422 MIA.reset(p: ObjectTarget->createMCInstrAnalysis(Info: MII.get()));
423
424 Printer.reset(p: ObjectTarget->createMCInstPrinter(
425 T: ObjectTriple, SyntaxVariant: AsmInfo->getAssemblerDialect(), MAI: *AsmInfo, MII: *MII,
426 MRI: *RegisterInfo));
427
428 return Error::success();
429}
430
431Error FileAnalysis::parseCodeSections() {
432 if (!IgnoreDWARFFlag) {
433 std::unique_ptr<DWARFContext> DWARF = DWARFContext::create(Obj: *Object);
434 if (!DWARF)
435 return make_error<StringError>(Args: "Could not create DWARF information.",
436 Args: inconvertibleErrorCode());
437
438 bool LineInfoValid = false;
439
440 for (auto &Unit : DWARF->compile_units()) {
441 const auto &LineTable = DWARF->getLineTableForUnit(U: Unit.get());
442 if (LineTable && !LineTable->Rows.empty()) {
443 LineInfoValid = true;
444 break;
445 }
446 }
447
448 if (!LineInfoValid)
449 return make_error<StringError>(
450 Args: "DWARF line information missing. Did you compile with '-g'?",
451 Args: inconvertibleErrorCode());
452 }
453
454 for (const object::SectionRef &Section : Object->sections()) {
455 // Ensure only executable sections get analysed.
456 if (!(object::ELFSectionRef(Section).getFlags() & ELF::SHF_EXECINSTR))
457 continue;
458
459 // Avoid checking the PLT since it produces spurious failures on AArch64
460 // when ignoring DWARF data.
461 Expected<StringRef> NameOrErr = Section.getName();
462 if (NameOrErr && *NameOrErr == ".plt")
463 continue;
464 consumeError(Err: NameOrErr.takeError());
465
466 Expected<StringRef> Contents = Section.getContents();
467 if (!Contents)
468 return Contents.takeError();
469 ArrayRef<uint8_t> SectionBytes = arrayRefFromStringRef(Input: *Contents);
470
471 parseSectionContents(SectionBytes,
472 Address: {.Address: Section.getAddress(), .SectionIndex: Section.getIndex()});
473 }
474 return Error::success();
475}
476
477void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes,
478 object::SectionedAddress Address) {
479 assert(Symbolizer && "Symbolizer is uninitialised.");
480 MCInst Instruction;
481 Instr InstrMeta;
482 uint64_t InstructionSize;
483
484 for (uint64_t Byte = 0; Byte < SectionBytes.size();) {
485 bool ValidInstruction =
486 Disassembler->getInstruction(Instr&: Instruction, Size&: InstructionSize,
487 Bytes: SectionBytes.drop_front(N: Byte), Address: 0,
488 CStream&: outs()) == MCDisassembler::Success;
489
490 Byte += InstructionSize;
491
492 uint64_t VMAddress = Address.Address + Byte - InstructionSize;
493 InstrMeta.Instruction = Instruction;
494 InstrMeta.VMAddress = VMAddress;
495 InstrMeta.InstructionSize = InstructionSize;
496 InstrMeta.Valid = ValidInstruction;
497
498 addInstruction(Instruction: InstrMeta);
499
500 if (!ValidInstruction)
501 continue;
502
503 // Skip additional parsing for instructions that do not affect the control
504 // flow.
505 const auto &InstrDesc = MII->get(Opcode: Instruction.getOpcode());
506 if (!InstrDesc.mayAffectControlFlow(MI: Instruction, RI: *RegisterInfo))
507 continue;
508
509 uint64_t Target;
510 if (MIA->evaluateBranch(Inst: Instruction, Addr: VMAddress, Size: InstructionSize, Target)) {
511 // If the target can be evaluated, it's not indirect.
512 StaticBranchTargetings[Target].push_back(x: VMAddress);
513 continue;
514 }
515
516 if (!usesRegisterOperand(InstrMeta))
517 continue;
518
519 if (InstrDesc.isReturn())
520 continue;
521
522 // Check if this instruction exists in the range of the DWARF metadata.
523 if (!IgnoreDWARFFlag) {
524 auto LineInfo = Symbolizer->symbolizeCode(
525 ModuleName: Object->getFileName(), ModuleOffset: {.Address: VMAddress, .SectionIndex: Address.SectionIndex});
526 if (!LineInfo) {
527 handleAllErrors(E: LineInfo.takeError(), Handlers: [](const ErrorInfoBase &E) {
528 errs() << "Symbolizer failed to get line: " << E.message() << "\n";
529 });
530 continue;
531 }
532
533 if (LineInfo->FileName == DILineInfo::BadString)
534 continue;
535 }
536
537 IndirectInstructions.insert(x: {.Address: VMAddress, .SectionIndex: Address.SectionIndex});
538 }
539}
540
541void FileAnalysis::addInstruction(const Instr &Instruction) {
542 const auto &KV =
543 Instructions.insert(x: std::make_pair(x: Instruction.VMAddress, y: Instruction));
544 if (!KV.second) {
545 errs() << "Failed to add instruction at address "
546 << format_hex(N: Instruction.VMAddress, Width: 2)
547 << ": Instruction at this address already exists.\n";
548 exit(EXIT_FAILURE);
549 }
550}
551
552Error FileAnalysis::parseSymbolTable() {
553 // Functions that will trap on CFI violations.
554 SmallSet<StringRef, 4> TrapOnFailFunctions;
555 TrapOnFailFunctions.insert(V: "__cfi_slowpath");
556 TrapOnFailFunctions.insert(V: "__cfi_slowpath_diag");
557 TrapOnFailFunctions.insert(V: "abort");
558
559 // Look through the list of symbols for functions that will trap on CFI
560 // violations.
561 for (auto &Sym : Object->symbols()) {
562 auto SymNameOrErr = Sym.getName();
563 if (!SymNameOrErr)
564 consumeError(Err: SymNameOrErr.takeError());
565 else if (TrapOnFailFunctions.contains(V: *SymNameOrErr)) {
566 auto AddrOrErr = Sym.getAddress();
567 if (!AddrOrErr)
568 consumeError(Err: AddrOrErr.takeError());
569 else
570 TrapOnFailFunctionAddresses.insert(V: *AddrOrErr);
571 }
572 }
573 if (auto *ElfObject = dyn_cast<object::ELFObjectFileBase>(Val: Object)) {
574 for (const auto &Plt : ElfObject->getPltEntries(STI: *SubtargetInfo)) {
575 if (!Plt.Symbol)
576 continue;
577 object::SymbolRef Sym(*Plt.Symbol, Object);
578 auto SymNameOrErr = Sym.getName();
579 if (!SymNameOrErr)
580 consumeError(Err: SymNameOrErr.takeError());
581 else if (TrapOnFailFunctions.contains(V: *SymNameOrErr))
582 TrapOnFailFunctionAddresses.insert(V: Plt.Address);
583 }
584 }
585 return Error::success();
586}
587
588UnsupportedDisassembly::UnsupportedDisassembly(StringRef Text)
589 : Text(std::string(Text)) {}
590
591char UnsupportedDisassembly::ID;
592void UnsupportedDisassembly::log(raw_ostream &OS) const {
593 OS << "Could not initialise disassembler: " << Text;
594}
595
596std::error_code UnsupportedDisassembly::convertToErrorCode() const {
597 return std::error_code();
598}
599
600} // namespace cfi_verify
601} // namespace llvm
602