Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 1 | //===- OutputSections.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 "OutputSections.h" |
| 11 | #include "Config.h" |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 12 | #include "SymbolTable.h" |
Rafael Espindola | 01205f7 | 2015-09-22 18:19:46 +0000 | [diff] [blame] | 13 | #include "Target.h" |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 14 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 15 | using namespace llvm; |
| 16 | using namespace llvm::object; |
| 17 | using namespace llvm::ELF; |
| 18 | |
| 19 | using namespace lld; |
| 20 | using namespace lld::elf2; |
| 21 | |
| 22 | template <bool Is64Bits> |
| 23 | OutputSectionBase<Is64Bits>::OutputSectionBase(StringRef Name, uint32_t sh_type, |
| 24 | uintX_t sh_flags) |
| 25 | : Name(Name) { |
| 26 | memset(&Header, 0, sizeof(HeaderT)); |
| 27 | Header.sh_type = sh_type; |
| 28 | Header.sh_flags = sh_flags; |
| 29 | } |
| 30 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 31 | template <class ELFT> |
| 32 | GotSection<ELFT>::GotSection() |
| 33 | : OutputSectionBase<ELFT::Is64Bits>(".got", llvm::ELF::SHT_PROGBITS, |
| 34 | llvm::ELF::SHF_ALLOC | |
| 35 | llvm::ELF::SHF_WRITE) { |
| 36 | this->Header.sh_addralign = this->getAddrSize(); |
| 37 | } |
| 38 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 39 | template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody *Sym) { |
| 40 | Sym->setGotIndex(Entries.size()); |
| 41 | Entries.push_back(Sym); |
| 42 | } |
| 43 | |
| 44 | template <class ELFT> |
| 45 | typename GotSection<ELFT>::uintX_t |
| 46 | GotSection<ELFT>::getEntryAddr(const SymbolBody &B) const { |
| 47 | return this->getVA() + B.getGotIndex() * this->getAddrSize(); |
| 48 | } |
| 49 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 50 | template <class ELFT> |
| 51 | PltSection<ELFT>::PltSection(const GotSection<ELFT> &GotSec) |
| 52 | : OutputSectionBase<ELFT::Is64Bits>(".plt", llvm::ELF::SHT_PROGBITS, |
| 53 | llvm::ELF::SHF_ALLOC | |
| 54 | llvm::ELF::SHF_EXECINSTR), |
| 55 | GotSec(GotSec) { |
| 56 | this->Header.sh_addralign = 16; |
| 57 | } |
| 58 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 59 | template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) { |
| 60 | uintptr_t Start = reinterpret_cast<uintptr_t>(Buf); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 61 | for (const SymbolBody *E : Entries) { |
Rafael Espindola | 01205f7 | 2015-09-22 18:19:46 +0000 | [diff] [blame] | 62 | uint64_t GotEntryAddr = GotSec.getEntryAddr(*E); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 63 | uintptr_t InstPos = reinterpret_cast<uintptr_t>(Buf); |
Rafael Espindola | 01205f7 | 2015-09-22 18:19:46 +0000 | [diff] [blame] | 64 | uint64_t PltEntryAddr = (InstPos - Start) + this->getVA(); |
| 65 | Target->writePltEntry(Buf, GotEntryAddr, PltEntryAddr); |
| 66 | Buf += 8; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | |
| 70 | template <class ELFT> void PltSection<ELFT>::addEntry(SymbolBody *Sym) { |
| 71 | Sym->setPltIndex(Entries.size()); |
| 72 | Entries.push_back(Sym); |
| 73 | } |
| 74 | |
| 75 | template <class ELFT> |
| 76 | typename PltSection<ELFT>::uintX_t |
| 77 | PltSection<ELFT>::getEntryAddr(const SymbolBody &B) const { |
| 78 | return this->getVA() + B.getPltIndex() * EntrySize; |
| 79 | } |
| 80 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 81 | template <class ELFT> |
| 82 | RelocationSection<ELFT>::RelocationSection(SymbolTableSection<ELFT> &DynSymSec, |
| 83 | const GotSection<ELFT> &GotSec, |
| 84 | bool IsRela) |
| 85 | : OutputSectionBase<ELFT::Is64Bits>(IsRela ? ".rela.dyn" : ".rel.dyn", |
| 86 | IsRela ? llvm::ELF::SHT_RELA |
| 87 | : llvm::ELF::SHT_REL, |
| 88 | llvm::ELF::SHF_ALLOC), |
| 89 | DynSymSec(DynSymSec), GotSec(GotSec), IsRela(IsRela) { |
| 90 | this->Header.sh_entsize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); |
| 91 | this->Header.sh_addralign = ELFT::Is64Bits ? 8 : 4; |
| 92 | } |
| 93 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 94 | template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 50534c2 | 2015-09-22 17:49:38 +0000 | [diff] [blame] | 95 | const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); |
Rafael Espindola | e1901cc | 2015-09-24 15:11:50 +0000 | [diff] [blame] | 96 | bool IsMips64EL = Relocs[0].C.getFile()->getObj().isMips64EL(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 97 | for (const DynamicReloc<ELFT> &Rel : Relocs) { |
Rafael Espindola | 50534c2 | 2015-09-22 17:49:38 +0000 | [diff] [blame] | 98 | auto *P = reinterpret_cast<Elf_Rel *>(Buf); |
| 99 | Buf += EntrySize; |
| 100 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 101 | const InputSection<ELFT> &C = Rel.C; |
| 102 | const Elf_Rel &RI = Rel.RI; |
| 103 | OutputSection<ELFT> *Out = C.getOutputSection(); |
| 104 | uint32_t SymIndex = RI.getSymbol(IsMips64EL); |
| 105 | const SymbolBody *Body = C.getFile()->getSymbolBody(SymIndex); |
| 106 | uint32_t Type = RI.getType(IsMips64EL); |
Rafael Espindola | 3ef3a4c | 2015-09-29 23:22:16 +0000 | [diff] [blame] | 107 | if (Target->relocNeedsGot(Type, *Body)) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 108 | P->r_offset = GotSec.getEntryAddr(*Body); |
Rafael Espindola | 7f07442 | 2015-09-22 21:35:51 +0000 | [diff] [blame] | 109 | P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), |
| 110 | Target->getGotReloc(), IsMips64EL); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 111 | } else { |
| 112 | P->r_offset = RI.r_offset + C.getOutputSectionOff() + Out->getVA(); |
| 113 | P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type, IsMips64EL); |
| 114 | if (IsRela) |
Rafael Espindola | 50534c2 | 2015-09-22 17:49:38 +0000 | [diff] [blame] | 115 | static_cast<Elf_Rela *>(P)->r_addend = |
| 116 | static_cast<const Elf_Rela &>(RI).r_addend; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 117 | } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
| 121 | template <class ELFT> void RelocationSection<ELFT>::finalize() { |
| 122 | this->Header.sh_link = DynSymSec.getSectionIndex(); |
| 123 | this->Header.sh_size = Relocs.size() * this->Header.sh_entsize; |
| 124 | } |
| 125 | |
| 126 | template <bool Is64Bits> |
| 127 | InterpSection<Is64Bits>::InterpSection() |
| 128 | : OutputSectionBase<Is64Bits>(".interp", llvm::ELF::SHT_PROGBITS, |
| 129 | llvm::ELF::SHF_ALLOC) { |
| 130 | this->Header.sh_size = Config->DynamicLinker.size() + 1; |
| 131 | this->Header.sh_addralign = 1; |
| 132 | } |
| 133 | |
| 134 | template <bool Is64Bits> |
| 135 | template <endianness E> |
| 136 | void OutputSectionBase<Is64Bits>::writeHeaderTo( |
| 137 | typename ELFFile<ELFType<E, Is64Bits>>::Elf_Shdr *SHdr) { |
| 138 | SHdr->sh_name = Header.sh_name; |
| 139 | SHdr->sh_type = Header.sh_type; |
| 140 | SHdr->sh_flags = Header.sh_flags; |
| 141 | SHdr->sh_addr = Header.sh_addr; |
| 142 | SHdr->sh_offset = Header.sh_offset; |
| 143 | SHdr->sh_size = Header.sh_size; |
| 144 | SHdr->sh_link = Header.sh_link; |
| 145 | SHdr->sh_info = Header.sh_info; |
| 146 | SHdr->sh_addralign = Header.sh_addralign; |
| 147 | SHdr->sh_entsize = Header.sh_entsize; |
| 148 | } |
| 149 | |
| 150 | template <bool Is64Bits> void InterpSection<Is64Bits>::writeTo(uint8_t *Buf) { |
| 151 | memcpy(Buf, Config->DynamicLinker.data(), Config->DynamicLinker.size()); |
| 152 | } |
| 153 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 154 | template <class ELFT> |
| 155 | HashTableSection<ELFT>::HashTableSection(SymbolTableSection<ELFT> &DynSymSec) |
| 156 | : OutputSectionBase<ELFT::Is64Bits>(".hash", llvm::ELF::SHT_HASH, |
| 157 | llvm::ELF::SHF_ALLOC), |
| 158 | DynSymSec(DynSymSec) { |
| 159 | this->Header.sh_entsize = sizeof(Elf_Word); |
| 160 | this->Header.sh_addralign = sizeof(Elf_Word); |
| 161 | } |
| 162 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 163 | template <class ELFT> void HashTableSection<ELFT>::addSymbol(SymbolBody *S) { |
| 164 | StringRef Name = S->getName(); |
| 165 | DynSymSec.addSymbol(Name); |
| 166 | Hashes.push_back(hash(Name)); |
| 167 | S->setDynamicSymbolTableIndex(Hashes.size()); |
| 168 | } |
| 169 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 170 | template <class ELFT> |
| 171 | DynamicSection<ELFT>::DynamicSection(SymbolTable &SymTab, |
| 172 | HashTableSection<ELFT> &HashSec, |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 173 | RelocationSection<ELFT> &RelaDynSec, |
| 174 | const OutputSection<ELFT> &BssSec) |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 175 | : OutputSectionBase<ELFT::Is64Bits>(".dynamic", llvm::ELF::SHT_DYNAMIC, |
| 176 | llvm::ELF::SHF_ALLOC | |
| 177 | llvm::ELF::SHF_WRITE), |
| 178 | HashSec(HashSec), DynSymSec(HashSec.getDynSymSec()), |
| 179 | DynStrSec(DynSymSec.getStrTabSec()), RelaDynSec(RelaDynSec), |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 180 | BssSec(BssSec), SymTab(SymTab) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 181 | typename Base::HeaderT &Header = this->Header; |
| 182 | Header.sh_addralign = ELFT::Is64Bits ? 8 : 4; |
| 183 | Header.sh_entsize = ELFT::Is64Bits ? 16 : 8; |
| 184 | } |
| 185 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 186 | template <class ELFT> void DynamicSection<ELFT>::finalize() { |
Michael J. Spencer | 52bf0eb | 2015-10-01 21:15:02 +0000 | [diff] [blame] | 187 | if (this->Header.sh_size) |
| 188 | return; // Already finalized. |
| 189 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 190 | typename Base::HeaderT &Header = this->Header; |
| 191 | Header.sh_link = DynStrSec.getSectionIndex(); |
| 192 | |
| 193 | unsigned NumEntries = 0; |
| 194 | if (RelaDynSec.hasRelocs()) { |
| 195 | ++NumEntries; // DT_RELA / DT_REL |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 196 | ++NumEntries; // DT_RELASZ / DT_RELSZ |
| 197 | ++NumEntries; // DT_RELAENT / DT_RELENT |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 198 | } |
| 199 | ++NumEntries; // DT_SYMTAB |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 200 | ++NumEntries; // DT_SYMENT |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 201 | ++NumEntries; // DT_STRTAB |
| 202 | ++NumEntries; // DT_STRSZ |
| 203 | ++NumEntries; // DT_HASH |
| 204 | |
Rui Ueyama | 7de3f37 | 2015-10-01 19:36:04 +0000 | [diff] [blame] | 205 | if (!Config->RPath.empty()) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 206 | ++NumEntries; // DT_RUNPATH |
Rui Ueyama | 7de3f37 | 2015-10-01 19:36:04 +0000 | [diff] [blame] | 207 | DynStrSec.add(Config->RPath); |
| 208 | } |
| 209 | |
| 210 | if (!Config->SoName.empty()) { |
| 211 | ++NumEntries; // DT_SONAME |
| 212 | DynStrSec.add(Config->SoName); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Rafael Espindola | 7757224 | 2015-10-02 19:37:55 +0000 | [diff] [blame] | 215 | if (PreInitArraySec) |
| 216 | NumEntries += 2; |
| 217 | if (InitArraySec) |
| 218 | NumEntries += 2; |
| 219 | if (FiniArraySec) |
| 220 | NumEntries += 2; |
| 221 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 222 | const std::vector<std::unique_ptr<SharedFileBase>> &SharedFiles = |
| 223 | SymTab.getSharedFiles(); |
| 224 | for (const std::unique_ptr<SharedFileBase> &File : SharedFiles) |
Rafael Espindola | c8b1581 | 2015-10-01 15:47:50 +0000 | [diff] [blame] | 225 | DynStrSec.add(File->getSoName()); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 226 | NumEntries += SharedFiles.size(); |
| 227 | |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 228 | if (Symbol *S = SymTab.getSymbols().lookup(Config->Init)) |
| 229 | InitSym = dyn_cast<ELFSymbolBody<ELFT>>(S->Body); |
| 230 | if (Symbol *S = SymTab.getSymbols().lookup(Config->Fini)) |
| 231 | FiniSym = dyn_cast<ELFSymbolBody<ELFT>>(S->Body); |
| 232 | |
| 233 | if (InitSym) |
| 234 | ++NumEntries; // DT_INIT |
| 235 | if (FiniSym) |
| 236 | ++NumEntries; // DT_FINI |
| 237 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 238 | ++NumEntries; // DT_NULL |
| 239 | |
| 240 | Header.sh_size = NumEntries * Header.sh_entsize; |
| 241 | } |
| 242 | |
| 243 | template <class ELFT> void DynamicSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 244 | auto *P = reinterpret_cast<Elf_Dyn *>(Buf); |
| 245 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 246 | auto WritePtr = [&](int32_t Tag, uint64_t Val) { |
| 247 | P->d_tag = Tag; |
| 248 | P->d_un.d_ptr = Val; |
| 249 | ++P; |
| 250 | }; |
| 251 | |
| 252 | auto WriteVal = [&](int32_t Tag, uint32_t Val) { |
| 253 | P->d_tag = Tag; |
| 254 | P->d_un.d_val = Val; |
| 255 | ++P; |
| 256 | }; |
| 257 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 258 | if (RelaDynSec.hasRelocs()) { |
| 259 | bool IsRela = RelaDynSec.isRela(); |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 260 | WritePtr(IsRela ? DT_RELA : DT_REL, RelaDynSec.getVA()); |
| 261 | WriteVal(IsRela ? DT_RELASZ : DT_RELSZ, RelaDynSec.getSize()); |
| 262 | WriteVal(IsRela ? DT_RELAENT : DT_RELENT, |
| 263 | IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel)); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 264 | } |
| 265 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 266 | WritePtr(DT_SYMTAB, DynSymSec.getVA()); |
| 267 | WritePtr(DT_SYMENT, sizeof(Elf_Sym)); |
| 268 | WritePtr(DT_STRTAB, DynStrSec.getVA()); |
| 269 | WriteVal(DT_STRSZ, DynStrSec.data().size()); |
| 270 | WritePtr(DT_HASH, HashSec.getVA()); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 271 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 272 | if (!Config->RPath.empty()) |
| 273 | WriteVal(DT_RUNPATH, DynStrSec.getFileOff(Config->RPath)); |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 274 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 275 | if (!Config->SoName.empty()) |
| 276 | WriteVal(DT_SONAME, DynStrSec.getFileOff(Config->SoName)); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 277 | |
Rafael Espindola | 7757224 | 2015-10-02 19:37:55 +0000 | [diff] [blame] | 278 | auto WriteArray = [&](int32_t T1, int32_t T2, |
| 279 | const OutputSection<ELFT> *Sec) { |
| 280 | if (!Sec) |
| 281 | return; |
| 282 | WritePtr(T1, Sec->getVA()); |
| 283 | WriteVal(T2, Sec->getSize()); |
| 284 | }; |
| 285 | WriteArray(DT_PREINIT_ARRAY, DT_PREINIT_ARRAYSZ, PreInitArraySec); |
| 286 | WriteArray(DT_INIT_ARRAY, DT_INIT_ARRAYSZ, InitArraySec); |
| 287 | WriteArray(DT_FINI_ARRAY, DT_FINI_ARRAYSZ, FiniArraySec); |
| 288 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 289 | const std::vector<std::unique_ptr<SharedFileBase>> &SharedFiles = |
| 290 | SymTab.getSharedFiles(); |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 291 | for (const std::unique_ptr<SharedFileBase> &File : SharedFiles) |
| 292 | WriteVal(DT_NEEDED, DynStrSec.getFileOff(File->getSoName())); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 293 | |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 294 | if (InitSym) |
| 295 | WritePtr(DT_INIT, getSymVA(*InitSym, BssSec)); |
| 296 | if (FiniSym) |
| 297 | WritePtr(DT_FINI, getSymVA(*FiniSym, BssSec)); |
| 298 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 299 | WriteVal(DT_NULL, 0); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | template <class ELFT> |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 303 | OutputSection<ELFT>::OutputSection(const PltSection<ELFT> &PltSec, |
| 304 | const GotSection<ELFT> &GotSec, |
| 305 | const OutputSection<ELFT> &BssSec, |
| 306 | StringRef Name, uint32_t sh_type, |
| 307 | uintX_t sh_flags) |
| 308 | : OutputSectionBase<ELFT::Is64Bits>(Name, sh_type, sh_flags), |
| 309 | PltSec(PltSec), GotSec(GotSec), BssSec(BssSec) {} |
| 310 | |
| 311 | template <class ELFT> |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 312 | void OutputSection<ELFT>::addSection(InputSection<ELFT> *C) { |
| 313 | Sections.push_back(C); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 314 | C->setOutputSection(this); |
| 315 | uint32_t Align = C->getAlign(); |
| 316 | if (Align > this->Header.sh_addralign) |
| 317 | this->Header.sh_addralign = Align; |
| 318 | |
| 319 | uintX_t Off = this->Header.sh_size; |
| 320 | Off = RoundUpToAlignment(Off, Align); |
| 321 | C->setOutputSectionOff(Off); |
| 322 | Off += C->getSize(); |
| 323 | this->Header.sh_size = Off; |
| 324 | } |
| 325 | |
| 326 | template <class ELFT> |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 327 | typename ELFFile<ELFT>::uintX_t |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 328 | lld::elf2::getSymVA(const ELFSymbolBody<ELFT> &S, |
| 329 | const OutputSection<ELFT> &BssSec) { |
| 330 | switch (S.kind()) { |
Rafael Espindola | 0e604f9 | 2015-09-25 18:56:53 +0000 | [diff] [blame] | 331 | case SymbolBody::DefinedSyntheticKind: |
| 332 | return cast<DefinedSynthetic<ELFT>>(S).Section.getVA() + S.Sym.st_value; |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 333 | case SymbolBody::DefinedAbsoluteKind: |
| 334 | return S.Sym.st_value; |
| 335 | case SymbolBody::DefinedRegularKind: { |
| 336 | const auto &DR = cast<DefinedRegular<ELFT>>(S); |
| 337 | const InputSection<ELFT> *SC = &DR.Section; |
| 338 | OutputSection<ELFT> *OS = SC->getOutputSection(); |
| 339 | return OS->getVA() + SC->getOutputSectionOff() + DR.Sym.st_value; |
| 340 | } |
| 341 | case SymbolBody::DefinedCommonKind: |
| 342 | return BssSec.getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS; |
| 343 | case SymbolBody::SharedKind: |
| 344 | case SymbolBody::UndefinedKind: |
| 345 | return 0; |
| 346 | case SymbolBody::LazyKind: |
Rafael Espindola | 2732235 | 2015-09-28 22:12:54 +0000 | [diff] [blame] | 347 | break; |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 348 | } |
Rafael Espindola | 2732235 | 2015-09-28 22:12:54 +0000 | [diff] [blame] | 349 | llvm_unreachable("Lazy symbol reached writer"); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | template <class ELFT> |
| 353 | typename ELFFile<ELFT>::uintX_t |
| 354 | lld::elf2::getLocalSymVA(const typename ELFFile<ELFT>::Elf_Sym *Sym, |
| 355 | const ObjectFile<ELFT> &File) { |
| 356 | uint32_t SecIndex = Sym->st_shndx; |
| 357 | |
| 358 | if (SecIndex == SHN_XINDEX) |
Rafael Espindola | e1901cc | 2015-09-24 15:11:50 +0000 | [diff] [blame] | 359 | SecIndex = File.getObj().getExtendedSymbolTableIndex( |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 360 | Sym, File.getSymbolTable(), File.getSymbolTableShndx()); |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 361 | ArrayRef<InputSection<ELFT> *> Sections = File.getSections(); |
| 362 | InputSection<ELFT> *Section = Sections[SecIndex]; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 363 | OutputSection<ELFT> *Out = Section->getOutputSection(); |
| 364 | return Out->getVA() + Section->getOutputSectionOff() + Sym->st_value; |
| 365 | } |
| 366 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 367 | template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 368 | for (InputSection<ELFT> *C : Sections) |
Rafael Espindola | c2d2119 | 2015-09-23 18:25:05 +0000 | [diff] [blame] | 369 | C->writeTo(Buf, BssSec, PltSec, GotSec); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | template <bool Is64Bits> |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 373 | StringTableSection<Is64Bits>::StringTableSection(bool Dynamic) |
| 374 | : OutputSectionBase<Is64Bits>(Dynamic ? ".dynstr" : ".strtab", |
| 375 | llvm::ELF::SHT_STRTAB, |
| 376 | Dynamic ? (uintX_t)llvm::ELF::SHF_ALLOC : 0), |
| 377 | Dynamic(Dynamic) { |
| 378 | this->Header.sh_addralign = 1; |
| 379 | } |
| 380 | |
| 381 | template <bool Is64Bits> |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 382 | void StringTableSection<Is64Bits>::writeTo(uint8_t *Buf) { |
| 383 | StringRef Data = StrTabBuilder.data(); |
| 384 | memcpy(Buf, Data.data(), Data.size()); |
| 385 | } |
| 386 | |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 387 | template <class ELFT> bool lld::elf2::includeInSymtab(const SymbolBody &B) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 388 | if (B.isLazy()) |
| 389 | return false; |
| 390 | if (!B.isUsedInRegularObj()) |
| 391 | return false; |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 392 | |
| 393 | // Don't include synthetic symbols like __init_array_start in every output. |
| 394 | if (auto *U = dyn_cast<DefinedAbsolute<ELFT>>(&B)) |
| 395 | if (&U->Sym == &DefinedAbsolute<ELFT>::IgnoreUndef) |
| 396 | return false; |
| 397 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 398 | return true; |
| 399 | } |
| 400 | |
Rafael Espindola | 05a3dd2 | 2015-09-22 23:38:23 +0000 | [diff] [blame] | 401 | bool lld::elf2::includeInDynamicSymtab(const SymbolBody &B) { |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 402 | uint8_t V = B.getMostConstrainingVisibility(); |
| 403 | if (V != STV_DEFAULT && V != STV_PROTECTED) |
| 404 | return false; |
| 405 | |
Rafael Espindola | 05a3dd2 | 2015-09-22 23:38:23 +0000 | [diff] [blame] | 406 | if (Config->ExportDynamic || Config->Shared) |
| 407 | return true; |
| 408 | return B.isUsedInDynamicReloc(); |
| 409 | } |
| 410 | |
Davide Italiano | 6993ba4 | 2015-09-26 00:47:56 +0000 | [diff] [blame] | 411 | bool lld::elf2::shouldKeepInSymtab(StringRef SymName) { |
| 412 | if (Config->DiscardNone) |
| 413 | return true; |
| 414 | |
| 415 | // ELF defines dynamic locals as symbols which name starts with ".L". |
| 416 | return !(Config->DiscardLocals && SymName.startswith(".L")); |
| 417 | } |
| 418 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 419 | template <class ELFT> |
| 420 | SymbolTableSection<ELFT>::SymbolTableSection( |
| 421 | SymbolTable &Table, StringTableSection<ELFT::Is64Bits> &StrTabSec, |
| 422 | const OutputSection<ELFT> &BssSec) |
| 423 | : OutputSectionBase<ELFT::Is64Bits>( |
| 424 | StrTabSec.isDynamic() ? ".dynsym" : ".symtab", |
| 425 | StrTabSec.isDynamic() ? llvm::ELF::SHT_DYNSYM : llvm::ELF::SHT_SYMTAB, |
| 426 | StrTabSec.isDynamic() ? (uintX_t)llvm::ELF::SHF_ALLOC : 0), |
| 427 | Table(Table), StrTabSec(StrTabSec), BssSec(BssSec) { |
| 428 | typedef OutputSectionBase<ELFT::Is64Bits> Base; |
| 429 | typename Base::HeaderT &Header = this->Header; |
| 430 | |
| 431 | Header.sh_entsize = sizeof(Elf_Sym); |
| 432 | Header.sh_addralign = ELFT::Is64Bits ? 8 : 4; |
| 433 | } |
| 434 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 435 | template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 436 | Buf += sizeof(Elf_Sym); |
| 437 | |
| 438 | // All symbols with STB_LOCAL binding precede the weak and global symbols. |
| 439 | // .dynsym only contains global symbols. |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 440 | if (!Config->DiscardAll && !StrTabSec.isDynamic()) |
| 441 | writeLocalSymbols(Buf); |
| 442 | |
| 443 | writeGlobalSymbols(Buf); |
| 444 | } |
| 445 | |
| 446 | template <class ELFT> |
| 447 | void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) { |
| 448 | // Iterate over all input object files to copy their local symbols |
| 449 | // to the output symbol table pointed by Buf. |
| 450 | for (const std::unique_ptr<ObjectFileBase> &FileB : Table.getObjectFiles()) { |
| 451 | auto &File = cast<ObjectFile<ELFT>>(*FileB); |
| 452 | Elf_Sym_Range Syms = File.getLocalSymbols(); |
| 453 | for (const Elf_Sym &Sym : Syms) { |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 454 | ErrorOr<StringRef> SymName = Sym.getName(File.getStringTable()); |
| 455 | if (SymName && !shouldKeepInSymtab(*SymName)) |
| 456 | continue; |
Rui Ueyama | c55733e | 2015-09-30 00:54:29 +0000 | [diff] [blame] | 457 | auto *ESym = reinterpret_cast<Elf_Sym *>(Buf); |
| 458 | Buf += sizeof(*ESym); |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 459 | ESym->st_name = (SymName) ? StrTabSec.getFileOff(*SymName) : 0; |
| 460 | ESym->st_size = Sym.st_size; |
| 461 | ESym->setBindingAndType(Sym.getBinding(), Sym.getType()); |
| 462 | uint32_t SecIndex = Sym.st_shndx; |
| 463 | uintX_t VA = Sym.st_value; |
| 464 | if (SecIndex == SHN_ABS) { |
| 465 | ESym->st_shndx = SHN_ABS; |
| 466 | } else { |
| 467 | if (SecIndex == SHN_XINDEX) |
| 468 | SecIndex = File.getObj().getExtendedSymbolTableIndex( |
| 469 | &Sym, File.getSymbolTable(), File.getSymbolTableShndx()); |
| 470 | ArrayRef<InputSection<ELFT> *> Sections = File.getSections(); |
| 471 | const InputSection<ELFT> *Section = Sections[SecIndex]; |
| 472 | const OutputSection<ELFT> *Out = Section->getOutputSection(); |
| 473 | ESym->st_shndx = Out->getSectionIndex(); |
| 474 | VA += Out->getVA() + Section->getOutputSectionOff(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 475 | } |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 476 | ESym->st_value = VA; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 477 | } |
| 478 | } |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 479 | } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 480 | |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 481 | template <class ELFT> |
| 482 | void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *&Buf) { |
| 483 | // Write the internal symbol table contents to the output symbol table |
| 484 | // pointed by Buf. |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 485 | uint8_t *Start = Buf; |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 486 | for (const std::pair<StringRef, Symbol *> &P : Table.getSymbols()) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 487 | StringRef Name = P.first; |
| 488 | Symbol *Sym = P.second; |
| 489 | SymbolBody *Body = Sym->Body; |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 490 | if (!includeInSymtab<ELFT>(*Body)) |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 491 | continue; |
Rafael Espindola | 05a3dd2 | 2015-09-22 23:38:23 +0000 | [diff] [blame] | 492 | if (StrTabSec.isDynamic() && !includeInDynamicSymtab(*Body)) |
| 493 | continue; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 494 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 495 | const auto &EBody = *cast<ELFSymbolBody<ELFT>>(Body); |
| 496 | const Elf_Sym &InputSym = EBody.Sym; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 497 | auto *ESym = reinterpret_cast<Elf_Sym *>(Buf); |
Rui Ueyama | c55733e | 2015-09-30 00:54:29 +0000 | [diff] [blame] | 498 | Buf += sizeof(*ESym); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 499 | ESym->st_name = StrTabSec.getFileOff(Name); |
| 500 | |
Rafael Espindola | 25b0acb | 2015-09-25 17:32:37 +0000 | [diff] [blame] | 501 | const OutputSection<ELFT> *Out = nullptr; |
| 502 | const InputSection<ELFT> *Section = nullptr; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 503 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 504 | switch (EBody.kind()) { |
Rafael Espindola | 0e604f9 | 2015-09-25 18:56:53 +0000 | [diff] [blame] | 505 | case SymbolBody::DefinedSyntheticKind: |
| 506 | Out = &cast<DefinedSynthetic<ELFT>>(Body)->Section; |
| 507 | break; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 508 | case SymbolBody::DefinedRegularKind: |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 509 | Section = &cast<DefinedRegular<ELFT>>(EBody).Section; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 510 | break; |
| 511 | case SymbolBody::DefinedCommonKind: |
Rafael Espindola | c2d2119 | 2015-09-23 18:25:05 +0000 | [diff] [blame] | 512 | Out = &BssSec; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 513 | break; |
| 514 | case SymbolBody::UndefinedKind: |
| 515 | case SymbolBody::DefinedAbsoluteKind: |
| 516 | case SymbolBody::SharedKind: |
| 517 | break; |
| 518 | case SymbolBody::LazyKind: |
| 519 | llvm_unreachable("Lazy symbol got to output symbol table!"); |
| 520 | } |
| 521 | |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 522 | unsigned char Binding = InputSym.getBinding(); |
| 523 | unsigned char Visibility = EBody.getMostConstrainingVisibility(); |
| 524 | if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED) |
| 525 | Binding = STB_LOCAL; |
| 526 | |
| 527 | ESym->setBindingAndType(Binding, InputSym.getType()); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 528 | ESym->st_size = InputSym.st_size; |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 529 | ESym->setVisibility(Visibility); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 530 | if (InputSym.isAbsolute()) { |
| 531 | ESym->st_shndx = SHN_ABS; |
| 532 | ESym->st_value = InputSym.st_value; |
| 533 | } |
| 534 | |
| 535 | if (Section) |
| 536 | Out = Section->getOutputSection(); |
| 537 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 538 | ESym->st_value = getSymVA(EBody, BssSec); |
| 539 | |
| 540 | if (Out) |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 541 | ESym->st_shndx = Out->getSectionIndex(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 542 | } |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 543 | if (!StrTabSec.isDynamic()) |
| 544 | std::stable_sort( |
| 545 | reinterpret_cast<Elf_Sym *>(Start), reinterpret_cast<Elf_Sym *>(Buf), |
| 546 | [](const Elf_Sym &A, const Elf_Sym &B) -> bool { |
| 547 | return A.getBinding() == STB_LOCAL && B.getBinding() != STB_LOCAL; |
| 548 | }); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | namespace lld { |
| 552 | namespace elf2 { |
| 553 | template class OutputSectionBase<false>; |
| 554 | template class OutputSectionBase<true>; |
| 555 | |
| 556 | template void OutputSectionBase<false>::writeHeaderTo<support::little>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 557 | ELFFile<ELFType<support::little, false>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 558 | template void OutputSectionBase<true>::writeHeaderTo<support::little>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 559 | ELFFile<ELFType<support::little, true>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 560 | template void OutputSectionBase<false>::writeHeaderTo<support::big>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 561 | ELFFile<ELFType<support::big, false>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 562 | template void OutputSectionBase<true>::writeHeaderTo<support::big>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 563 | ELFFile<ELFType<support::big, true>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 564 | |
| 565 | template class GotSection<ELF32LE>; |
| 566 | template class GotSection<ELF32BE>; |
| 567 | template class GotSection<ELF64LE>; |
| 568 | template class GotSection<ELF64BE>; |
| 569 | |
| 570 | template class PltSection<ELF32LE>; |
| 571 | template class PltSection<ELF32BE>; |
| 572 | template class PltSection<ELF64LE>; |
| 573 | template class PltSection<ELF64BE>; |
| 574 | |
| 575 | template class RelocationSection<ELF32LE>; |
| 576 | template class RelocationSection<ELF32BE>; |
| 577 | template class RelocationSection<ELF64LE>; |
| 578 | template class RelocationSection<ELF64BE>; |
| 579 | |
| 580 | template class InterpSection<false>; |
| 581 | template class InterpSection<true>; |
| 582 | |
| 583 | template class HashTableSection<ELF32LE>; |
| 584 | template class HashTableSection<ELF32BE>; |
| 585 | template class HashTableSection<ELF64LE>; |
| 586 | template class HashTableSection<ELF64BE>; |
| 587 | |
| 588 | template class DynamicSection<ELF32LE>; |
| 589 | template class DynamicSection<ELF32BE>; |
| 590 | template class DynamicSection<ELF64LE>; |
| 591 | template class DynamicSection<ELF64BE>; |
| 592 | |
| 593 | template class OutputSection<ELF32LE>; |
| 594 | template class OutputSection<ELF32BE>; |
| 595 | template class OutputSection<ELF64LE>; |
| 596 | template class OutputSection<ELF64BE>; |
| 597 | |
| 598 | template class StringTableSection<false>; |
| 599 | template class StringTableSection<true>; |
| 600 | |
| 601 | template class SymbolTableSection<ELF32LE>; |
| 602 | template class SymbolTableSection<ELF32BE>; |
| 603 | template class SymbolTableSection<ELF64LE>; |
| 604 | template class SymbolTableSection<ELF64BE>; |
| 605 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 606 | template ELFFile<ELF32LE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 607 | getSymVA(const ELFSymbolBody<ELF32LE> &, const OutputSection<ELF32LE> &); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 608 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 609 | template ELFFile<ELF32BE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 610 | getSymVA(const ELFSymbolBody<ELF32BE> &, const OutputSection<ELF32BE> &); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 611 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 612 | template ELFFile<ELF64LE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 613 | getSymVA(const ELFSymbolBody<ELF64LE> &, const OutputSection<ELF64LE> &); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 614 | |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 615 | template ELFFile<ELF64BE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 616 | getSymVA(const ELFSymbolBody<ELF64BE> &, const OutputSection<ELF64BE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 617 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 618 | template ELFFile<ELF32LE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 619 | getLocalSymVA(const ELFFile<ELF32LE>::Elf_Sym *, const ObjectFile<ELF32LE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 620 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 621 | template ELFFile<ELF32BE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 622 | getLocalSymVA(const ELFFile<ELF32BE>::Elf_Sym *, const ObjectFile<ELF32BE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 623 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 624 | template ELFFile<ELF64LE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 625 | getLocalSymVA(const ELFFile<ELF64LE>::Elf_Sym *, const ObjectFile<ELF64LE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 626 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 627 | template ELFFile<ELF64BE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 628 | getLocalSymVA(const ELFFile<ELF64BE>::Elf_Sym *, const ObjectFile<ELF64BE> &); |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame^] | 629 | |
| 630 | template bool includeInSymtab<ELF32LE>(const SymbolBody &); |
| 631 | template bool includeInSymtab<ELF32BE>(const SymbolBody &); |
| 632 | template bool includeInSymtab<ELF64LE>(const SymbolBody &); |
| 633 | template bool includeInSymtab<ELF64BE>(const SymbolBody &); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 634 | } |
| 635 | } |