1//===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===//
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 "llvm/MC/MCObjectWriter.h"
10#include "llvm/MC/MCAssembler.h"
11#include "llvm/MC/MCContext.h"
12#include "llvm/MC/MCExpr.h"
13#include "llvm/MC/MCSymbol.h"
14#include "llvm/MC/MCValue.h"
15namespace llvm {
16class MCSection;
17}
18
19using namespace llvm;
20
21MCObjectWriter::~MCObjectWriter() = default;
22
23MCContext &MCObjectWriter::getContext() const { return Asm->getContext(); }
24
25void MCObjectWriter::reset() {
26 FileNames.clear();
27 AddrsigSyms.clear();
28 EmitAddrsigSection = false;
29 SubsectionsViaSymbols = false;
30 CGProfile.clear();
31}
32
33void MCObjectWriter::recordRelocation(const MCFragment &F, const MCFixup &Fixup,
34 MCValue Target, uint64_t &FixedValue) {}
35
36bool MCObjectWriter::isSymbolRefDifferenceFullyResolved(const MCSymbol &SA,
37 const MCSymbol &SB,
38 bool InSet) const {
39 assert(!SA.isUndefined() && !SB.isUndefined());
40 return isSymbolRefDifferenceFullyResolvedImpl(SymA: SA, FB: *SB.getFragment(), InSet,
41 /*IsPCRel=*/false);
42}
43
44bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
45 const MCSymbol &SymA, const MCFragment &FB, bool InSet,
46 bool IsPCRel) const {
47 const MCSection &SecA = SymA.getSection();
48 const MCSection &SecB = *FB.getParent();
49 // On ELF and COFF A - B is absolute if A and B are in the same section.
50 return &SecA == &SecB;
51}
52
53void MCObjectWriter::addFileName(StringRef FileName) {
54 FileNames.emplace_back(Args: std::string(FileName), Args: Asm->Symbols.size());
55}
56
57MCContext &MCObjectTargetWriter::getContext() const {
58 return Asm->getContext();
59}
60
61void MCObjectTargetWriter::reportError(SMLoc L, const Twine &Msg) const {
62 return Asm->getContext().reportError(L, Msg);
63}
64