1 //===- llvm/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "../tools/llvm-cfi-verify/lib/FileAnalysis.h"
11 #include "gmock/gmock.h"
12 #include "gtest/gtest.h"
14 #include "llvm/BinaryFormat/ELF.h"
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCDisassembler/MCDisassembler.h"
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCInstPrinter.h"
20 #include "llvm/MC/MCInstrAnalysis.h"
21 #include "llvm/MC/MCInstrDesc.h"
22 #include "llvm/MC/MCInstrInfo.h"
23 #include "llvm/MC/MCObjectFileInfo.h"
24 #include "llvm/MC/MCRegisterInfo.h"
25 #include "llvm/MC/MCSubtargetInfo.h"
26 #include "llvm/Object/Binary.h"
27 #include "llvm/Object/COFF.h"
28 #include "llvm/Object/ELFObjectFile.h"
29 #include "llvm/Object/ObjectFile.h"
30 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/CommandLine.h"
32 #include "llvm/Support/Error.h"
33 #include "llvm/Support/MemoryBuffer.h"
34 #include "llvm/Support/TargetRegistry.h"
35 #include "llvm/Support/TargetSelect.h"
36 #include "llvm/Support/raw_ostream.h"
40 using Instr = ::llvm::cfi_verify::FileAnalysis::Instr;
42 using ::testing::Field;
45 namespace cfi_verify {
47 class ELFx86TestFileAnalysis : public FileAnalysis {
49 ELFx86TestFileAnalysis()
50 : FileAnalysis(Triple("x86_64--"), SubtargetFeatures()) {}
52 // Expose this method publicly for testing.
53 void parseSectionContents(ArrayRef<uint8_t> SectionBytes,
54 uint64_t SectionAddress) {
55 FileAnalysis::parseSectionContents(SectionBytes, SectionAddress);
58 Error initialiseDisassemblyMembers() {
59 return FileAnalysis::initialiseDisassemblyMembers();
63 class BasicFileAnalysisTest : public ::testing::Test {
65 virtual void SetUp() {
66 SuccessfullyInitialised = true;
67 if (auto Err = Analysis.initialiseDisassemblyMembers()) {
68 handleAllErrors(std::move(Err), [&](const UnsupportedDisassembly &E) {
69 SuccessfullyInitialised = false;
71 << "Note: CFIVerifyTests are disabled due to lack of x86 support "
77 bool SuccessfullyInitialised;
78 ELFx86TestFileAnalysis Analysis;
81 TEST_F(BasicFileAnalysisTest, BasicDisassemblyTraversalTest) {
82 if (!SuccessfullyInitialised)
84 Analysis.parseSectionContents(
87 0xb0, 0x00, // 1: mov $0x0, %al
88 0x48, 0x89, 0xe5, // 3: mov %rsp, %rbp
89 0x48, 0x83, 0xec, 0x18, // 6: sub $0x18, %rsp
90 0x48, 0xbe, 0xc4, 0x07, 0x40,
91 0x00, 0x00, 0x00, 0x00, 0x00, // 10: movabs $0x4007c4, %rsi
93 0x41, 0x0e, // 21: rex.B (bad)
94 0x62, 0x72, 0x65, 0x61, 0x6b, // 23: (bad) {%k1}
98 EXPECT_EQ(nullptr, Analysis.getInstruction(0x0));
99 EXPECT_EQ(nullptr, Analysis.getInstruction(0x1000));
102 const auto *InstrMeta = Analysis.getInstruction(0xDEADBEEF);
103 EXPECT_NE(nullptr, InstrMeta);
104 EXPECT_EQ(0xDEADBEEF, InstrMeta->VMAddress);
105 EXPECT_EQ(1u, InstrMeta->InstructionSize);
106 EXPECT_TRUE(InstrMeta->Valid);
108 const auto *NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
109 EXPECT_EQ(nullptr, Analysis.getPrevInstructionSequential(*InstrMeta));
110 const auto *PrevInstrMeta = InstrMeta;
112 // 0xDEADBEEF + 1: mov $0x0, %al
113 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 1);
114 EXPECT_NE(nullptr, InstrMeta);
115 EXPECT_EQ(NextInstrMeta, InstrMeta);
116 EXPECT_EQ(0xDEADBEEF + 1, InstrMeta->VMAddress);
117 EXPECT_EQ(2u, InstrMeta->InstructionSize);
118 EXPECT_TRUE(InstrMeta->Valid);
120 NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
121 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
122 PrevInstrMeta = InstrMeta;
124 // 0xDEADBEEF + 3: mov %rsp, %rbp
125 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 3);
126 EXPECT_NE(nullptr, InstrMeta);
127 EXPECT_EQ(NextInstrMeta, InstrMeta);
128 EXPECT_EQ(0xDEADBEEF + 3, InstrMeta->VMAddress);
129 EXPECT_EQ(3u, InstrMeta->InstructionSize);
130 EXPECT_TRUE(InstrMeta->Valid);
132 NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
133 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
134 PrevInstrMeta = InstrMeta;
136 // 0xDEADBEEF + 6: sub $0x18, %rsp
137 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 6);
138 EXPECT_NE(nullptr, InstrMeta);
139 EXPECT_EQ(NextInstrMeta, InstrMeta);
140 EXPECT_EQ(0xDEADBEEF + 6, InstrMeta->VMAddress);
141 EXPECT_EQ(4u, InstrMeta->InstructionSize);
142 EXPECT_TRUE(InstrMeta->Valid);
144 NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
145 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
146 PrevInstrMeta = InstrMeta;
148 // 0xDEADBEEF + 10: movabs $0x4007c4, %rsi
149 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 10);
150 EXPECT_NE(nullptr, InstrMeta);
151 EXPECT_EQ(NextInstrMeta, InstrMeta);
152 EXPECT_EQ(0xDEADBEEF + 10, InstrMeta->VMAddress);
153 EXPECT_EQ(10u, InstrMeta->InstructionSize);
154 EXPECT_TRUE(InstrMeta->Valid);
156 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
157 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
158 PrevInstrMeta = InstrMeta;
160 // 0xDEADBEEF + 20: (bad)
161 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 20);
162 EXPECT_NE(nullptr, InstrMeta);
163 EXPECT_EQ(0xDEADBEEF + 20, InstrMeta->VMAddress);
164 EXPECT_EQ(1u, InstrMeta->InstructionSize);
165 EXPECT_FALSE(InstrMeta->Valid);
167 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
168 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
170 // 0xDEADBEEF + 21: rex.B (bad)
171 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 21);
172 EXPECT_NE(nullptr, InstrMeta);
173 EXPECT_EQ(0xDEADBEEF + 21, InstrMeta->VMAddress);
174 EXPECT_EQ(2u, InstrMeta->InstructionSize);
175 EXPECT_FALSE(InstrMeta->Valid);
177 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
178 EXPECT_EQ(nullptr, Analysis.getPrevInstructionSequential(*InstrMeta));
180 // 0xDEADBEEF + 6: (bad) {%k1}
181 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 23);
182 EXPECT_NE(nullptr, InstrMeta);
183 EXPECT_EQ(0xDEADBEEF + 23, InstrMeta->VMAddress);
184 EXPECT_EQ(5u, InstrMeta->InstructionSize);
185 EXPECT_FALSE(InstrMeta->Valid);
187 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
188 EXPECT_EQ(nullptr, Analysis.getPrevInstructionSequential(*InstrMeta));
191 TEST_F(BasicFileAnalysisTest, PrevAndNextFromBadInst) {
192 if (!SuccessfullyInitialised)
194 Analysis.parseSectionContents(
201 const auto &BadInstrMeta = Analysis.getInstructionOrDie(0xDEADBEEF + 1);
202 const auto *GoodInstrMeta =
203 Analysis.getPrevInstructionSequential(BadInstrMeta);
204 EXPECT_NE(nullptr, GoodInstrMeta);
205 EXPECT_EQ(0xDEADBEEF, GoodInstrMeta->VMAddress);
206 EXPECT_EQ(1u, GoodInstrMeta->InstructionSize);
208 GoodInstrMeta = Analysis.getNextInstructionSequential(BadInstrMeta);
209 EXPECT_NE(nullptr, GoodInstrMeta);
210 EXPECT_EQ(0xDEADBEEF + 2, GoodInstrMeta->VMAddress);
211 EXPECT_EQ(1u, GoodInstrMeta->InstructionSize);
214 TEST_F(BasicFileAnalysisTest, CFITrapTest) {
215 if (!SuccessfullyInitialised)
217 Analysis.parseSectionContents(
220 0xb0, 0x00, // 1: mov $0x0, %al
221 0x48, 0x89, 0xe5, // 3: mov %rsp, %rbp
222 0x48, 0x83, 0xec, 0x18, // 6: sub $0x18, %rsp
223 0x48, 0xbe, 0xc4, 0x07, 0x40,
224 0x00, 0x00, 0x00, 0x00, 0x00, // 10: movabs $0x4007c4, %rsi
226 0x41, 0x0e, // 21: rex.B (bad)
227 0x62, 0x72, 0x65, 0x61, 0x6b, // 23: (bad) {%k1}
228 0x0f, 0x0b // 28: ud2
232 EXPECT_FALSE(Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF)));
234 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 3)));
236 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 6)));
238 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 10)));
240 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 20)));
242 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 21)));
244 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 23)));
246 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 28)));
249 TEST_F(BasicFileAnalysisTest, FallThroughTest) {
250 if (!SuccessfullyInitialised)
252 Analysis.parseSectionContents(
255 0xb0, 0x00, // 1: mov $0x0, %al
257 0x0f, 0x0b, // 4: ud2
258 0xff, 0x20, // 6: jmpq *(%rax)
259 0xeb, 0x00, // 8: jmp +0
260 0xe8, 0x45, 0xfe, 0xff, 0xff, // 10: callq [some loc]
261 0xff, 0x10, // 15: callq *(rax)
262 0x75, 0x00, // 17: jne +0
268 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF)));
270 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 1)));
272 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 3)));
274 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 4)));
276 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 6)));
278 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 8)));
280 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 10)));
282 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 15)));
284 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 17)));
286 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 19)));
289 TEST_F(BasicFileAnalysisTest, DefiniteNextInstructionTest) {
290 if (!SuccessfullyInitialised)
292 Analysis.parseSectionContents(
295 0xb0, 0x00, // 1: mov $0x0, %al
297 0x0f, 0x0b, // 4: ud2
298 0xff, 0x20, // 6: jmpq *(%rax)
299 0xeb, 0x00, // 8: jmp 10 [+0]
300 0xeb, 0x05, // 10: jmp 17 [+5]
301 0xe8, 0x00, 0x00, 0x00, 0x00, // 12: callq 17 [+0]
302 0xe8, 0x78, 0x56, 0x34, 0x12, // 17: callq 0x1234569f [+0x12345678]
303 0xe8, 0x04, 0x00, 0x00, 0x00, // 22: callq 31 [+4]
304 0xff, 0x10, // 27: callq *(rax)
305 0x75, 0x00, // 29: jne 31 [+0]
306 0x75, 0xe0, // 31: jne 1 [-32]
308 0xeb, 0xdd, // 34: jmp 1 [-35]
309 0xeb, 0xdd, // 36: jmp 3 [-35]
310 0xeb, 0xdc, // 38: jmp 4 [-36]
314 const auto *Current = Analysis.getInstruction(0xDEADBEEF);
315 const auto *Next = Analysis.getDefiniteNextInstruction(*Current);
316 EXPECT_NE(nullptr, Next);
317 EXPECT_EQ(0xDEADBEEF + 1, Next->VMAddress);
319 Current = Analysis.getInstruction(0xDEADBEEF + 1);
320 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
322 Current = Analysis.getInstruction(0xDEADBEEF + 3);
323 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
325 Current = Analysis.getInstruction(0xDEADBEEF + 4);
326 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
328 Current = Analysis.getInstruction(0xDEADBEEF + 6);
329 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
331 Current = Analysis.getInstruction(0xDEADBEEF + 8);
332 Next = Analysis.getDefiniteNextInstruction(*Current);
333 EXPECT_NE(nullptr, Next);
334 EXPECT_EQ(0xDEADBEEF + 10, Next->VMAddress);
336 Current = Analysis.getInstruction(0xDEADBEEF + 10);
337 Next = Analysis.getDefiniteNextInstruction(*Current);
338 EXPECT_NE(nullptr, Next);
339 EXPECT_EQ(0xDEADBEEF + 17, Next->VMAddress);
341 Current = Analysis.getInstruction(0xDEADBEEF + 12);
342 Next = Analysis.getDefiniteNextInstruction(*Current);
343 EXPECT_NE(nullptr, Next);
344 EXPECT_EQ(0xDEADBEEF + 17, Next->VMAddress);
346 Current = Analysis.getInstruction(0xDEADBEEF + 17);
347 // Note, definite next instruction address is out of range and should fail.
348 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
349 Next = Analysis.getDefiniteNextInstruction(*Current);
351 Current = Analysis.getInstruction(0xDEADBEEF + 22);
352 Next = Analysis.getDefiniteNextInstruction(*Current);
353 EXPECT_NE(nullptr, Next);
354 EXPECT_EQ(0xDEADBEEF + 31, Next->VMAddress);
356 Current = Analysis.getInstruction(0xDEADBEEF + 27);
357 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
358 Current = Analysis.getInstruction(0xDEADBEEF + 29);
359 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
360 Current = Analysis.getInstruction(0xDEADBEEF + 31);
361 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
362 Current = Analysis.getInstruction(0xDEADBEEF + 33);
363 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
365 Current = Analysis.getInstruction(0xDEADBEEF + 34);
366 Next = Analysis.getDefiniteNextInstruction(*Current);
367 EXPECT_NE(nullptr, Next);
368 EXPECT_EQ(0xDEADBEEF + 1, Next->VMAddress);
370 Current = Analysis.getInstruction(0xDEADBEEF + 36);
371 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
373 Current = Analysis.getInstruction(0xDEADBEEF + 38);
374 Next = Analysis.getDefiniteNextInstruction(*Current);
375 EXPECT_NE(nullptr, Next);
376 EXPECT_EQ(0xDEADBEEF + 4, Next->VMAddress);
379 TEST_F(BasicFileAnalysisTest, ControlFlowXRefsTest) {
380 if (!SuccessfullyInitialised)
382 Analysis.parseSectionContents(
385 0xb0, 0x00, // 1: mov $0x0, %al
387 0x0f, 0x0b, // 4: ud2
388 0xff, 0x20, // 6: jmpq *(%rax)
389 0xeb, 0x00, // 8: jmp 10 [+0]
390 0xeb, 0x05, // 10: jmp 17 [+5]
391 0xe8, 0x00, 0x00, 0x00, 0x00, // 12: callq 17 [+0]
392 0xe8, 0x78, 0x56, 0x34, 0x12, // 17: callq 0x1234569f [+0x12345678]
393 0xe8, 0x04, 0x00, 0x00, 0x00, // 22: callq 31 [+4]
394 0xff, 0x10, // 27: callq *(rax)
395 0x75, 0x00, // 29: jne 31 [+0]
396 0x75, 0xe0, // 31: jne 1 [-32]
398 0xeb, 0xdd, // 34: jmp 1 [-35]
399 0xeb, 0xdd, // 36: jmp 3 [-35]
400 0xeb, 0xdc, // 38: jmp 4 [-36]
403 const auto *InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF);
404 std::set<const Instr *> XRefs =
405 Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
406 EXPECT_TRUE(XRefs.empty());
408 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 1);
409 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
410 EXPECT_THAT(XRefs, UnorderedElementsAre(
411 Field(&Instr::VMAddress, Eq(0xDEADBEEF)),
412 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 31)),
413 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 34))));
415 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 3);
416 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
417 EXPECT_THAT(XRefs, UnorderedElementsAre(
418 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 1)),
419 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 36))));
421 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 4);
422 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
423 EXPECT_THAT(XRefs, UnorderedElementsAre(
424 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 38))));
426 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 6);
427 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
429 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 8);
430 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
431 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
433 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 10);
434 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
435 EXPECT_THAT(XRefs, UnorderedElementsAre(
436 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 8))));
438 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 12);
439 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
440 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
442 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 17);
443 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
444 EXPECT_THAT(XRefs, UnorderedElementsAre(
445 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 10)),
446 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 12))));
448 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 22);
449 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
450 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
452 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 27);
453 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
454 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
456 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 29);
457 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
458 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
460 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 31);
461 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
462 EXPECT_THAT(XRefs, UnorderedElementsAre(
463 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 22)),
464 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 29))));
466 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 33);
467 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
468 EXPECT_THAT(XRefs, UnorderedElementsAre(
469 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 31))));
471 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 34);
472 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
473 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
475 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 36);
476 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
477 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
479 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 38);
480 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
481 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
484 } // anonymous namespace
485 } // end namespace cfi_verify
486 } // end namespace llvm
488 int main(int argc, char **argv) {
489 ::testing::InitGoogleTest(&argc, argv);
490 llvm::cl::ParseCommandLineOptions(argc, argv);
492 llvm::InitializeAllTargetInfos();
493 llvm::InitializeAllTargetMCs();
494 llvm::InitializeAllAsmParsers();
495 llvm::InitializeAllDisassemblers();
497 return RUN_ALL_TESTS();