2018-01-23 15:10:24 -08:00
|
|
|
//===--- BinarySection.cpp - Interface for object file section -----------===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "BinarySection.h"
|
2018-02-01 16:33:43 -08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
|
|
|
|
|
|
#undef DEBUG_TYPE
|
|
|
|
|
#define DEBUG_TYPE "bolt"
|
2018-01-23 15:10:24 -08:00
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
using namespace bolt;
|
|
|
|
|
|
2018-02-01 16:33:43 -08:00
|
|
|
namespace opts {
|
|
|
|
|
extern cl::opt<bool> PrintRelocations;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BinarySection::~BinarySection() {
|
|
|
|
|
if (!isAllocatable() &&
|
|
|
|
|
(!hasSectionRef() ||
|
|
|
|
|
OutputContents.data() != getContents(Section).data())) {
|
|
|
|
|
delete[] getOutputData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BinarySection::print(raw_ostream &OS) const {
|
|
|
|
|
OS << getName() << ", "
|
|
|
|
|
<< "0x" << Twine::utohexstr(getAddress()) << ", "
|
|
|
|
|
<< getSize()
|
|
|
|
|
<< " (0x" << Twine::utohexstr(getFileAddress()) << ", "
|
|
|
|
|
<< getOutputSize() << ")"
|
|
|
|
|
<< ", data = " << getData()
|
|
|
|
|
<< ", output data = " << getOutputData();
|
|
|
|
|
|
|
|
|
|
if (isAllocatable())
|
|
|
|
|
OS << " (allocatable)";
|
|
|
|
|
|
2017-11-14 20:05:11 -08:00
|
|
|
if (isVirtual())
|
|
|
|
|
OS << " (virtual)";
|
|
|
|
|
|
|
|
|
|
if (isTLS())
|
|
|
|
|
OS << " (tls)";
|
|
|
|
|
|
2018-02-01 16:33:43 -08:00
|
|
|
if (opts::PrintRelocations) {
|
|
|
|
|
for (auto &R : relocations())
|
|
|
|
|
OS << "\n " << R;
|
|
|
|
|
}
|
|
|
|
|
}
|