Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 1 | //===- Symbols.cpp --------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Linker |
| 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 "Symbols.h" |
Rafael Espindola | 49a2ca6 | 2015-08-06 15:33:19 +0000 | [diff] [blame] | 11 | #include "Error.h" |
Michael J. Spencer | cdae0a4 | 2015-07-28 22:58:25 +0000 | [diff] [blame] | 12 | #include "InputFiles.h" |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 13 | #include "InputSection.h" |
| 14 | #include "OutputSections.h" |
| 15 | #include "Target.h" |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 16 | |
Michael J. Spencer | 1b348a6 | 2015-09-04 22:28:10 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Rui Ueyama | a4a628f | 2016-01-13 18:55:39 +0000 | [diff] [blame] | 18 | #include "llvm/Config/config.h" |
| 19 | |
| 20 | #ifdef HAVE_CXXABI_H |
| 21 | #include <cxxabi.h> |
| 22 | #endif |
Michael J. Spencer | 1b348a6 | 2015-09-04 22:28:10 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace llvm; |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 25 | using namespace llvm::object; |
Rafael Espindola | 78471f0 | 2015-09-01 23:12:52 +0000 | [diff] [blame] | 26 | using namespace llvm::ELF; |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 27 | |
| 28 | using namespace lld; |
Rafael Espindola | e0df00b | 2016-02-28 00:25:54 +0000 | [diff] [blame] | 29 | using namespace lld::elf; |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 30 | |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 31 | template <class ELFT> |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 32 | static typename ELFFile<ELFT>::uintX_t |
| 33 | getSymVA(const SymbolBody &Body, typename ELFFile<ELFT>::uintX_t &Addend) { |
| 34 | typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym; |
| 35 | typedef typename ELFFile<ELFT>::uintX_t uintX_t; |
| 36 | |
| 37 | switch (Body.kind()) { |
| 38 | case SymbolBody::DefinedSyntheticKind: { |
| 39 | auto &D = cast<DefinedSynthetic<ELFT>>(Body); |
| 40 | return D.Section.getVA() + D.Value; |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 41 | } |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 42 | case SymbolBody::DefinedRegularKind: { |
| 43 | auto &D = cast<DefinedRegular<ELFT>>(Body); |
| 44 | InputSectionBase<ELFT> *SC = D.Section; |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 45 | |
| 46 | // This is an absolute symbol. |
| 47 | if (!SC) |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 48 | return D.Sym.st_value; |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 49 | |
Rafael Espindola | 1f5b70f | 2016-03-11 14:21:37 +0000 | [diff] [blame] | 50 | const Elf_Sym &Sym = D.Sym; |
| 51 | uintX_t Offset = Sym.st_value; |
| 52 | if (Sym.getType() == STT_SECTION) { |
| 53 | Offset += Addend; |
| 54 | Addend = 0; |
| 55 | } |
| 56 | uintX_t VA = SC->OutSec->getVA() + SC->getOffset(Offset); |
| 57 | if (Sym.getType() == STT_TLS) |
| 58 | return VA - Out<ELFT>::TlsPhdr->p_vaddr; |
| 59 | return VA; |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 60 | } |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 61 | case SymbolBody::DefinedCommonKind: |
| 62 | return Out<ELFT>::Bss->getVA() + cast<DefinedCommon>(Body).OffsetInBss; |
| 63 | case SymbolBody::SharedKind: { |
| 64 | auto &SS = cast<SharedSymbol<ELFT>>(Body); |
| 65 | if (!SS.NeedsCopyOrPltAddr) |
Rafael Espindola | a0a65f9 | 2016-02-09 15:11:01 +0000 | [diff] [blame] | 66 | return 0; |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 67 | if (SS.IsFunc) |
| 68 | return Body.getPltVA<ELFT>(); |
Rui Ueyama | 2df7289 | 2016-03-13 20:54:38 +0000 | [diff] [blame] | 69 | return Out<ELFT>::Bss->getVA() + SS.OffsetInBss; |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 70 | } |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 71 | case SymbolBody::UndefinedElfKind: |
| 72 | case SymbolBody::UndefinedKind: |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 73 | return 0; |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 74 | case SymbolBody::LazyKind: |
George Rimar | 777f963 | 2016-03-12 08:31:34 +0000 | [diff] [blame] | 75 | assert(Body.isUsedInRegularObj() && "lazy symbol reached writer"); |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 76 | return 0; |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 77 | case SymbolBody::DefinedBitcodeKind: |
George Rimar | 777f963 | 2016-03-12 08:31:34 +0000 | [diff] [blame] | 78 | llvm_unreachable("should have been replaced"); |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 79 | } |
George Rimar | 777f963 | 2016-03-12 08:31:34 +0000 | [diff] [blame] | 80 | llvm_unreachable("invalid symbol kind"); |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Rui Ueyama | c446660 | 2016-03-13 19:48:18 +0000 | [diff] [blame] | 83 | // Returns true if a symbol can be replaced at load-time by a symbol |
| 84 | // with the same name defined in other ELF executable or DSO. |
| 85 | bool SymbolBody::isPreemptible() const { |
| 86 | if (isLocal()) |
| 87 | return false; |
| 88 | |
| 89 | if (isShared()) |
| 90 | return true; |
| 91 | |
| 92 | if (isUndefined()) { |
| 93 | if (!isWeak()) |
| 94 | return true; |
| 95 | |
| 96 | // Ideally the static linker should see a definition for every symbol, but |
| 97 | // shared object are normally allowed to have undefined references that the |
| 98 | // static linker never sees a definition for. |
| 99 | if (Config->Shared) |
| 100 | return true; |
| 101 | |
| 102 | // Otherwise, just resolve to 0. |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | if (!Config->Shared) |
| 107 | return false; |
| 108 | if (getVisibility() != STV_DEFAULT) |
| 109 | return false; |
| 110 | if (Config->Bsymbolic || (Config->BsymbolicFunctions && IsFunc)) |
| 111 | return false; |
| 112 | return true; |
| 113 | } |
| 114 | |
Rui Ueyama | 7ede543 | 2016-03-13 04:40:14 +0000 | [diff] [blame] | 115 | template <class ELFT> bool SymbolBody::isGnuIfunc() const { |
| 116 | if (auto *D = dyn_cast<DefinedElf<ELFT>>(this)) |
| 117 | return D->Sym.getType() == STT_GNU_IFUNC; |
| 118 | return false; |
| 119 | } |
| 120 | |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 121 | template <class ELFT> |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 122 | typename ELFFile<ELFT>::uintX_t |
| 123 | SymbolBody::getVA(typename ELFFile<ELFT>::uintX_t Addend) const { |
| 124 | return getSymVA<ELFT>(*this, Addend) + Addend; |
| 125 | } |
| 126 | |
| 127 | template <class ELFT> |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 128 | typename ELFFile<ELFT>::uintX_t SymbolBody::getGotVA() const { |
| 129 | return Out<ELFT>::Got->getVA() + |
| 130 | (Out<ELFT>::Got->getMipsLocalEntriesNum() + GotIndex) * |
| 131 | sizeof(typename ELFFile<ELFT>::uintX_t); |
| 132 | } |
| 133 | |
| 134 | template <class ELFT> |
| 135 | typename ELFFile<ELFT>::uintX_t SymbolBody::getGotPltVA() const { |
| 136 | return Out<ELFT>::GotPlt->getVA() + |
| 137 | GotPltIndex * sizeof(typename ELFFile<ELFT>::uintX_t); |
| 138 | } |
| 139 | |
| 140 | template <class ELFT> |
| 141 | typename ELFFile<ELFT>::uintX_t SymbolBody::getPltVA() const { |
| 142 | return Out<ELFT>::Plt->getVA() + Target->PltZeroSize + |
| 143 | PltIndex * Target->PltEntrySize; |
| 144 | } |
| 145 | |
Rui Ueyama | 512c61d | 2016-02-03 00:12:24 +0000 | [diff] [blame] | 146 | template <class ELFT> |
| 147 | typename ELFFile<ELFT>::uintX_t SymbolBody::getSize() const { |
| 148 | if (auto *B = dyn_cast<DefinedElf<ELFT>>(this)) |
| 149 | return B->Sym.st_size; |
| 150 | return 0; |
| 151 | } |
| 152 | |
Rafael Espindola | 78471f0 | 2015-09-01 23:12:52 +0000 | [diff] [blame] | 153 | static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) { |
| 154 | if (VA == STV_DEFAULT) |
| 155 | return VB; |
| 156 | if (VB == STV_DEFAULT) |
| 157 | return VA; |
| 158 | return std::min(VA, VB); |
| 159 | } |
| 160 | |
George Rimar | 3498c7f | 2016-03-10 18:49:24 +0000 | [diff] [blame] | 161 | static int compareCommons(DefinedCommon *A, DefinedCommon *B) { |
George Rimar | 3435800 | 2016-03-14 09:19:30 +0000 | [diff] [blame^] | 162 | if (Config->WarnCommon) |
| 163 | warning("multiple common of " + A->getName()); |
Rui Ueyama | 17d6983 | 2016-03-10 18:58:53 +0000 | [diff] [blame] | 164 | A->Alignment = B->Alignment = std::max(A->Alignment, B->Alignment); |
George Rimar | 3498c7f | 2016-03-10 18:49:24 +0000 | [diff] [blame] | 165 | if (A->Size < B->Size) |
| 166 | return -1; |
| 167 | return 1; |
| 168 | } |
| 169 | |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 170 | // Returns 1, 0 or -1 if this symbol should take precedence |
| 171 | // over the Other, tie or lose, respectively. |
Rafael Espindola | daa92a6 | 2015-08-31 01:16:19 +0000 | [diff] [blame] | 172 | template <class ELFT> int SymbolBody::compare(SymbolBody *Other) { |
Michael J. Spencer | 1b348a6 | 2015-09-04 22:28:10 +0000 | [diff] [blame] | 173 | assert(!isLazy() && !Other->isLazy()); |
Rafael Espindola | 0bc0c02 | 2016-01-18 23:54:05 +0000 | [diff] [blame] | 174 | std::tuple<bool, bool, bool> L(isDefined(), !isShared(), !isWeak()); |
| 175 | std::tuple<bool, bool, bool> R(Other->isDefined(), !Other->isShared(), |
| 176 | !Other->isWeak()); |
Rui Ueyama | a7ccb29 | 2015-07-27 20:39:01 +0000 | [diff] [blame] | 177 | |
Rafael Espindola | 3a63f3f | 2015-08-28 20:19:34 +0000 | [diff] [blame] | 178 | // Normalize |
| 179 | if (L > R) |
Rafael Espindola | daa92a6 | 2015-08-31 01:16:19 +0000 | [diff] [blame] | 180 | return -Other->compare<ELFT>(this); |
Rui Ueyama | a7ccb29 | 2015-07-27 20:39:01 +0000 | [diff] [blame] | 181 | |
Rui Ueyama | 8f2c4da | 2015-10-21 18:13:47 +0000 | [diff] [blame] | 182 | Visibility = Other->Visibility = |
| 183 | getMinVisibility(Visibility, Other->Visibility); |
Rafael Espindola | 78471f0 | 2015-09-01 23:12:52 +0000 | [diff] [blame] | 184 | |
Rui Ueyama | 86696f3 | 2015-10-21 19:41:03 +0000 | [diff] [blame] | 185 | if (IsUsedInRegularObj || Other->IsUsedInRegularObj) |
| 186 | IsUsedInRegularObj = Other->IsUsedInRegularObj = true; |
Rafael Espindola | 18173d4 | 2015-09-08 15:50:05 +0000 | [diff] [blame] | 187 | |
George Rimar | 02ca179 | 2016-01-25 08:44:38 +0000 | [diff] [blame] | 188 | // We want to export all symbols that exist both in the executable |
| 189 | // and in DSOs, so that the symbols in the executable can interrupt |
| 190 | // symbols in the DSO at runtime. |
| 191 | if (isShared() != Other->isShared()) |
| 192 | if (isa<DefinedRegular<ELFT>>(isShared() ? Other : this)) |
Rafael Espindola | abebed9 | 2016-02-05 15:27:15 +0000 | [diff] [blame] | 193 | MustBeInDynSym = Other->MustBeInDynSym = true; |
George Rimar | 02ca179 | 2016-01-25 08:44:38 +0000 | [diff] [blame] | 194 | |
Rafael Espindola | 3a63f3f | 2015-08-28 20:19:34 +0000 | [diff] [blame] | 195 | if (L != R) |
| 196 | return -1; |
George Rimar | 3498c7f | 2016-03-10 18:49:24 +0000 | [diff] [blame] | 197 | if (!isDefined() || isShared() || isWeak()) |
Rafael Espindola | 8e5560d | 2015-09-23 14:23:59 +0000 | [diff] [blame] | 198 | return 1; |
George Rimar | 3498c7f | 2016-03-10 18:49:24 +0000 | [diff] [blame] | 199 | if (!isCommon() && !Other->isCommon()) |
| 200 | return 0; |
| 201 | if (isCommon() && Other->isCommon()) |
| 202 | return compareCommons(cast<DefinedCommon>(this), |
| 203 | cast<DefinedCommon>(Other)); |
George Rimar | 3435800 | 2016-03-14 09:19:30 +0000 | [diff] [blame^] | 204 | if (Config->WarnCommon) |
| 205 | warning("common " + this->getName() + " is overridden"); |
George Rimar | 3498c7f | 2016-03-10 18:49:24 +0000 | [diff] [blame] | 206 | return isCommon() ? -1 : 1; |
Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 +0000 | [diff] [blame] | 207 | } |
Rafael Espindola | daa92a6 | 2015-08-31 01:16:19 +0000 | [diff] [blame] | 208 | |
Rafael Espindola | 1f5b70f | 2016-03-11 14:21:37 +0000 | [diff] [blame] | 209 | Defined::Defined(Kind K, StringRef Name, bool IsWeak, bool IsLocal, |
| 210 | uint8_t Visibility, uint8_t Type) |
| 211 | : SymbolBody(K, Name, IsWeak, IsLocal, Visibility, Type) {} |
Rafael Espindola | 4d4b06a | 2015-12-24 00:47:42 +0000 | [diff] [blame] | 212 | |
Rafael Espindola | 4f29c1a | 2016-03-07 17:14:36 +0000 | [diff] [blame] | 213 | DefinedBitcode::DefinedBitcode(StringRef Name, bool IsWeak, uint8_t Visibility) |
Rafael Espindola | 1f5b70f | 2016-03-11 14:21:37 +0000 | [diff] [blame] | 214 | : Defined(DefinedBitcodeKind, Name, IsWeak, false, Visibility, |
| 215 | 0 /* Type */) {} |
Rafael Espindola | 9f77ef0 | 2016-02-12 20:54:57 +0000 | [diff] [blame] | 216 | |
| 217 | bool DefinedBitcode::classof(const SymbolBody *S) { |
| 218 | return S->kind() == DefinedBitcodeKind; |
| 219 | } |
| 220 | |
Rafael Espindola | 5d7593b | 2015-12-22 23:00:50 +0000 | [diff] [blame] | 221 | Undefined::Undefined(SymbolBody::Kind K, StringRef N, bool IsWeak, |
Davide Italiano | 255730c | 2016-03-04 01:55:28 +0000 | [diff] [blame] | 222 | uint8_t Visibility, uint8_t Type) |
Rafael Espindola | 1f5b70f | 2016-03-11 14:21:37 +0000 | [diff] [blame] | 223 | : SymbolBody(K, N, IsWeak, false, Visibility, Type), |
George Rimar | 5c36e59 | 2016-02-02 09:28:53 +0000 | [diff] [blame] | 224 | CanKeepUndefined(false) {} |
Rafael Espindola | 5d7593b | 2015-12-22 23:00:50 +0000 | [diff] [blame] | 225 | |
| 226 | Undefined::Undefined(StringRef N, bool IsWeak, uint8_t Visibility, |
| 227 | bool CanKeepUndefined) |
Davide Italiano | 255730c | 2016-03-04 01:55:28 +0000 | [diff] [blame] | 228 | : Undefined(SymbolBody::UndefinedKind, N, IsWeak, Visibility, 0 /* Type */) { |
Rafael Espindola | 5d7593b | 2015-12-22 23:00:50 +0000 | [diff] [blame] | 229 | this->CanKeepUndefined = CanKeepUndefined; |
| 230 | } |
| 231 | |
| 232 | template <typename ELFT> |
| 233 | UndefinedElf<ELFT>::UndefinedElf(StringRef N, const Elf_Sym &Sym) |
| 234 | : Undefined(SymbolBody::UndefinedElfKind, N, |
| 235 | Sym.getBinding() == llvm::ELF::STB_WEAK, Sym.getVisibility(), |
Davide Italiano | 255730c | 2016-03-04 01:55:28 +0000 | [diff] [blame] | 236 | Sym.getType()), |
Rafael Espindola | 5d7593b | 2015-12-22 23:00:50 +0000 | [diff] [blame] | 237 | Sym(Sym) {} |
| 238 | |
Rafael Espindola | 4d4b06a | 2015-12-24 00:47:42 +0000 | [diff] [blame] | 239 | template <typename ELFT> |
| 240 | DefinedSynthetic<ELFT>::DefinedSynthetic(StringRef N, uintX_t Value, |
George Rimar | aa4dc20 | 2016-03-01 16:23:13 +0000 | [diff] [blame] | 241 | OutputSectionBase<ELFT> &Section, |
| 242 | uint8_t Visibility) |
Rafael Espindola | 1f5b70f | 2016-03-11 14:21:37 +0000 | [diff] [blame] | 243 | : Defined(SymbolBody::DefinedSyntheticKind, N, false, false, Visibility, |
Davide Italiano | 255730c | 2016-03-04 01:55:28 +0000 | [diff] [blame] | 244 | 0 /* Type */), |
Rafael Espindola | 4d4b06a | 2015-12-24 00:47:42 +0000 | [diff] [blame] | 245 | Value(Value), Section(Section) {} |
| 246 | |
Rafael Espindola | 1119191 | 2015-12-24 16:23:37 +0000 | [diff] [blame] | 247 | DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, |
| 248 | bool IsWeak, uint8_t Visibility) |
Rafael Espindola | 1f5b70f | 2016-03-11 14:21:37 +0000 | [diff] [blame] | 249 | : Defined(SymbolBody::DefinedCommonKind, N, IsWeak, false, Visibility, |
Rui Ueyama | 17d6983 | 2016-03-10 18:58:53 +0000 | [diff] [blame] | 250 | 0 /* Type */), |
| 251 | Alignment(Alignment), Size(Size) {} |
Rafael Espindola | 1119191 | 2015-12-24 16:23:37 +0000 | [diff] [blame] | 252 | |
Michael J. Spencer | 1b348a6 | 2015-09-04 22:28:10 +0000 | [diff] [blame] | 253 | std::unique_ptr<InputFile> Lazy::getMember() { |
| 254 | MemoryBufferRef MBRef = File->getMember(&Sym); |
| 255 | |
| 256 | // getMember returns an empty buffer if the member was already |
| 257 | // read from the library. |
| 258 | if (MBRef.getBuffer().empty()) |
| 259 | return std::unique_ptr<InputFile>(nullptr); |
Rui Ueyama | 71c066d | 2016-02-02 08:22:41 +0000 | [diff] [blame] | 260 | return createObjectFile(MBRef, File->getName()); |
Michael J. Spencer | 1b348a6 | 2015-09-04 22:28:10 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Rui Ueyama | a4a628f | 2016-01-13 18:55:39 +0000 | [diff] [blame] | 263 | // Returns the demangled C++ symbol name for Name. |
Rafael Espindola | e0df00b | 2016-02-28 00:25:54 +0000 | [diff] [blame] | 264 | std::string elf::demangle(StringRef Name) { |
Rui Ueyama | a4a628f | 2016-01-13 18:55:39 +0000 | [diff] [blame] | 265 | #if !defined(HAVE_CXXABI_H) |
| 266 | return Name; |
| 267 | #else |
| 268 | if (!Config->Demangle) |
| 269 | return Name; |
Rui Ueyama | 5fa978b | 2016-01-13 19:40:13 +0000 | [diff] [blame] | 270 | |
Rui Ueyama | df15451 | 2016-01-13 22:09:09 +0000 | [diff] [blame] | 271 | // __cxa_demangle can be used to demangle strings other than symbol |
| 272 | // names which do not necessarily start with "_Z". Name can be |
| 273 | // either a C or C++ symbol. Don't call __cxa_demangle if the name |
| 274 | // does not look like a C++ symbol name to avoid getting unexpected |
| 275 | // result for a C symbol that happens to match a mangled type name. |
Rui Ueyama | 5fa978b | 2016-01-13 19:40:13 +0000 | [diff] [blame] | 276 | if (!Name.startswith("_Z")) |
| 277 | return Name; |
| 278 | |
Rui Ueyama | a4a628f | 2016-01-13 18:55:39 +0000 | [diff] [blame] | 279 | char *Buf = |
| 280 | abi::__cxa_demangle(Name.str().c_str(), nullptr, nullptr, nullptr); |
| 281 | if (!Buf) |
| 282 | return Name; |
| 283 | std::string S(Buf); |
| 284 | free(Buf); |
| 285 | return S; |
| 286 | #endif |
| 287 | } |
| 288 | |
Rui Ueyama | 7ede543 | 2016-03-13 04:40:14 +0000 | [diff] [blame] | 289 | template bool SymbolBody::template isGnuIfunc<ELF32LE>() const; |
| 290 | template bool SymbolBody::template isGnuIfunc<ELF32BE>() const; |
| 291 | template bool SymbolBody::template isGnuIfunc<ELF64LE>() const; |
| 292 | template bool SymbolBody::template isGnuIfunc<ELF64BE>() const; |
| 293 | |
Rafael Espindola | 87d9f10 | 2016-03-11 12:19:05 +0000 | [diff] [blame] | 294 | template uint32_t SymbolBody::template getVA<ELF32LE>(uint32_t) const; |
| 295 | template uint32_t SymbolBody::template getVA<ELF32BE>(uint32_t) const; |
| 296 | template uint64_t SymbolBody::template getVA<ELF64LE>(uint64_t) const; |
| 297 | template uint64_t SymbolBody::template getVA<ELF64BE>(uint64_t) const; |
Rui Ueyama | b5a6970 | 2016-02-01 21:00:35 +0000 | [diff] [blame] | 298 | |
| 299 | template uint32_t SymbolBody::template getGotVA<ELF32LE>() const; |
| 300 | template uint32_t SymbolBody::template getGotVA<ELF32BE>() const; |
| 301 | template uint64_t SymbolBody::template getGotVA<ELF64LE>() const; |
| 302 | template uint64_t SymbolBody::template getGotVA<ELF64BE>() const; |
| 303 | |
| 304 | template uint32_t SymbolBody::template getGotPltVA<ELF32LE>() const; |
| 305 | template uint32_t SymbolBody::template getGotPltVA<ELF32BE>() const; |
| 306 | template uint64_t SymbolBody::template getGotPltVA<ELF64LE>() const; |
| 307 | template uint64_t SymbolBody::template getGotPltVA<ELF64BE>() const; |
| 308 | |
| 309 | template uint32_t SymbolBody::template getPltVA<ELF32LE>() const; |
| 310 | template uint32_t SymbolBody::template getPltVA<ELF32BE>() const; |
| 311 | template uint64_t SymbolBody::template getPltVA<ELF64LE>() const; |
| 312 | template uint64_t SymbolBody::template getPltVA<ELF64BE>() const; |
| 313 | |
Rui Ueyama | 512c61d | 2016-02-03 00:12:24 +0000 | [diff] [blame] | 314 | template uint32_t SymbolBody::template getSize<ELF32LE>() const; |
| 315 | template uint32_t SymbolBody::template getSize<ELF32BE>() const; |
| 316 | template uint64_t SymbolBody::template getSize<ELF64LE>() const; |
| 317 | template uint64_t SymbolBody::template getSize<ELF64BE>() const; |
| 318 | |
Rafael Espindola | daa92a6 | 2015-08-31 01:16:19 +0000 | [diff] [blame] | 319 | template int SymbolBody::compare<ELF32LE>(SymbolBody *Other); |
| 320 | template int SymbolBody::compare<ELF32BE>(SymbolBody *Other); |
| 321 | template int SymbolBody::compare<ELF64LE>(SymbolBody *Other); |
| 322 | template int SymbolBody::compare<ELF64BE>(SymbolBody *Other); |
Rafael Espindola | 5d7593b | 2015-12-22 23:00:50 +0000 | [diff] [blame] | 323 | |
Rafael Espindola | e0df00b | 2016-02-28 00:25:54 +0000 | [diff] [blame] | 324 | template class elf::UndefinedElf<ELF32LE>; |
| 325 | template class elf::UndefinedElf<ELF32BE>; |
| 326 | template class elf::UndefinedElf<ELF64LE>; |
| 327 | template class elf::UndefinedElf<ELF64BE>; |
Rafael Espindola | 4d4b06a | 2015-12-24 00:47:42 +0000 | [diff] [blame] | 328 | |
Rafael Espindola | e0df00b | 2016-02-28 00:25:54 +0000 | [diff] [blame] | 329 | template class elf::DefinedSynthetic<ELF32LE>; |
| 330 | template class elf::DefinedSynthetic<ELF32BE>; |
| 331 | template class elf::DefinedSynthetic<ELF64LE>; |
| 332 | template class elf::DefinedSynthetic<ELF64BE>; |