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; |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 17 | using namespace llvm::support::endian; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 18 | using namespace llvm::ELF; |
| 19 | |
| 20 | using namespace lld; |
| 21 | using namespace lld::elf2; |
| 22 | |
| 23 | template <bool Is64Bits> |
| 24 | OutputSectionBase<Is64Bits>::OutputSectionBase(StringRef Name, uint32_t sh_type, |
| 25 | uintX_t sh_flags) |
| 26 | : Name(Name) { |
| 27 | memset(&Header, 0, sizeof(HeaderT)); |
| 28 | Header.sh_type = sh_type; |
| 29 | Header.sh_flags = sh_flags; |
| 30 | } |
| 31 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 32 | template <class ELFT> |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 33 | GotSection<ELFT>::GotSection() |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 34 | : OutputSectionBase<ELFT::Is64Bits>(".got", llvm::ELF::SHT_PROGBITS, |
| 35 | llvm::ELF::SHF_ALLOC | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 36 | llvm::ELF::SHF_WRITE) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 37 | this->Header.sh_addralign = this->getAddrSize(); |
| 38 | } |
| 39 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 40 | template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody *Sym) { |
Rui Ueyama | 49c68a7 | 2015-10-09 00:42:06 +0000 | [diff] [blame] | 41 | Sym->GotIndex = Entries.size(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 42 | Entries.push_back(Sym); |
| 43 | } |
| 44 | |
| 45 | template <class ELFT> |
| 46 | typename GotSection<ELFT>::uintX_t |
| 47 | GotSection<ELFT>::getEntryAddr(const SymbolBody &B) const { |
Rui Ueyama | 49c68a7 | 2015-10-09 00:42:06 +0000 | [diff] [blame] | 48 | return this->getVA() + B.GotIndex * this->getAddrSize(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 51 | template <class ELFT> void GotSection<ELFT>::writeTo(uint8_t *Buf) { |
| 52 | for (const SymbolBody *B : Entries) { |
Rafael Espindola | e782f67 | 2015-10-07 03:56:05 +0000 | [diff] [blame] | 53 | uint8_t *Entry = Buf; |
| 54 | Buf += sizeof(uintX_t); |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 55 | if (canBePreempted(B)) |
| 56 | continue; // The dynamic linker will take care of it. |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 57 | uintX_t VA = getSymVA<ELFT>(*B); |
Rafael Espindola | e782f67 | 2015-10-07 03:56:05 +0000 | [diff] [blame] | 58 | write<uintX_t, ELFT::TargetEndianness, sizeof(uintX_t)>(Entry, VA); |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 62 | template <class ELFT> |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 63 | PltSection<ELFT>::PltSection() |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 64 | : OutputSectionBase<ELFT::Is64Bits>(".plt", llvm::ELF::SHT_PROGBITS, |
| 65 | llvm::ELF::SHF_ALLOC | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 66 | llvm::ELF::SHF_EXECINSTR) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 67 | this->Header.sh_addralign = 16; |
| 68 | } |
| 69 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 70 | template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) { |
Rui Ueyama | 242ddf4 | 2015-10-12 18:56:36 +0000 | [diff] [blame^] | 71 | size_t Off = 0; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 72 | for (const SymbolBody *E : Entries) { |
Rui Ueyama | 36f6922 | 2015-10-09 00:50:05 +0000 | [diff] [blame] | 73 | uint64_t Got = Out<ELFT>::Got->getEntryAddr(*E); |
Rui Ueyama | 242ddf4 | 2015-10-12 18:56:36 +0000 | [diff] [blame^] | 74 | uint64_t Plt = this->getVA() + Off; |
| 75 | Target->writePltEntry(Buf + Off, Got, Plt); |
| 76 | Off += Target->getPltEntrySize(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
| 80 | template <class ELFT> void PltSection<ELFT>::addEntry(SymbolBody *Sym) { |
Rui Ueyama | 49c68a7 | 2015-10-09 00:42:06 +0000 | [diff] [blame] | 81 | Sym->PltIndex = Entries.size(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 82 | Entries.push_back(Sym); |
| 83 | } |
| 84 | |
| 85 | template <class ELFT> |
| 86 | typename PltSection<ELFT>::uintX_t |
| 87 | PltSection<ELFT>::getEntryAddr(const SymbolBody &B) const { |
Rui Ueyama | 49c68a7 | 2015-10-09 00:42:06 +0000 | [diff] [blame] | 88 | return this->getVA() + B.PltIndex * Target->getPltEntrySize(); |
Hal Finkel | 6c2a3b8 | 2015-10-08 21:51:31 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | template <class ELFT> |
| 92 | void PltSection<ELFT>::finalize() { |
| 93 | this->Header.sh_size = Entries.size() * Target->getPltEntrySize(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 96 | template <class ELFT> |
Rafael Espindola | d540919 | 2015-10-09 14:25:49 +0000 | [diff] [blame] | 97 | RelocationSection<ELFT>::RelocationSection(bool IsRela) |
| 98 | : OutputSectionBase<ELFT::Is64Bits>(IsRela ? ".rela.dyn" : ".rel.dyn", |
| 99 | IsRela ? llvm::ELF::SHT_RELA |
| 100 | : llvm::ELF::SHT_REL, |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 101 | llvm::ELF::SHF_ALLOC), |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 102 | IsRela(IsRela) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 103 | this->Header.sh_entsize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); |
| 104 | this->Header.sh_addralign = ELFT::Is64Bits ? 8 : 4; |
| 105 | } |
| 106 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 107 | template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 50534c2 | 2015-09-22 17:49:38 +0000 | [diff] [blame] | 108 | const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel); |
Rafael Espindola | e1901cc | 2015-09-24 15:11:50 +0000 | [diff] [blame] | 109 | bool IsMips64EL = Relocs[0].C.getFile()->getObj().isMips64EL(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 110 | for (const DynamicReloc<ELFT> &Rel : Relocs) { |
Rafael Espindola | 50534c2 | 2015-09-22 17:49:38 +0000 | [diff] [blame] | 111 | auto *P = reinterpret_cast<Elf_Rel *>(Buf); |
| 112 | Buf += EntrySize; |
| 113 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 114 | const InputSection<ELFT> &C = Rel.C; |
| 115 | const Elf_Rel &RI = Rel.RI; |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 116 | OutputSection<ELFT> *OutSec = C.getOutputSection(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 117 | uint32_t SymIndex = RI.getSymbol(IsMips64EL); |
Rafael Espindola | 41127ad | 2015-10-05 22:49:16 +0000 | [diff] [blame] | 118 | const ObjectFile<ELFT> &File = *C.getFile(); |
Rui Ueyama | 35da9b6 | 2015-10-11 20:59:12 +0000 | [diff] [blame] | 119 | SymbolBody *Body = File.getSymbolBody(SymIndex); |
Rafael Espindola | 41127ad | 2015-10-05 22:49:16 +0000 | [diff] [blame] | 120 | const ELFFile<ELFT> &Obj = File.getObj(); |
Rui Ueyama | 35da9b6 | 2015-10-11 20:59:12 +0000 | [diff] [blame] | 121 | if (Body) |
| 122 | Body = Body->repl(); |
Rafael Espindola | 41127ad | 2015-10-05 22:49:16 +0000 | [diff] [blame] | 123 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 124 | uint32_t Type = RI.getType(IsMips64EL); |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 125 | |
| 126 | bool CanBePreempted = canBePreempted(Body); |
| 127 | uintX_t Addend = 0; |
| 128 | if (!CanBePreempted) { |
| 129 | if (IsRela) { |
| 130 | if (Body) |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 131 | Addend += getSymVA<ELFT>(cast<ELFSymbolBody<ELFT>>(*Body)); |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 132 | else |
| 133 | Addend += getLocalSymVA( |
| 134 | Obj.getRelocationSymbol(&RI, File.getSymbolTable()), File); |
| 135 | } |
| 136 | P->setSymbolAndType(0, Target->getRelativeReloc(), IsMips64EL); |
| 137 | } |
| 138 | |
Rafael Espindola | ae24400 | 2015-10-05 19:30:12 +0000 | [diff] [blame] | 139 | if (Body && Target->relocNeedsGot(Type, *Body)) { |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 140 | P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body); |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 141 | if (CanBePreempted) |
| 142 | P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), |
| 143 | Target->getGotReloc(), IsMips64EL); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 144 | } else { |
Rafael Espindola | 3c83e2b | 2015-10-05 21:09:37 +0000 | [diff] [blame] | 145 | if (IsRela) |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 146 | Addend += static_cast<const Elf_Rela &>(RI).r_addend; |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 147 | P->r_offset = RI.r_offset + C.getOutputSectionOff() + OutSec->getVA(); |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 148 | if (CanBePreempted) |
Rafael Espindola | ae24400 | 2015-10-05 19:30:12 +0000 | [diff] [blame] | 149 | P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type, |
| 150 | IsMips64EL); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 151 | } |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 152 | |
| 153 | if (IsRela) |
| 154 | static_cast<Elf_Rela *>(P)->r_addend = Addend; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | |
| 158 | template <class ELFT> void RelocationSection<ELFT>::finalize() { |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 159 | this->Header.sh_link = Out<ELFT>::DynSymTab->getSectionIndex(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 160 | this->Header.sh_size = Relocs.size() * this->Header.sh_entsize; |
| 161 | } |
| 162 | |
| 163 | template <bool Is64Bits> |
| 164 | InterpSection<Is64Bits>::InterpSection() |
| 165 | : OutputSectionBase<Is64Bits>(".interp", llvm::ELF::SHT_PROGBITS, |
| 166 | llvm::ELF::SHF_ALLOC) { |
| 167 | this->Header.sh_size = Config->DynamicLinker.size() + 1; |
| 168 | this->Header.sh_addralign = 1; |
| 169 | } |
| 170 | |
| 171 | template <bool Is64Bits> |
| 172 | template <endianness E> |
| 173 | void OutputSectionBase<Is64Bits>::writeHeaderTo( |
| 174 | typename ELFFile<ELFType<E, Is64Bits>>::Elf_Shdr *SHdr) { |
| 175 | SHdr->sh_name = Header.sh_name; |
| 176 | SHdr->sh_type = Header.sh_type; |
| 177 | SHdr->sh_flags = Header.sh_flags; |
| 178 | SHdr->sh_addr = Header.sh_addr; |
| 179 | SHdr->sh_offset = Header.sh_offset; |
| 180 | SHdr->sh_size = Header.sh_size; |
| 181 | SHdr->sh_link = Header.sh_link; |
| 182 | SHdr->sh_info = Header.sh_info; |
| 183 | SHdr->sh_addralign = Header.sh_addralign; |
| 184 | SHdr->sh_entsize = Header.sh_entsize; |
| 185 | } |
| 186 | |
| 187 | template <bool Is64Bits> void InterpSection<Is64Bits>::writeTo(uint8_t *Buf) { |
| 188 | memcpy(Buf, Config->DynamicLinker.data(), Config->DynamicLinker.size()); |
| 189 | } |
| 190 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 191 | template <class ELFT> |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 192 | HashTableSection<ELFT>::HashTableSection() |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 193 | : OutputSectionBase<ELFT::Is64Bits>(".hash", llvm::ELF::SHT_HASH, |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 194 | llvm::ELF::SHF_ALLOC) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 195 | this->Header.sh_entsize = sizeof(Elf_Word); |
| 196 | this->Header.sh_addralign = sizeof(Elf_Word); |
| 197 | } |
| 198 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 199 | template <class ELFT> void HashTableSection<ELFT>::addSymbol(SymbolBody *S) { |
| 200 | StringRef Name = S->getName(); |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 201 | Out<ELFT>::DynSymTab->addSymbol(Name); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 202 | Hashes.push_back(hash(Name)); |
| 203 | S->setDynamicSymbolTableIndex(Hashes.size()); |
| 204 | } |
| 205 | |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 206 | template <class ELFT> void HashTableSection<ELFT>::finalize() { |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 207 | this->Header.sh_link = Out<ELFT>::DynSymTab->getSectionIndex(); |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 208 | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 209 | assert(Out<ELFT>::DynSymTab->getNumSymbols() == Hashes.size() + 1); |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 210 | unsigned NumEntries = 2; // nbucket and nchain. |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 211 | NumEntries += Out<ELFT>::DynSymTab->getNumSymbols(); // The chain entries. |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 212 | |
| 213 | // Create as many buckets as there are symbols. |
| 214 | // FIXME: This is simplistic. We can try to optimize it, but implementing |
| 215 | // support for SHT_GNU_HASH is probably even more profitable. |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 216 | NumEntries += Out<ELFT>::DynSymTab->getNumSymbols(); |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 217 | this->Header.sh_size = NumEntries * sizeof(Elf_Word); |
| 218 | } |
| 219 | |
| 220 | template <class ELFT> void HashTableSection<ELFT>::writeTo(uint8_t *Buf) { |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 221 | unsigned NumSymbols = Out<ELFT>::DynSymTab->getNumSymbols(); |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 222 | auto *P = reinterpret_cast<Elf_Word *>(Buf); |
| 223 | *P++ = NumSymbols; // nbucket |
| 224 | *P++ = NumSymbols; // nchain |
| 225 | |
| 226 | Elf_Word *Buckets = P; |
| 227 | Elf_Word *Chains = P + NumSymbols; |
| 228 | |
| 229 | for (unsigned I = 1; I < NumSymbols; ++I) { |
| 230 | uint32_t Hash = Hashes[I - 1] % NumSymbols; |
| 231 | Chains[I] = Buckets[Hash]; |
| 232 | Buckets[Hash] = I; |
| 233 | } |
| 234 | } |
| 235 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 236 | template <class ELFT> |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 237 | DynamicSection<ELFT>::DynamicSection(SymbolTable<ELFT> &SymTab) |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 238 | : OutputSectionBase<ELFT::Is64Bits>(".dynamic", llvm::ELF::SHT_DYNAMIC, |
| 239 | llvm::ELF::SHF_ALLOC | |
| 240 | llvm::ELF::SHF_WRITE), |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 241 | SymTab(SymTab) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 242 | typename Base::HeaderT &Header = this->Header; |
| 243 | Header.sh_addralign = ELFT::Is64Bits ? 8 : 4; |
| 244 | Header.sh_entsize = ELFT::Is64Bits ? 16 : 8; |
| 245 | } |
| 246 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 247 | template <class ELFT> void DynamicSection<ELFT>::finalize() { |
Michael J. Spencer | 52bf0eb | 2015-10-01 21:15:02 +0000 | [diff] [blame] | 248 | if (this->Header.sh_size) |
| 249 | return; // Already finalized. |
| 250 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 251 | typename Base::HeaderT &Header = this->Header; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 252 | Header.sh_link = Out<ELFT>::DynStrTab->getSectionIndex(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 253 | |
| 254 | unsigned NumEntries = 0; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 255 | if (Out<ELFT>::RelaDyn->hasRelocs()) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 256 | ++NumEntries; // DT_RELA / DT_REL |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 257 | ++NumEntries; // DT_RELASZ / DT_RELSZ |
| 258 | ++NumEntries; // DT_RELAENT / DT_RELENT |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 259 | } |
| 260 | ++NumEntries; // DT_SYMTAB |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 261 | ++NumEntries; // DT_SYMENT |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 262 | ++NumEntries; // DT_STRTAB |
| 263 | ++NumEntries; // DT_STRSZ |
| 264 | ++NumEntries; // DT_HASH |
| 265 | |
Rui Ueyama | 7de3f37 | 2015-10-01 19:36:04 +0000 | [diff] [blame] | 266 | if (!Config->RPath.empty()) { |
Davide Italiano | c39c75d | 2015-10-06 16:20:00 +0000 | [diff] [blame] | 267 | ++NumEntries; // DT_RUNPATH / DT_RPATH |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 268 | Out<ELFT>::DynStrTab->add(Config->RPath); |
Rui Ueyama | 7de3f37 | 2015-10-01 19:36:04 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | if (!Config->SoName.empty()) { |
| 272 | ++NumEntries; // DT_SONAME |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 273 | Out<ELFT>::DynStrTab->add(Config->SoName); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Rafael Espindola | 7757224 | 2015-10-02 19:37:55 +0000 | [diff] [blame] | 276 | if (PreInitArraySec) |
| 277 | NumEntries += 2; |
| 278 | if (InitArraySec) |
| 279 | NumEntries += 2; |
| 280 | if (FiniArraySec) |
| 281 | NumEntries += 2; |
| 282 | |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 283 | for (const std::unique_ptr<SharedFile<ELFT>> &F : SymTab.getSharedFiles()) { |
Rui Ueyama | 35da9b6 | 2015-10-11 20:59:12 +0000 | [diff] [blame] | 284 | if (!F->isNeeded()) |
| 285 | continue; |
Rui Ueyama | 6ccc8ca | 2015-10-09 20:32:54 +0000 | [diff] [blame] | 286 | Out<ELFT>::DynStrTab->add(F->getSoName()); |
| 287 | ++NumEntries; |
| 288 | } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 289 | |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 290 | if (Symbol *S = SymTab.getSymbols().lookup(Config->Init)) |
| 291 | InitSym = dyn_cast<ELFSymbolBody<ELFT>>(S->Body); |
| 292 | if (Symbol *S = SymTab.getSymbols().lookup(Config->Fini)) |
| 293 | FiniSym = dyn_cast<ELFSymbolBody<ELFT>>(S->Body); |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 294 | if (InitSym) |
| 295 | ++NumEntries; // DT_INIT |
| 296 | if (FiniSym) |
| 297 | ++NumEntries; // DT_FINI |
George Rimar | 97aad17 | 2015-10-07 15:00:21 +0000 | [diff] [blame] | 298 | if (Config->ZNow) |
| 299 | ++NumEntries; // DT_FLAGS_1 |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 300 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 301 | ++NumEntries; // DT_NULL |
| 302 | |
| 303 | Header.sh_size = NumEntries * Header.sh_entsize; |
| 304 | } |
| 305 | |
| 306 | template <class ELFT> void DynamicSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 307 | auto *P = reinterpret_cast<Elf_Dyn *>(Buf); |
| 308 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 309 | auto WritePtr = [&](int32_t Tag, uint64_t Val) { |
| 310 | P->d_tag = Tag; |
| 311 | P->d_un.d_ptr = Val; |
| 312 | ++P; |
| 313 | }; |
| 314 | |
| 315 | auto WriteVal = [&](int32_t Tag, uint32_t Val) { |
| 316 | P->d_tag = Tag; |
| 317 | P->d_un.d_val = Val; |
| 318 | ++P; |
| 319 | }; |
| 320 | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 321 | if (Out<ELFT>::RelaDyn->hasRelocs()) { |
| 322 | bool IsRela = Out<ELFT>::RelaDyn->isRela(); |
| 323 | WritePtr(IsRela ? DT_RELA : DT_REL, Out<ELFT>::RelaDyn->getVA()); |
| 324 | WriteVal(IsRela ? DT_RELASZ : DT_RELSZ, Out<ELFT>::RelaDyn->getSize()); |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 325 | WriteVal(IsRela ? DT_RELAENT : DT_RELENT, |
| 326 | IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel)); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 327 | } |
| 328 | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 329 | WritePtr(DT_SYMTAB, Out<ELFT>::DynSymTab->getVA()); |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 330 | WritePtr(DT_SYMENT, sizeof(Elf_Sym)); |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 331 | WritePtr(DT_STRTAB, Out<ELFT>::DynStrTab->getVA()); |
| 332 | WriteVal(DT_STRSZ, Out<ELFT>::DynStrTab->data().size()); |
| 333 | WritePtr(DT_HASH, Out<ELFT>::HashTab->getVA()); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 334 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 335 | if (!Config->RPath.empty()) |
Davide Italiano | c39c75d | 2015-10-06 16:20:00 +0000 | [diff] [blame] | 336 | |
| 337 | // If --enable-new-dtags is set lld emits DT_RUNPATH |
| 338 | // instead of DT_RPATH. The two tags are functionally |
| 339 | // equivalent except for the following: |
| 340 | // - DT_RUNPATH is searched after LD_LIBRARY_PATH, while |
| 341 | // DT_RPATH is searched before. |
| 342 | // - DT_RUNPATH is used only to search for direct |
| 343 | // dependencies of the object it's contained in, while |
| 344 | // DT_RPATH is used for indirect dependencies as well. |
| 345 | WriteVal(Config->EnableNewDtags ? DT_RUNPATH : DT_RPATH, |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 346 | Out<ELFT>::DynStrTab->getFileOff(Config->RPath)); |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 347 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 348 | if (!Config->SoName.empty()) |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 349 | WriteVal(DT_SONAME, Out<ELFT>::DynStrTab->getFileOff(Config->SoName)); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 350 | |
Rafael Espindola | 7757224 | 2015-10-02 19:37:55 +0000 | [diff] [blame] | 351 | auto WriteArray = [&](int32_t T1, int32_t T2, |
| 352 | const OutputSection<ELFT> *Sec) { |
| 353 | if (!Sec) |
| 354 | return; |
| 355 | WritePtr(T1, Sec->getVA()); |
| 356 | WriteVal(T2, Sec->getSize()); |
| 357 | }; |
| 358 | WriteArray(DT_PREINIT_ARRAY, DT_PREINIT_ARRAYSZ, PreInitArraySec); |
| 359 | WriteArray(DT_INIT_ARRAY, DT_INIT_ARRAYSZ, InitArraySec); |
| 360 | WriteArray(DT_FINI_ARRAY, DT_FINI_ARRAYSZ, FiniArraySec); |
| 361 | |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 362 | for (const std::unique_ptr<SharedFile<ELFT>> &F : SymTab.getSharedFiles()) |
Rui Ueyama | 35da9b6 | 2015-10-11 20:59:12 +0000 | [diff] [blame] | 363 | if (F->isNeeded()) |
| 364 | WriteVal(DT_NEEDED, Out<ELFT>::DynStrTab->getFileOff(F->getSoName())); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 365 | |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 366 | if (InitSym) |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 367 | WritePtr(DT_INIT, getSymVA<ELFT>(*InitSym)); |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 368 | if (FiniSym) |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 369 | WritePtr(DT_FINI, getSymVA<ELFT>(*FiniSym)); |
Igor Kudrin | b1f2b51 | 2015-10-05 10:29:46 +0000 | [diff] [blame] | 370 | |
George Rimar | 97aad17 | 2015-10-07 15:00:21 +0000 | [diff] [blame] | 371 | if (Config->ZNow) |
| 372 | WriteVal(DT_FLAGS_1, DF_1_NOW); |
| 373 | |
Rui Ueyama | 8c205d5 | 2015-10-02 01:33:31 +0000 | [diff] [blame] | 374 | WriteVal(DT_NULL, 0); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | template <class ELFT> |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 378 | OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t sh_type, |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 379 | uintX_t sh_flags) |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 380 | : OutputSectionBase<ELFT::Is64Bits>(Name, sh_type, sh_flags) {} |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 381 | |
| 382 | template <class ELFT> |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 383 | void OutputSection<ELFT>::addSection(InputSection<ELFT> *C) { |
| 384 | Sections.push_back(C); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 385 | C->setOutputSection(this); |
| 386 | uint32_t Align = C->getAlign(); |
| 387 | if (Align > this->Header.sh_addralign) |
| 388 | this->Header.sh_addralign = Align; |
| 389 | |
| 390 | uintX_t Off = this->Header.sh_size; |
| 391 | Off = RoundUpToAlignment(Off, Align); |
| 392 | C->setOutputSectionOff(Off); |
| 393 | Off += C->getSize(); |
| 394 | this->Header.sh_size = Off; |
| 395 | } |
| 396 | |
| 397 | template <class ELFT> |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 398 | typename ELFFile<ELFT>::uintX_t lld::elf2::getSymVA(const SymbolBody &S) { |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 399 | switch (S.kind()) { |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 400 | case SymbolBody::DefinedSyntheticKind: { |
| 401 | auto &D = cast<DefinedSynthetic<ELFT>>(S); |
| 402 | return D.Section.getVA() + D.Sym.st_value; |
| 403 | } |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 404 | case SymbolBody::DefinedAbsoluteKind: |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 405 | return cast<DefinedAbsolute<ELFT>>(S).Sym.st_value; |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 406 | case SymbolBody::DefinedRegularKind: { |
| 407 | const auto &DR = cast<DefinedRegular<ELFT>>(S); |
| 408 | const InputSection<ELFT> *SC = &DR.Section; |
| 409 | OutputSection<ELFT> *OS = SC->getOutputSection(); |
| 410 | return OS->getVA() + SC->getOutputSectionOff() + DR.Sym.st_value; |
| 411 | } |
| 412 | case SymbolBody::DefinedCommonKind: |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 413 | return Out<ELFT>::Bss->getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS; |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 414 | case SymbolBody::SharedKind: |
| 415 | case SymbolBody::UndefinedKind: |
| 416 | return 0; |
| 417 | case SymbolBody::LazyKind: |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 418 | assert(S.isUsedInRegularObj() && "Lazy symbol reached writer"); |
| 419 | return 0; |
Rafael Espindola | cd076f0 | 2015-09-25 18:19:03 +0000 | [diff] [blame] | 420 | } |
Denis Protivensky | 92aa1c0 | 2015-10-07 08:21:34 +0000 | [diff] [blame] | 421 | llvm_unreachable("Invalid symbol kind"); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | template <class ELFT> |
| 425 | typename ELFFile<ELFT>::uintX_t |
| 426 | lld::elf2::getLocalSymVA(const typename ELFFile<ELFT>::Elf_Sym *Sym, |
| 427 | const ObjectFile<ELFT> &File) { |
| 428 | uint32_t SecIndex = Sym->st_shndx; |
| 429 | |
| 430 | if (SecIndex == SHN_XINDEX) |
Rafael Espindola | e1901cc | 2015-09-24 15:11:50 +0000 | [diff] [blame] | 431 | SecIndex = File.getObj().getExtendedSymbolTableIndex( |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 432 | Sym, File.getSymbolTable(), File.getSymbolTableShndx()); |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 433 | ArrayRef<InputSection<ELFT> *> Sections = File.getSections(); |
| 434 | InputSection<ELFT> *Section = Sections[SecIndex]; |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 435 | |
| 436 | // According to the ELF spec reference to a local symbol from outside |
| 437 | // the group are not allowed. Unfortunately .eh_frame breaks that rule |
| 438 | // and must be treated specially. For now we just replace the symbol with |
| 439 | // 0. |
| 440 | if (Section == &InputSection<ELFT>::Discarded) |
| 441 | return 0; |
| 442 | |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 443 | OutputSection<ELFT> *OutSec = Section->getOutputSection(); |
| 444 | return OutSec->getVA() + Section->getOutputSectionOff() + Sym->st_value; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 445 | } |
| 446 | |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 447 | bool lld::elf2::canBePreempted(const SymbolBody *Body) { |
| 448 | if (!Body) |
| 449 | return false; |
Rafael Espindola | cea0b3b | 2015-10-07 04:22:55 +0000 | [diff] [blame] | 450 | if (Body->isShared()) |
| 451 | return true; |
| 452 | if (Body->isUndefined() && !Body->isWeak()) |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 453 | return true; |
| 454 | if (!Config->Shared) |
| 455 | return false; |
Rafael Espindola | 52dca34 | 2015-10-07 00:58:20 +0000 | [diff] [blame] | 456 | return Body->getMostConstrainingVisibility() == STV_DEFAULT; |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 457 | } |
| 458 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 459 | template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 460 | for (InputSection<ELFT> *C : Sections) |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 461 | C->writeTo(Buf); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | template <bool Is64Bits> |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 465 | StringTableSection<Is64Bits>::StringTableSection(bool Dynamic) |
| 466 | : OutputSectionBase<Is64Bits>(Dynamic ? ".dynstr" : ".strtab", |
| 467 | llvm::ELF::SHT_STRTAB, |
| 468 | Dynamic ? (uintX_t)llvm::ELF::SHF_ALLOC : 0), |
| 469 | Dynamic(Dynamic) { |
| 470 | this->Header.sh_addralign = 1; |
| 471 | } |
| 472 | |
| 473 | template <bool Is64Bits> |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 474 | void StringTableSection<Is64Bits>::writeTo(uint8_t *Buf) { |
| 475 | StringRef Data = StrTabBuilder.data(); |
| 476 | memcpy(Buf, Data.data(), Data.size()); |
| 477 | } |
| 478 | |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 479 | template <class ELFT> bool lld::elf2::includeInSymtab(const SymbolBody &B) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 480 | if (!B.isUsedInRegularObj()) |
| 481 | return false; |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 482 | |
| 483 | // Don't include synthetic symbols like __init_array_start in every output. |
| 484 | if (auto *U = dyn_cast<DefinedAbsolute<ELFT>>(&B)) |
| 485 | if (&U->Sym == &DefinedAbsolute<ELFT>::IgnoreUndef) |
| 486 | return false; |
| 487 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 488 | return true; |
| 489 | } |
| 490 | |
Rafael Espindola | 05a3dd2 | 2015-09-22 23:38:23 +0000 | [diff] [blame] | 491 | bool lld::elf2::includeInDynamicSymtab(const SymbolBody &B) { |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 492 | uint8_t V = B.getMostConstrainingVisibility(); |
| 493 | if (V != STV_DEFAULT && V != STV_PROTECTED) |
| 494 | return false; |
| 495 | |
Rafael Espindola | 05a3dd2 | 2015-09-22 23:38:23 +0000 | [diff] [blame] | 496 | if (Config->ExportDynamic || Config->Shared) |
| 497 | return true; |
| 498 | return B.isUsedInDynamicReloc(); |
| 499 | } |
| 500 | |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 501 | template <class ELFT> |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 502 | bool lld::elf2::shouldKeepInSymtab(const ObjectFile<ELFT> &File, |
| 503 | StringRef SymName, |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 504 | const typename ELFFile<ELFT>::Elf_Sym &Sym) { |
| 505 | if (Sym.getType() == STT_SECTION) |
| 506 | return false; |
| 507 | |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 508 | // If sym references a section in a discarded group, don't keep it. |
| 509 | uint32_t SecIndex = Sym.st_shndx; |
| 510 | if (SecIndex != SHN_ABS) { |
| 511 | if (SecIndex == SHN_XINDEX) |
| 512 | SecIndex = File.getObj().getExtendedSymbolTableIndex( |
| 513 | &Sym, File.getSymbolTable(), File.getSymbolTableShndx()); |
| 514 | ArrayRef<InputSection<ELFT> *> Sections = File.getSections(); |
| 515 | const InputSection<ELFT> *Section = Sections[SecIndex]; |
| 516 | if (Section == &InputSection<ELFT>::Discarded) |
| 517 | return false; |
| 518 | } |
| 519 | |
Davide Italiano | 6993ba4 | 2015-09-26 00:47:56 +0000 | [diff] [blame] | 520 | if (Config->DiscardNone) |
| 521 | return true; |
| 522 | |
| 523 | // ELF defines dynamic locals as symbols which name starts with ".L". |
| 524 | return !(Config->DiscardLocals && SymName.startswith(".L")); |
| 525 | } |
| 526 | |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 527 | template <class ELFT> |
| 528 | SymbolTableSection<ELFT>::SymbolTableSection( |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 529 | SymbolTable<ELFT> &Table, StringTableSection<ELFT::Is64Bits> &StrTabSec) |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 530 | : OutputSectionBase<ELFT::Is64Bits>( |
| 531 | StrTabSec.isDynamic() ? ".dynsym" : ".symtab", |
| 532 | StrTabSec.isDynamic() ? llvm::ELF::SHT_DYNSYM : llvm::ELF::SHT_SYMTAB, |
| 533 | StrTabSec.isDynamic() ? (uintX_t)llvm::ELF::SHF_ALLOC : 0), |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 534 | Table(Table), StrTabSec(StrTabSec) { |
Rafael Espindola | 35c6af3 | 2015-09-25 17:19:10 +0000 | [diff] [blame] | 535 | typedef OutputSectionBase<ELFT::Is64Bits> Base; |
| 536 | typename Base::HeaderT &Header = this->Header; |
| 537 | |
| 538 | Header.sh_entsize = sizeof(Elf_Sym); |
| 539 | Header.sh_addralign = ELFT::Is64Bits ? 8 : 4; |
| 540 | } |
| 541 | |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 542 | template <class ELFT> void SymbolTableSection<ELFT>::finalize() { |
| 543 | this->Header.sh_size = getNumSymbols() * sizeof(Elf_Sym); |
| 544 | this->Header.sh_link = StrTabSec.getSectionIndex(); |
| 545 | this->Header.sh_info = NumLocals + 1; |
| 546 | } |
| 547 | |
| 548 | template <class ELFT> |
| 549 | void SymbolTableSection<ELFT>::addSymbol(StringRef Name, bool isLocal) { |
| 550 | StrTabSec.add(Name); |
| 551 | ++NumVisible; |
| 552 | if (isLocal) |
| 553 | ++NumLocals; |
| 554 | } |
| 555 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 556 | template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 557 | Buf += sizeof(Elf_Sym); |
| 558 | |
| 559 | // All symbols with STB_LOCAL binding precede the weak and global symbols. |
| 560 | // .dynsym only contains global symbols. |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 561 | if (!Config->DiscardAll && !StrTabSec.isDynamic()) |
| 562 | writeLocalSymbols(Buf); |
| 563 | |
| 564 | writeGlobalSymbols(Buf); |
| 565 | } |
| 566 | |
| 567 | template <class ELFT> |
| 568 | void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) { |
| 569 | // Iterate over all input object files to copy their local symbols |
| 570 | // to the output symbol table pointed by Buf. |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 571 | for (const std::unique_ptr<ObjectFile<ELFT>> &File : Table.getObjectFiles()) { |
| 572 | Elf_Sym_Range Syms = File->getLocalSymbols(); |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 573 | for (const Elf_Sym &Sym : Syms) { |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 574 | ErrorOr<StringRef> SymNameOrErr = Sym.getName(File->getStringTable()); |
Rafael Espindola | 26fd69d | 2015-10-09 16:15:57 +0000 | [diff] [blame] | 575 | error(SymNameOrErr); |
| 576 | StringRef SymName = *SymNameOrErr; |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 577 | if (!shouldKeepInSymtab<ELFT>(*File, SymName, Sym)) |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 578 | continue; |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 579 | |
Rui Ueyama | c55733e | 2015-09-30 00:54:29 +0000 | [diff] [blame] | 580 | auto *ESym = reinterpret_cast<Elf_Sym *>(Buf); |
| 581 | Buf += sizeof(*ESym); |
Rafael Espindola | 26fd69d | 2015-10-09 16:15:57 +0000 | [diff] [blame] | 582 | ESym->st_name = StrTabSec.getFileOff(SymName); |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 583 | ESym->st_size = Sym.st_size; |
| 584 | ESym->setBindingAndType(Sym.getBinding(), Sym.getType()); |
| 585 | uint32_t SecIndex = Sym.st_shndx; |
| 586 | uintX_t VA = Sym.st_value; |
| 587 | if (SecIndex == SHN_ABS) { |
| 588 | ESym->st_shndx = SHN_ABS; |
| 589 | } else { |
| 590 | if (SecIndex == SHN_XINDEX) |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 591 | SecIndex = File->getObj().getExtendedSymbolTableIndex( |
| 592 | &Sym, File->getSymbolTable(), File->getSymbolTableShndx()); |
| 593 | ArrayRef<InputSection<ELFT> *> Sections = File->getSections(); |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 594 | const InputSection<ELFT> *Section = Sections[SecIndex]; |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 595 | const OutputSection<ELFT> *OutSec = Section->getOutputSection(); |
| 596 | ESym->st_shndx = OutSec->getSectionIndex(); |
| 597 | VA += OutSec->getVA() + Section->getOutputSectionOff(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 598 | } |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 599 | ESym->st_value = VA; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 600 | } |
| 601 | } |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 602 | } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 603 | |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 604 | template <class ELFT> |
| 605 | void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *&Buf) { |
| 606 | // Write the internal symbol table contents to the output symbol table |
| 607 | // pointed by Buf. |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 608 | uint8_t *Start = Buf; |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 609 | for (const std::pair<StringRef, Symbol *> &P : Table.getSymbols()) { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 610 | StringRef Name = P.first; |
| 611 | Symbol *Sym = P.second; |
| 612 | SymbolBody *Body = Sym->Body; |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 613 | if (!includeInSymtab<ELFT>(*Body)) |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 614 | continue; |
Rafael Espindola | 05a3dd2 | 2015-09-22 23:38:23 +0000 | [diff] [blame] | 615 | if (StrTabSec.isDynamic() && !includeInDynamicSymtab(*Body)) |
| 616 | continue; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 617 | |
| 618 | auto *ESym = reinterpret_cast<Elf_Sym *>(Buf); |
Rui Ueyama | c55733e | 2015-09-30 00:54:29 +0000 | [diff] [blame] | 619 | Buf += sizeof(*ESym); |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 620 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 621 | ESym->st_name = StrTabSec.getFileOff(Name); |
| 622 | |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 623 | const OutputSection<ELFT> *OutSec = nullptr; |
Rafael Espindola | 25b0acb | 2015-09-25 17:32:37 +0000 | [diff] [blame] | 624 | const InputSection<ELFT> *Section = nullptr; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 625 | |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 626 | switch (Body->kind()) { |
Rafael Espindola | 0e604f9 | 2015-09-25 18:56:53 +0000 | [diff] [blame] | 627 | case SymbolBody::DefinedSyntheticKind: |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 628 | OutSec = &cast<DefinedSynthetic<ELFT>>(Body)->Section; |
Rafael Espindola | 0e604f9 | 2015-09-25 18:56:53 +0000 | [diff] [blame] | 629 | break; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 630 | case SymbolBody::DefinedRegularKind: |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 631 | Section = &cast<DefinedRegular<ELFT>>(Body)->Section; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 632 | break; |
| 633 | case SymbolBody::DefinedCommonKind: |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 634 | OutSec = Out<ELFT>::Bss; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 635 | break; |
| 636 | case SymbolBody::UndefinedKind: |
| 637 | case SymbolBody::DefinedAbsoluteKind: |
| 638 | case SymbolBody::SharedKind: |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 639 | case SymbolBody::LazyKind: |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 640 | break; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 641 | } |
| 642 | |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 643 | unsigned char Binding = Body->isWeak() ? STB_WEAK : STB_GLOBAL; |
| 644 | unsigned char Type = STT_NOTYPE; |
| 645 | uintX_t Size = 0; |
| 646 | if (const auto *EBody = dyn_cast<ELFSymbolBody<ELFT>>(Body)) { |
| 647 | const Elf_Sym &InputSym = EBody->Sym; |
| 648 | Binding = InputSym.getBinding(); |
| 649 | Type = InputSym.getType(); |
| 650 | Size = InputSym.st_size; |
| 651 | } |
| 652 | |
| 653 | unsigned char Visibility = Body->getMostConstrainingVisibility(); |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 654 | if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED) |
| 655 | Binding = STB_LOCAL; |
| 656 | |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 657 | ESym->setBindingAndType(Binding, Type); |
| 658 | ESym->st_size = Size; |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 659 | ESym->setVisibility(Visibility); |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 660 | ESym->st_value = getSymVA<ELFT>(*Body); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 661 | |
| 662 | if (Section) |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 663 | OutSec = Section->getOutputSection(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 664 | |
Rafael Espindola | 8614c56 | 2015-10-06 14:33:58 +0000 | [diff] [blame] | 665 | if (isa<DefinedAbsolute<ELFT>>(Body)) |
Rafael Espindola | 6f4bd53 | 2015-10-06 14:17:53 +0000 | [diff] [blame] | 666 | ESym->st_shndx = SHN_ABS; |
Rui Ueyama | b490876 | 2015-10-07 17:04:18 +0000 | [diff] [blame] | 667 | else if (OutSec) |
| 668 | ESym->st_shndx = OutSec->getSectionIndex(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 669 | } |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 670 | if (!StrTabSec.isDynamic()) |
| 671 | std::stable_sort( |
| 672 | reinterpret_cast<Elf_Sym *>(Start), reinterpret_cast<Elf_Sym *>(Buf), |
| 673 | [](const Elf_Sym &A, const Elf_Sym &B) -> bool { |
| 674 | return A.getBinding() == STB_LOCAL && B.getBinding() != STB_LOCAL; |
| 675 | }); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | namespace lld { |
| 679 | namespace elf2 { |
| 680 | template class OutputSectionBase<false>; |
| 681 | template class OutputSectionBase<true>; |
| 682 | |
| 683 | template void OutputSectionBase<false>::writeHeaderTo<support::little>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 684 | ELFFile<ELFType<support::little, false>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 685 | template void OutputSectionBase<true>::writeHeaderTo<support::little>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 686 | ELFFile<ELFType<support::little, true>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 687 | template void OutputSectionBase<false>::writeHeaderTo<support::big>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 688 | ELFFile<ELFType<support::big, false>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 689 | template void OutputSectionBase<true>::writeHeaderTo<support::big>( |
Rafael Espindola | f68b707 | 2015-09-21 22:21:46 +0000 | [diff] [blame] | 690 | ELFFile<ELFType<support::big, true>>::Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 691 | |
| 692 | template class GotSection<ELF32LE>; |
| 693 | template class GotSection<ELF32BE>; |
| 694 | template class GotSection<ELF64LE>; |
| 695 | template class GotSection<ELF64BE>; |
| 696 | |
| 697 | template class PltSection<ELF32LE>; |
| 698 | template class PltSection<ELF32BE>; |
| 699 | template class PltSection<ELF64LE>; |
| 700 | template class PltSection<ELF64BE>; |
| 701 | |
| 702 | template class RelocationSection<ELF32LE>; |
| 703 | template class RelocationSection<ELF32BE>; |
| 704 | template class RelocationSection<ELF64LE>; |
| 705 | template class RelocationSection<ELF64BE>; |
| 706 | |
| 707 | template class InterpSection<false>; |
| 708 | template class InterpSection<true>; |
| 709 | |
| 710 | template class HashTableSection<ELF32LE>; |
| 711 | template class HashTableSection<ELF32BE>; |
| 712 | template class HashTableSection<ELF64LE>; |
| 713 | template class HashTableSection<ELF64BE>; |
| 714 | |
| 715 | template class DynamicSection<ELF32LE>; |
| 716 | template class DynamicSection<ELF32BE>; |
| 717 | template class DynamicSection<ELF64LE>; |
| 718 | template class DynamicSection<ELF64BE>; |
| 719 | |
| 720 | template class OutputSection<ELF32LE>; |
| 721 | template class OutputSection<ELF32BE>; |
| 722 | template class OutputSection<ELF64LE>; |
| 723 | template class OutputSection<ELF64BE>; |
| 724 | |
| 725 | template class StringTableSection<false>; |
| 726 | template class StringTableSection<true>; |
| 727 | |
| 728 | template class SymbolTableSection<ELF32LE>; |
| 729 | template class SymbolTableSection<ELF32BE>; |
| 730 | template class SymbolTableSection<ELF64LE>; |
| 731 | template class SymbolTableSection<ELF64BE>; |
| 732 | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 733 | template ELFFile<ELF32LE>::uintX_t getSymVA<ELF32LE>(const SymbolBody &); |
| 734 | template ELFFile<ELF32BE>::uintX_t getSymVA<ELF32BE>(const SymbolBody &); |
| 735 | template ELFFile<ELF64LE>::uintX_t getSymVA<ELF64LE>(const SymbolBody &); |
| 736 | template ELFFile<ELF64BE>::uintX_t getSymVA<ELF64BE>(const SymbolBody &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 737 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 738 | template ELFFile<ELF32LE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 739 | getLocalSymVA(const ELFFile<ELF32LE>::Elf_Sym *, const ObjectFile<ELF32LE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 740 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 741 | template ELFFile<ELF32BE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 742 | getLocalSymVA(const ELFFile<ELF32BE>::Elf_Sym *, const ObjectFile<ELF32BE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 743 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 744 | template ELFFile<ELF64LE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 745 | getLocalSymVA(const ELFFile<ELF64LE>::Elf_Sym *, const ObjectFile<ELF64LE> &); |
Rafael Espindola | 4ea0021 | 2015-09-21 22:01:00 +0000 | [diff] [blame] | 746 | |
Rafael Espindola | 56f965f | 2015-09-21 22:48:12 +0000 | [diff] [blame] | 747 | template ELFFile<ELF64BE>::uintX_t |
Rui Ueyama | b189b5c | 2015-09-30 00:43:22 +0000 | [diff] [blame] | 748 | getLocalSymVA(const ELFFile<ELF64BE>::Elf_Sym *, const ObjectFile<ELF64BE> &); |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 749 | |
| 750 | template bool includeInSymtab<ELF32LE>(const SymbolBody &); |
| 751 | template bool includeInSymtab<ELF32BE>(const SymbolBody &); |
| 752 | template bool includeInSymtab<ELF64LE>(const SymbolBody &); |
| 753 | template bool includeInSymtab<ELF64BE>(const SymbolBody &); |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 754 | |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 755 | template bool shouldKeepInSymtab<ELF32LE>(const ObjectFile<ELF32LE> &, |
| 756 | StringRef, |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 757 | const ELFFile<ELF32LE>::Elf_Sym &); |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 758 | template bool shouldKeepInSymtab<ELF32BE>(const ObjectFile<ELF32BE> &, |
| 759 | StringRef, |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 760 | const ELFFile<ELF32BE>::Elf_Sym &); |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 761 | template bool shouldKeepInSymtab<ELF64LE>(const ObjectFile<ELF64LE> &, |
| 762 | StringRef, |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 763 | const ELFFile<ELF64LE>::Elf_Sym &); |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 764 | template bool shouldKeepInSymtab<ELF64BE>(const ObjectFile<ELF64BE> &, |
| 765 | StringRef, |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 766 | const ELFFile<ELF64BE>::Elf_Sym &); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 767 | } |
| 768 | } |