1 //===- Symbols.cpp --------------------------------------------------------===// 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 "Symbols.h" 10 #include "InputFiles.h" 11 #include "SyntheticSections.h" 12 13 using namespace llvm; 14 using namespace lld; 15 using namespace lld::macho; 16 17 uint64_t Defined::getVA() const { 18 if (isAbsolute()) 19 return value; 20 return isec->getVA() + value; 21 } 22 23 uint64_t Defined::getFileOffset() const { 24 if (isAbsolute()) { 25 error("absolute symbol " + toString(*this) + 26 " does not have a file offset"); 27 return 0; 28 } 29 return isec->getFileOffset() + value; 30 } 31 32 void LazySymbol::fetchArchiveMember() { file->fetch(sym); } 33 34 // Returns a symbol for an error message. 35 std::string lld::toString(const Symbol &sym) { 36 if (config->demangle) 37 return demangleItanium(sym.getName()); 38 return std::string(sym.getName()); 39 } 40 41 uint64_t DSOHandle::getVA() const { return header->addr; } 42 43 uint64_t DSOHandle::getFileOffset() const { return header->fileOff; } 44 45 constexpr StringRef DSOHandle::name; 46