2020-04-03 02:54:05 +08:00
|
|
|
//===- Symbols.cpp --------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Symbols.h"
|
|
|
|
#include "InputFiles.h"
|
2020-07-31 05:28:41 +08:00
|
|
|
#include "SyntheticSections.h"
|
2020-04-03 02:54:05 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace lld;
|
|
|
|
using namespace lld::macho;
|
|
|
|
|
2020-09-18 23:40:46 +08:00
|
|
|
uint64_t Defined::getVA() const {
|
|
|
|
if (isAbsolute())
|
|
|
|
return value;
|
|
|
|
return isec->getVA() + value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t Defined::getFileOffset() const {
|
|
|
|
if (isAbsolute()) {
|
|
|
|
error("absolute symbol " + toString(*this) +
|
|
|
|
" does not have a file offset");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return isec->getFileOffset() + value;
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:43:51 +08:00
|
|
|
void LazySymbol::fetchArchiveMember() { file->fetch(sym); }
|
|
|
|
|
2020-04-03 02:54:05 +08:00
|
|
|
// Returns a symbol for an error message.
|
|
|
|
std::string lld::toString(const Symbol &sym) {
|
|
|
|
if (Optional<std::string> s = demangleItanium(sym.getName()))
|
|
|
|
return *s;
|
|
|
|
return std::string(sym.getName());
|
|
|
|
}
|
2020-07-31 05:28:41 +08:00
|
|
|
|
|
|
|
uint64_t DSOHandle::getVA() const { return header->addr; }
|
|
|
|
|
|
|
|
uint64_t DSOHandle::getFileOffset() const { return header->fileOff; }
|
|
|
|
|
|
|
|
constexpr StringRef DSOHandle::name;
|