/src/keystone/llvm/lib/MC/MCObjectWriter.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | |
10 | | #include "llvm/MC/MCAssembler.h" |
11 | | #include "llvm/MC/MCExpr.h" |
12 | | #include "llvm/MC/MCObjectWriter.h" |
13 | | #include "llvm/MC/MCSymbol.h" |
14 | | |
15 | | using namespace llvm_ks; |
16 | | |
17 | 129k | MCObjectWriter::~MCObjectWriter() { |
18 | 129k | } |
19 | | |
20 | | bool MCObjectWriter::isSymbolRefDifferenceFullyResolved( |
21 | | const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B, |
22 | | bool InSet, bool &valid) const |
23 | 121k | { |
24 | 121k | valid = true; |
25 | | // Modified symbol references cannot be resolved. |
26 | 121k | if (A->getKind() != MCSymbolRefExpr::VK_None || |
27 | 121k | B->getKind() != MCSymbolRefExpr::VK_None) |
28 | 205 | return false; |
29 | | |
30 | 121k | const MCSymbol &SA = A->getSymbol(); |
31 | 121k | const MCSymbol &SB = B->getSymbol(); |
32 | 121k | if (SA.isUndefined() || SB.isUndefined()) |
33 | 0 | return false; |
34 | | |
35 | 121k | if (!SA.getFragment() || !SB.getFragment()) |
36 | 0 | return false; |
37 | | |
38 | 121k | if (!SA.isInSection()) { |
39 | 779 | valid = false; |
40 | 779 | return false; |
41 | 779 | } |
42 | 120k | return isSymbolRefDifferenceFullyResolvedImpl(Asm, SA, SB, InSet); |
43 | 121k | } |
44 | | |
45 | | bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( |
46 | | const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, |
47 | 120k | bool InSet) const { |
48 | 120k | return isSymbolRefDifferenceFullyResolvedImpl(Asm, A, *B.getFragment(), InSet, |
49 | 120k | false); |
50 | 120k | } |
51 | | |
52 | | bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( |
53 | | const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, |
54 | 143k | bool InSet, bool IsPCRel) const { |
55 | 143k | const MCSection &SecA = SymA.getSection(); |
56 | 143k | const MCSection &SecB = *FB.getParent(); |
57 | | // On ELF and COFF A - B is absolute if A and B are in the same section. |
58 | 143k | return &SecA == &SecB; |
59 | 143k | } |
60 | | |
61 | 0 | bool MCObjectWriter::isWeak(const MCSymbol &) const { return false; } |