blob: e6f8842b80d36dd3f1c44fb9dbd3d0b5f368cbce [file] [log] [blame]
Michael J. Spencer84487f12015-07-24 21:03:07 +00001//===- 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 Espindola49a2ca62015-08-06 15:33:19 +000011#include "Error.h"
Michael J. Spencercdae0a42015-07-28 22:58:25 +000012#include "InputFiles.h"
Rui Ueyamab5a69702016-02-01 21:00:35 +000013#include "InputSection.h"
14#include "OutputSections.h"
15#include "Target.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000016
Michael J. Spencer1b348a62015-09-04 22:28:10 +000017#include "llvm/ADT/STLExtras.h"
Rui Ueyamaa4a628f2016-01-13 18:55:39 +000018#include "llvm/Config/config.h"
19
20#ifdef HAVE_CXXABI_H
21#include <cxxabi.h>
22#endif
Michael J. Spencer1b348a62015-09-04 22:28:10 +000023
24using namespace llvm;
Michael J. Spencer84487f12015-07-24 21:03:07 +000025using namespace llvm::object;
Rafael Espindola78471f02015-09-01 23:12:52 +000026using namespace llvm::ELF;
Michael J. Spencer84487f12015-07-24 21:03:07 +000027
28using namespace lld;
Rafael Espindolae0df00b2016-02-28 00:25:54 +000029using namespace lld::elf;
Michael J. Spencer84487f12015-07-24 21:03:07 +000030
Rui Ueyamab5a69702016-02-01 21:00:35 +000031template <class ELFT>
Rui Ueyama9328b2c2016-03-14 23:16:09 +000032static typename ELFT::uint getSymVA(const SymbolBody &Body,
33 typename ELFT::uint &Addend) {
Rui Ueyama9328b2c2016-03-14 23:16:09 +000034 typedef typename ELFT::uint uintX_t;
Rafael Espindola87d9f102016-03-11 12:19:05 +000035
36 switch (Body.kind()) {
37 case SymbolBody::DefinedSyntheticKind: {
38 auto &D = cast<DefinedSynthetic<ELFT>>(Body);
Simon Atanasyan13f6da12016-03-31 21:26:23 +000039 if (D.Value == DefinedSynthetic<ELFT>::SectionEnd)
40 return D.Section.getVA() + D.Section.getSize();
Rafael Espindola87d9f102016-03-11 12:19:05 +000041 return D.Section.getVA() + D.Value;
Rui Ueyamab5a69702016-02-01 21:00:35 +000042 }
Rafael Espindola87d9f102016-03-11 12:19:05 +000043 case SymbolBody::DefinedRegularKind: {
44 auto &D = cast<DefinedRegular<ELFT>>(Body);
45 InputSectionBase<ELFT> *SC = D.Section;
Rui Ueyamab5a69702016-02-01 21:00:35 +000046
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +000047 // According to the ELF spec reference to a local symbol from outside
48 // the group are not allowed. Unfortunately .eh_frame breaks that rule
49 // and must be treated specially. For now we just replace the symbol with
50 // 0.
51 if (SC == &InputSection<ELFT>::Discarded)
52 return 0;
53
Rui Ueyamab5a69702016-02-01 21:00:35 +000054 // This is an absolute symbol.
55 if (!SC)
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +000056 return D.Value;
Rui Ueyamab5a69702016-02-01 21:00:35 +000057
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +000058 uintX_t Offset = D.Value;
59 if (D.isSection()) {
Rafael Espindola1f5b70f2016-03-11 14:21:37 +000060 Offset += Addend;
61 Addend = 0;
62 }
63 uintX_t VA = SC->OutSec->getVA() + SC->getOffset(Offset);
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +000064 if (D.isTls())
Rafael Espindola1f5b70f2016-03-11 14:21:37 +000065 return VA - Out<ELFT>::TlsPhdr->p_vaddr;
66 return VA;
Rui Ueyamab5a69702016-02-01 21:00:35 +000067 }
Rafael Espindola87d9f102016-03-11 12:19:05 +000068 case SymbolBody::DefinedCommonKind:
69 return Out<ELFT>::Bss->getVA() + cast<DefinedCommon>(Body).OffsetInBss;
70 case SymbolBody::SharedKind: {
71 auto &SS = cast<SharedSymbol<ELFT>>(Body);
72 if (!SS.NeedsCopyOrPltAddr)
Rafael Espindolaa0a65f92016-02-09 15:11:01 +000073 return 0;
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +000074 if (SS.isFunc())
Rafael Espindola87d9f102016-03-11 12:19:05 +000075 return Body.getPltVA<ELFT>();
Rui Ueyama2df72892016-03-13 20:54:38 +000076 return Out<ELFT>::Bss->getVA() + SS.OffsetInBss;
Rui Ueyamab5a69702016-02-01 21:00:35 +000077 }
Rafael Espindola87d9f102016-03-11 12:19:05 +000078 case SymbolBody::UndefinedElfKind:
Rafael Espindolaf4765732016-04-06 13:22:41 +000079 case SymbolBody::UndefinedBitcodeKind:
Rui Ueyamab5a69702016-02-01 21:00:35 +000080 return 0;
Rui Ueyamaf8baa662016-04-07 19:24:51 +000081 case SymbolBody::LazyArchiveKind:
82 case SymbolBody::LazyObjectKind:
George Rimar777f9632016-03-12 08:31:34 +000083 assert(Body.isUsedInRegularObj() && "lazy symbol reached writer");
Rui Ueyamab5a69702016-02-01 21:00:35 +000084 return 0;
Rafael Espindola87d9f102016-03-11 12:19:05 +000085 case SymbolBody::DefinedBitcodeKind:
Davide Italianof6523ae2016-03-29 02:20:10 +000086 llvm_unreachable("should have been replaced");
Rui Ueyamab5a69702016-02-01 21:00:35 +000087 }
George Rimar777f9632016-03-12 08:31:34 +000088 llvm_unreachable("invalid symbol kind");
Rui Ueyamab5a69702016-02-01 21:00:35 +000089}
90
Rui Ueyamab5792b22016-04-04 19:09:08 +000091SymbolBody::SymbolBody(Kind K, uint32_t NameOffset, uint8_t StOther,
92 uint8_t Type)
Rafael Espindola5e345682016-04-06 14:31:03 +000093 : SymbolKind(K), Type(Type), Binding(STB_LOCAL), StOther(StOther),
94 NameOffset(NameOffset) {
Rafael Espindolaf4765732016-04-06 13:22:41 +000095 init();
96}
97
98SymbolBody::SymbolBody(Kind K, StringRef Name, uint8_t Binding, uint8_t StOther,
99 uint8_t Type)
Rafael Espindola5e345682016-04-06 14:31:03 +0000100 : SymbolKind(K), Type(Type), Binding(Binding), StOther(StOther),
Rafael Espindolaf4765732016-04-06 13:22:41 +0000101 Name({Name.data(), Name.size()}) {
102 assert(!isLocal());
103 init();
104}
105
106void SymbolBody::init() {
107 Kind K = kind();
108 IsUsedInRegularObj = K == DefinedRegularKind || K == DefinedCommonKind ||
109 K == DefinedSyntheticKind || K == UndefinedElfKind;
Rafael Espindola5e345682016-04-06 14:31:03 +0000110 CanKeepUndefined = false;
111 MustBeInDynSym = false;
Rafael Espindola4d480ed2016-04-21 21:44:25 +0000112 CanOmitFromDynSym = false;
Rafael Espindola5e345682016-04-06 14:31:03 +0000113 NeedsCopyOrPltAddr = false;
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000114}
115
Rui Ueyamac4466602016-03-13 19:48:18 +0000116// Returns true if a symbol can be replaced at load-time by a symbol
117// with the same name defined in other ELF executable or DSO.
118bool SymbolBody::isPreemptible() const {
119 if (isLocal())
120 return false;
121
122 if (isShared())
123 return true;
124
Rafael Espindola36660252016-04-15 11:57:07 +0000125 if (getVisibility() != STV_DEFAULT)
126 return false;
127
Rui Ueyamac4466602016-03-13 19:48:18 +0000128 if (isUndefined()) {
129 if (!isWeak())
130 return true;
131
132 // Ideally the static linker should see a definition for every symbol, but
133 // shared object are normally allowed to have undefined references that the
134 // static linker never sees a definition for.
135 if (Config->Shared)
136 return true;
137
138 // Otherwise, just resolve to 0.
139 return false;
140 }
141
142 if (!Config->Shared)
143 return false;
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000144 if (Config->Bsymbolic || (Config->BsymbolicFunctions && isFunc()))
Rui Ueyamac4466602016-03-13 19:48:18 +0000145 return false;
146 return true;
147}
148
Rui Ueyamab5a69702016-02-01 21:00:35 +0000149template <class ELFT>
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000150typename ELFT::uint SymbolBody::getVA(typename ELFT::uint Addend) const {
Rafael Espindola8381c562016-03-17 23:36:19 +0000151 typename ELFT::uint OutVA = getSymVA<ELFT>(*this, Addend);
152 return OutVA + Addend;
Rafael Espindola87d9f102016-03-11 12:19:05 +0000153}
154
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000155template <class ELFT> typename ELFT::uint SymbolBody::getGotVA() const {
Rafael Espindola74031ba2016-04-07 15:20:56 +0000156 return Out<ELFT>::Got->getVA() + getGotOffset<ELFT>();
157}
158
159template <class ELFT> typename ELFT::uint SymbolBody::getGotOffset() const {
160 return (Out<ELFT>::Got->getMipsLocalEntriesNum() + GotIndex) *
161 sizeof(typename ELFT::uint);
Rui Ueyamab5a69702016-02-01 21:00:35 +0000162}
163
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000164template <class ELFT> typename ELFT::uint SymbolBody::getGotPltVA() const {
Rafael Espindola74031ba2016-04-07 15:20:56 +0000165 return Out<ELFT>::GotPlt->getVA() + getGotPltOffset<ELFT>();
166}
167
168template <class ELFT> typename ELFT::uint SymbolBody::getGotPltOffset() const {
169 return GotPltIndex * sizeof(typename ELFT::uint);
Rui Ueyamab5a69702016-02-01 21:00:35 +0000170}
171
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000172template <class ELFT> typename ELFT::uint SymbolBody::getPltVA() const {
Rui Ueyamab5a69702016-02-01 21:00:35 +0000173 return Out<ELFT>::Plt->getVA() + Target->PltZeroSize +
174 PltIndex * Target->PltEntrySize;
175}
176
Simon Atanasyan13f6da12016-03-31 21:26:23 +0000177template <class ELFT> typename ELFT::uint SymbolBody::getThunkVA() const {
178 auto *D = cast<DefinedRegular<ELFT>>(this);
179 auto *S = cast<InputSection<ELFT>>(D->Section);
180 return S->OutSec->getVA() + S->OutSecOff + S->getThunkOff() +
181 ThunkIndex * Target->ThunkSize;
182}
183
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000184template <class ELFT> typename ELFT::uint SymbolBody::getSize() const {
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000185 if (const auto *C = dyn_cast<DefinedCommon>(this))
186 return C->Size;
187 if (const auto *DR = dyn_cast<DefinedRegular<ELFT>>(this))
188 return DR->Size;
189 if (const auto *S = dyn_cast<SharedSymbol<ELFT>>(this))
190 return S->Sym.st_size;
191 if (const auto *U = dyn_cast<UndefinedElf<ELFT>>(this))
192 return U->Size;
Rui Ueyama512c61d2016-02-03 00:12:24 +0000193 return 0;
194}
195
Rafael Espindola78471f02015-09-01 23:12:52 +0000196static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {
197 if (VA == STV_DEFAULT)
198 return VB;
199 if (VB == STV_DEFAULT)
200 return VA;
201 return std::min(VA, VB);
202}
203
George Rimar3498c7f2016-03-10 18:49:24 +0000204static int compareCommons(DefinedCommon *A, DefinedCommon *B) {
George Rimar34358002016-03-14 09:19:30 +0000205 if (Config->WarnCommon)
206 warning("multiple common of " + A->getName());
Rui Ueyama17d69832016-03-10 18:58:53 +0000207 A->Alignment = B->Alignment = std::max(A->Alignment, B->Alignment);
Davide Italiano901de032016-03-21 22:44:24 +0000208 return A->Size < B->Size ? -1 : 1;
George Rimar3498c7f2016-03-10 18:49:24 +0000209}
210
Michael J. Spencer84487f12015-07-24 21:03:07 +0000211// Returns 1, 0 or -1 if this symbol should take precedence
212// over the Other, tie or lose, respectively.
Peter Collingbourned0856a62016-04-05 00:47:58 +0000213int SymbolBody::compare(SymbolBody *Other) {
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000214 assert(!isLazy() && !Other->isLazy());
Rafael Espindola0bc0c022016-01-18 23:54:05 +0000215 std::tuple<bool, bool, bool> L(isDefined(), !isShared(), !isWeak());
216 std::tuple<bool, bool, bool> R(Other->isDefined(), !Other->isShared(),
217 !Other->isWeak());
Rui Ueyamaa7ccb292015-07-27 20:39:01 +0000218
Rafael Espindola3a63f3f2015-08-28 20:19:34 +0000219 // Normalize
220 if (L > R)
Peter Collingbourned0856a62016-04-05 00:47:58 +0000221 return -Other->compare(this);
Rui Ueyamaa7ccb292015-07-27 20:39:01 +0000222
Rafael Espindolaf9d3dcf2016-04-13 19:03:34 +0000223 uint8_t V = getMinVisibility(getVisibility(), Other->getVisibility());
Rafael Espindola8caf33c2016-04-08 18:39:03 +0000224 if (isShared() != Other->isShared()) {
225 SymbolBody *Shared = isShared() ? this : Other;
226 Shared->MustBeInDynSym = true;
Rafael Espindolaf9d3dcf2016-04-13 19:03:34 +0000227 if (Shared->getVisibility() == STV_DEFAULT &&
228 (V == STV_DEFAULT || V == STV_PROTECTED)) {
Rafael Espindola8caf33c2016-04-08 18:39:03 +0000229 // We want to export all symbols that exist in the executable and are
230 // preemptable in DSOs, so that the symbols in the executable can
231 // preempt symbols in the DSO at runtime.
232 SymbolBody *NonShared = isShared() ? Other : this;
233 NonShared->MustBeInDynSym = true;
234 }
235 }
236
Rafael Espindolaa15fb152016-04-08 16:11:42 +0000237 if (!isShared() && !Other->isShared()) {
Rafael Espindolaa15fb152016-04-08 16:11:42 +0000238 setVisibility(V);
239 Other->setVisibility(V);
240 }
Rafael Espindola78471f02015-09-01 23:12:52 +0000241
Rui Ueyama86696f32015-10-21 19:41:03 +0000242 if (IsUsedInRegularObj || Other->IsUsedInRegularObj)
243 IsUsedInRegularObj = Other->IsUsedInRegularObj = true;
Rafael Espindola18173d42015-09-08 15:50:05 +0000244
Rafael Espindola4d480ed2016-04-21 21:44:25 +0000245 if (!CanOmitFromDynSym || !Other->CanOmitFromDynSym)
246 CanOmitFromDynSym = Other->CanOmitFromDynSym = false;
247
Rafael Espindola3a63f3f2015-08-28 20:19:34 +0000248 if (L != R)
249 return -1;
George Rimar3498c7f2016-03-10 18:49:24 +0000250 if (!isDefined() || isShared() || isWeak())
Rafael Espindola8e5560d2015-09-23 14:23:59 +0000251 return 1;
George Rimar3498c7f2016-03-10 18:49:24 +0000252 if (!isCommon() && !Other->isCommon())
253 return 0;
254 if (isCommon() && Other->isCommon())
255 return compareCommons(cast<DefinedCommon>(this),
256 cast<DefinedCommon>(Other));
George Rimar34358002016-03-14 09:19:30 +0000257 if (Config->WarnCommon)
258 warning("common " + this->getName() + " is overridden");
George Rimar3498c7f2016-03-10 18:49:24 +0000259 return isCommon() ? -1 : 1;
Michael J. Spencer84487f12015-07-24 21:03:07 +0000260}
Rafael Espindoladaa92a62015-08-31 01:16:19 +0000261
Rafael Espindolaf9b79a42016-04-06 12:14:31 +0000262Defined::Defined(Kind K, StringRef Name, uint8_t Binding, uint8_t StOther,
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000263 uint8_t Type)
Rafael Espindolaf9b79a42016-04-06 12:14:31 +0000264 : SymbolBody(K, Name, Binding, StOther, Type) {}
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000265
Rafael Espindolaf9b79a42016-04-06 12:14:31 +0000266Defined::Defined(Kind K, uint32_t NameOffset, uint8_t StOther, uint8_t Type)
267 : SymbolBody(K, NameOffset, StOther, Type) {}
Rafael Espindola4d4b06a2015-12-24 00:47:42 +0000268
Rafael Espindolaf9b79a42016-04-06 12:14:31 +0000269DefinedBitcode::DefinedBitcode(StringRef Name, bool IsWeak, uint8_t StOther)
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000270 : Defined(DefinedBitcodeKind, Name, IsWeak ? STB_WEAK : STB_GLOBAL,
Rafael Espindolaf9b79a42016-04-06 12:14:31 +0000271 StOther, 0 /* Type */) {}
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000272
273bool DefinedBitcode::classof(const SymbolBody *S) {
274 return S->kind() == DefinedBitcodeKind;
275}
276
Rafael Espindolaf4765732016-04-06 13:22:41 +0000277UndefinedBitcode::UndefinedBitcode(StringRef N, bool IsWeak, uint8_t StOther)
278 : SymbolBody(SymbolBody::UndefinedBitcodeKind, N,
279 IsWeak ? STB_WEAK : STB_GLOBAL, StOther, 0 /* Type */) {}
Rafael Espindola5d7593b2015-12-22 23:00:50 +0000280
281template <typename ELFT>
282UndefinedElf<ELFT>::UndefinedElf(StringRef N, const Elf_Sym &Sym)
Rafael Espindolaf4765732016-04-06 13:22:41 +0000283 : SymbolBody(SymbolBody::UndefinedElfKind, N, Sym.getBinding(),
284 Sym.st_other, Sym.getType()),
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000285 Size(Sym.st_size) {}
286
287template <typename ELFT>
Rafael Espindolaf4765732016-04-06 13:22:41 +0000288UndefinedElf<ELFT>::UndefinedElf(StringRef Name, uint8_t Binding,
289 uint8_t StOther, uint8_t Type,
290 bool CanKeepUndefined)
Rafael Espindola5e345682016-04-06 14:31:03 +0000291 : SymbolBody(SymbolBody::UndefinedElfKind, Name, Binding, StOther, Type) {
292 this->CanKeepUndefined = CanKeepUndefined;
293}
Rafael Espindolaf4765732016-04-06 13:22:41 +0000294
295template <typename ELFT>
Rafael Espindolad9a17172016-04-05 11:47:46 +0000296UndefinedElf<ELFT>::UndefinedElf(const Elf_Sym &Sym)
Rafael Espindolaf4765732016-04-06 13:22:41 +0000297 : SymbolBody(SymbolBody::UndefinedElfKind, Sym.st_name, Sym.st_other,
298 Sym.getType()),
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000299 Size(Sym.st_size) {
300 assert(Sym.getBinding() == STB_LOCAL);
301}
Rafael Espindola5d7593b2015-12-22 23:00:50 +0000302
Rafael Espindola4d4b06a2015-12-24 00:47:42 +0000303template <typename ELFT>
304DefinedSynthetic<ELFT>::DefinedSynthetic(StringRef N, uintX_t Value,
Peter Collingbournef6e9b4e2016-04-13 16:57:28 +0000305 OutputSectionBase<ELFT> &Section)
306 : Defined(SymbolBody::DefinedSyntheticKind, N, STB_GLOBAL, STV_HIDDEN,
Davide Italiano255730c2016-03-04 01:55:28 +0000307 0 /* Type */),
Rafael Espindola4d4b06a2015-12-24 00:47:42 +0000308 Value(Value), Section(Section) {}
309
Rafael Espindola11191912015-12-24 16:23:37 +0000310DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment,
Rafael Espindolaf9b79a42016-04-06 12:14:31 +0000311 uint8_t Binding, uint8_t StOther, uint8_t Type)
312 : Defined(SymbolBody::DefinedCommonKind, N, Binding, StOther, Type),
Rui Ueyama17d69832016-03-10 18:58:53 +0000313 Alignment(Alignment), Size(Size) {}
Rafael Espindola11191912015-12-24 16:23:37 +0000314
Rui Ueyamaf8baa662016-04-07 19:24:51 +0000315std::unique_ptr<InputFile> Lazy::getFile() {
316 if (auto *S = dyn_cast<LazyArchive>(this))
317 return S->getFile();
318 return cast<LazyObject>(this)->getFile();
319}
320
321std::unique_ptr<InputFile> LazyArchive::getFile() {
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000322 MemoryBufferRef MBRef = File->getMember(&Sym);
323
324 // getMember returns an empty buffer if the member was already
325 // read from the library.
326 if (MBRef.getBuffer().empty())
327 return std::unique_ptr<InputFile>(nullptr);
Rui Ueyama71c066d2016-02-02 08:22:41 +0000328 return createObjectFile(MBRef, File->getName());
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000329}
330
Rui Ueyamaf8baa662016-04-07 19:24:51 +0000331std::unique_ptr<InputFile> LazyObject::getFile() {
332 return createObjectFile(MBRef);
333}
334
Rui Ueyamaa4a628f2016-01-13 18:55:39 +0000335// Returns the demangled C++ symbol name for Name.
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000336std::string elf::demangle(StringRef Name) {
Rui Ueyamaa4a628f2016-01-13 18:55:39 +0000337#if !defined(HAVE_CXXABI_H)
338 return Name;
339#else
340 if (!Config->Demangle)
341 return Name;
Rui Ueyama5fa978b2016-01-13 19:40:13 +0000342
Rui Ueyamadf154512016-01-13 22:09:09 +0000343 // __cxa_demangle can be used to demangle strings other than symbol
344 // names which do not necessarily start with "_Z". Name can be
345 // either a C or C++ symbol. Don't call __cxa_demangle if the name
346 // does not look like a C++ symbol name to avoid getting unexpected
347 // result for a C symbol that happens to match a mangled type name.
Rui Ueyama5fa978b2016-01-13 19:40:13 +0000348 if (!Name.startswith("_Z"))
349 return Name;
350
Rui Ueyamaa4a628f2016-01-13 18:55:39 +0000351 char *Buf =
352 abi::__cxa_demangle(Name.str().c_str(), nullptr, nullptr, nullptr);
353 if (!Buf)
354 return Name;
355 std::string S(Buf);
356 free(Buf);
357 return S;
358#endif
359}
360
Rafael Espindolaae605c12016-04-21 20:35:25 +0000361bool SymbolBody::includeInDynsym() const {
362 if (MustBeInDynSym)
363 return true;
364 uint8_t V = getVisibility();
365 if (V != STV_DEFAULT && V != STV_PROTECTED)
366 return false;
Rafael Espindola4d480ed2016-04-21 21:44:25 +0000367 if (!Config->ExportDynamic && !Config->Shared)
368 return false;
369 return !CanOmitFromDynSym;
Rafael Espindolaae605c12016-04-21 20:35:25 +0000370}
371
Rafael Espindola87d9f102016-03-11 12:19:05 +0000372template uint32_t SymbolBody::template getVA<ELF32LE>(uint32_t) const;
373template uint32_t SymbolBody::template getVA<ELF32BE>(uint32_t) const;
374template uint64_t SymbolBody::template getVA<ELF64LE>(uint64_t) const;
375template uint64_t SymbolBody::template getVA<ELF64BE>(uint64_t) const;
Rui Ueyamab5a69702016-02-01 21:00:35 +0000376
377template uint32_t SymbolBody::template getGotVA<ELF32LE>() const;
378template uint32_t SymbolBody::template getGotVA<ELF32BE>() const;
379template uint64_t SymbolBody::template getGotVA<ELF64LE>() const;
380template uint64_t SymbolBody::template getGotVA<ELF64BE>() const;
381
Rafael Espindola74031ba2016-04-07 15:20:56 +0000382template uint32_t SymbolBody::template getGotOffset<ELF32LE>() const;
383template uint32_t SymbolBody::template getGotOffset<ELF32BE>() const;
384template uint64_t SymbolBody::template getGotOffset<ELF64LE>() const;
385template uint64_t SymbolBody::template getGotOffset<ELF64BE>() const;
386
Rui Ueyamab5a69702016-02-01 21:00:35 +0000387template uint32_t SymbolBody::template getGotPltVA<ELF32LE>() const;
388template uint32_t SymbolBody::template getGotPltVA<ELF32BE>() const;
389template uint64_t SymbolBody::template getGotPltVA<ELF64LE>() const;
390template uint64_t SymbolBody::template getGotPltVA<ELF64BE>() const;
391
Rafael Espindola74031ba2016-04-07 15:20:56 +0000392template uint32_t SymbolBody::template getGotPltOffset<ELF32LE>() const;
393template uint32_t SymbolBody::template getGotPltOffset<ELF32BE>() const;
394template uint64_t SymbolBody::template getGotPltOffset<ELF64LE>() const;
395template uint64_t SymbolBody::template getGotPltOffset<ELF64BE>() const;
396
Rui Ueyamab5a69702016-02-01 21:00:35 +0000397template uint32_t SymbolBody::template getPltVA<ELF32LE>() const;
398template uint32_t SymbolBody::template getPltVA<ELF32BE>() const;
399template uint64_t SymbolBody::template getPltVA<ELF64LE>() const;
400template uint64_t SymbolBody::template getPltVA<ELF64BE>() const;
401
Rui Ueyama512c61d2016-02-03 00:12:24 +0000402template uint32_t SymbolBody::template getSize<ELF32LE>() const;
403template uint32_t SymbolBody::template getSize<ELF32BE>() const;
404template uint64_t SymbolBody::template getSize<ELF64LE>() const;
405template uint64_t SymbolBody::template getSize<ELF64BE>() const;
406
Simon Atanasyan13f6da12016-03-31 21:26:23 +0000407template uint32_t SymbolBody::template getThunkVA<ELF32LE>() const;
408template uint32_t SymbolBody::template getThunkVA<ELF32BE>() const;
409template uint64_t SymbolBody::template getThunkVA<ELF64LE>() const;
410template uint64_t SymbolBody::template getThunkVA<ELF64BE>() const;
411
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000412template class elf::UndefinedElf<ELF32LE>;
413template class elf::UndefinedElf<ELF32BE>;
414template class elf::UndefinedElf<ELF64LE>;
415template class elf::UndefinedElf<ELF64BE>;
Rafael Espindola4d4b06a2015-12-24 00:47:42 +0000416
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000417template class elf::DefinedSynthetic<ELF32LE>;
418template class elf::DefinedSynthetic<ELF32BE>;
419template class elf::DefinedSynthetic<ELF64LE>;
420template class elf::DefinedSynthetic<ELF64BE>;