Michael J. Spencer | 84487f1 | 2015-07-24 21:03:07 | [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" |
| 11 | #include "Chunks.h" |
| 12 | |
| 13 | using namespace llvm::object; |
| 14 | |
| 15 | using namespace lld; |
| 16 | using namespace lld::elf2; |
| 17 | |
| 18 | template <class ELFT> |
| 19 | DefinedRegular<ELFT>::DefinedRegular(StringRef Name) |
| 20 | : Defined(DefinedRegularKind), Name(Name) {} |
| 21 | |
| 22 | // Returns 1, 0 or -1 if this symbol should take precedence |
| 23 | // over the Other, tie or lose, respectively. |
| 24 | template <class ELFT> int DefinedRegular<ELFT>::compare(SymbolBody *Other) { |
| 25 | if (Other->kind() < kind()) |
| 26 | return -Other->compare(this); |
| 27 | auto *R = dyn_cast<DefinedRegular>(Other); |
| 28 | if (!R) |
| 29 | return 1; |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | int Defined::compare(SymbolBody *Other) { |
| 35 | if (Other->kind() < kind()) |
| 36 | return -Other->compare(this); |
| 37 | if (isa<Defined>(Other)) |
| 38 | return 0; |
| 39 | return 1; |
| 40 | } |
| 41 | |
| 42 | int Undefined::compare(SymbolBody *Other) { |
| 43 | if (Other->kind() < kind()) |
| 44 | return -Other->compare(this); |
| 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | template <class ELFT> StringRef DefinedRegular<ELFT>::getName() { return Name; } |
| 49 | |
| 50 | namespace lld { |
| 51 | namespace elf2 { |
| 52 | template class DefinedRegular<llvm::object::ELF32LE>; |
| 53 | template class DefinedRegular<llvm::object::ELF32BE>; |
| 54 | template class DefinedRegular<llvm::object::ELF64LE>; |
| 55 | template class DefinedRegular<llvm::object::ELF64BE>; |
| 56 | } |
| 57 | } |