1 //===- SyntheticSection.h ---------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Synthetic sections represent chunks of linker-created data. If you 10 // need to create a chunk of data that to be included in some section 11 // in the result, you probably want to create that as a synthetic section. 12 // 13 // Synthetic sections are designed as input sections as opposed to 14 // output sections because we want to allow them to be manipulated 15 // using linker scripts just like other input sections from regular 16 // files. 17 // 18 //===----------------------------------------------------------------------===// 19 20 #ifndef LLD_ELF_SYNTHETIC_SECTIONS_H 21 #define LLD_ELF_SYNTHETIC_SECTIONS_H 22 23 #include "DWARF.h" 24 #include "EhFrame.h" 25 #include "InputSection.h" 26 #include "llvm/ADT/DenseSet.h" 27 #include "llvm/ADT/MapVector.h" 28 #include "llvm/MC/StringTableBuilder.h" 29 #include "llvm/Support/Endian.h" 30 #include <functional> 31 32 namespace lld { 33 namespace elf { 34 class Defined; 35 struct PhdrEntry; 36 class SymbolTableBaseSection; 37 38 class SyntheticSection : public InputSection { 39 public: 40 SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment, 41 StringRef name) 42 : InputSection(nullptr, flags, type, alignment, {}, name, 43 InputSectionBase::Synthetic) {} 44 45 virtual ~SyntheticSection() = default; 46 virtual void writeTo(uint8_t *buf) = 0; 47 virtual size_t getSize() const = 0; 48 virtual void finalizeContents() {} 49 // If the section has the SHF_ALLOC flag and the size may be changed if 50 // thunks are added, update the section size. 51 virtual bool updateAllocSize() { return false; } 52 virtual bool isNeeded() const { return true; } 53 54 static bool classof(const SectionBase *d) { 55 return d->kind() == InputSectionBase::Synthetic; 56 } 57 }; 58 59 struct CieRecord { 60 EhSectionPiece *cie = nullptr; 61 SmallVector<EhSectionPiece *, 0> fdes; 62 }; 63 64 // Section for .eh_frame. 65 class EhFrameSection final : public SyntheticSection { 66 public: 67 EhFrameSection(); 68 void writeTo(uint8_t *buf) override; 69 void finalizeContents() override; 70 bool isNeeded() const override { return !sections.empty(); } 71 size_t getSize() const override { return size; } 72 73 static bool classof(const SectionBase *d) { 74 return SyntheticSection::classof(d) && d->name == ".eh_frame"; 75 } 76 77 void addSection(EhInputSection *sec); 78 79 SmallVector<EhInputSection *, 0> sections; 80 size_t numFdes = 0; 81 82 struct FdeData { 83 uint32_t pcRel; 84 uint32_t fdeVARel; 85 }; 86 87 SmallVector<FdeData, 0> getFdeData() const; 88 ArrayRef<CieRecord *> getCieRecords() const { return cieRecords; } 89 template <class ELFT> 90 void iterateFDEWithLSDA(llvm::function_ref<void(InputSection &)> fn); 91 92 private: 93 // This is used only when parsing EhInputSection. We keep it here to avoid 94 // allocating one for each EhInputSection. 95 llvm::DenseMap<size_t, CieRecord *> offsetToCie; 96 97 uint64_t size = 0; 98 99 template <class ELFT, class RelTy> 100 void addRecords(EhInputSection *s, llvm::ArrayRef<RelTy> rels); 101 template <class ELFT> void addSectionAux(EhInputSection *s); 102 template <class ELFT, class RelTy> 103 void iterateFDEWithLSDAAux(EhInputSection &sec, ArrayRef<RelTy> rels, 104 llvm::DenseSet<size_t> &ciesWithLSDA, 105 llvm::function_ref<void(InputSection &)> fn); 106 107 template <class ELFT, class RelTy> 108 CieRecord *addCie(EhSectionPiece &piece, ArrayRef<RelTy> rels); 109 110 template <class ELFT, class RelTy> 111 Defined *isFdeLive(EhSectionPiece &piece, ArrayRef<RelTy> rels); 112 113 uint64_t getFdePc(uint8_t *buf, size_t off, uint8_t enc) const; 114 115 SmallVector<CieRecord *, 0> cieRecords; 116 117 // CIE records are uniquified by their contents and personality functions. 118 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, Symbol *>, CieRecord *> cieMap; 119 }; 120 121 class GotSection : public SyntheticSection { 122 public: 123 GotSection(); 124 size_t getSize() const override { return size; } 125 void finalizeContents() override; 126 bool isNeeded() const override; 127 void writeTo(uint8_t *buf) override; 128 129 void addEntry(Symbol &sym); 130 bool addTlsDescEntry(Symbol &sym); 131 bool addDynTlsEntry(Symbol &sym); 132 bool addTlsIndex(); 133 uint32_t getTlsDescOffset(const Symbol &sym) const; 134 uint64_t getTlsDescAddr(const Symbol &sym) const; 135 uint64_t getGlobalDynAddr(const Symbol &b) const; 136 uint64_t getGlobalDynOffset(const Symbol &b) const; 137 138 uint64_t getTlsIndexVA() { return this->getVA() + tlsIndexOff; } 139 uint32_t getTlsIndexOff() const { return tlsIndexOff; } 140 141 // Flag to force GOT to be in output if we have relocations 142 // that relies on its address. 143 bool hasGotOffRel = false; 144 145 protected: 146 size_t numEntries = 0; 147 uint32_t tlsIndexOff = -1; 148 uint64_t size = 0; 149 }; 150 151 // .note.GNU-stack section. 152 class GnuStackSection : public SyntheticSection { 153 public: 154 GnuStackSection() 155 : SyntheticSection(0, llvm::ELF::SHT_PROGBITS, 1, ".note.GNU-stack") {} 156 void writeTo(uint8_t *buf) override {} 157 size_t getSize() const override { return 0; } 158 }; 159 160 class GnuPropertySection : public SyntheticSection { 161 public: 162 GnuPropertySection(); 163 void writeTo(uint8_t *buf) override; 164 size_t getSize() const override; 165 }; 166 167 // .note.gnu.build-id section. 168 class BuildIdSection : public SyntheticSection { 169 // First 16 bytes are a header. 170 static const unsigned headerSize = 16; 171 172 public: 173 const size_t hashSize; 174 BuildIdSection(); 175 void writeTo(uint8_t *buf) override; 176 size_t getSize() const override { return headerSize + hashSize; } 177 void writeBuildId(llvm::ArrayRef<uint8_t> buf); 178 179 private: 180 uint8_t *hashBuf; 181 }; 182 183 // BssSection is used to reserve space for copy relocations and common symbols. 184 // We create three instances of this class for .bss, .bss.rel.ro and "COMMON", 185 // that are used for writable symbols, read-only symbols and common symbols, 186 // respectively. 187 class BssSection final : public SyntheticSection { 188 public: 189 BssSection(StringRef name, uint64_t size, uint32_t alignment); 190 void writeTo(uint8_t *) override {} 191 bool isNeeded() const override { return size != 0; } 192 size_t getSize() const override { return size; } 193 194 static bool classof(const SectionBase *s) { return s->bss; } 195 uint64_t size; 196 }; 197 198 class MipsGotSection final : public SyntheticSection { 199 public: 200 MipsGotSection(); 201 void writeTo(uint8_t *buf) override; 202 size_t getSize() const override { return size; } 203 bool updateAllocSize() override; 204 void finalizeContents() override; 205 bool isNeeded() const override; 206 207 // Join separate GOTs built for each input file to generate 208 // primary and optional multiple secondary GOTs. 209 void build(); 210 211 void addEntry(InputFile &file, Symbol &sym, int64_t addend, RelExpr expr); 212 void addDynTlsEntry(InputFile &file, Symbol &sym); 213 void addTlsIndex(InputFile &file); 214 215 uint64_t getPageEntryOffset(const InputFile *f, const Symbol &s, 216 int64_t addend) const; 217 uint64_t getSymEntryOffset(const InputFile *f, const Symbol &s, 218 int64_t addend) const; 219 uint64_t getGlobalDynOffset(const InputFile *f, const Symbol &s) const; 220 uint64_t getTlsIndexOffset(const InputFile *f) const; 221 222 // Returns the symbol which corresponds to the first entry of the global part 223 // of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic 224 // table properties. 225 // Returns nullptr if the global part is empty. 226 const Symbol *getFirstGlobalEntry() const; 227 228 // Returns the number of entries in the local part of GOT including 229 // the number of reserved entries. 230 unsigned getLocalEntriesNum() const; 231 232 // Return _gp value for primary GOT (nullptr) or particular input file. 233 uint64_t getGp(const InputFile *f = nullptr) const; 234 235 private: 236 // MIPS GOT consists of three parts: local, global and tls. Each part 237 // contains different types of entries. Here is a layout of GOT: 238 // - Header entries | 239 // - Page entries | Local part 240 // - Local entries (16-bit access) | 241 // - Local entries (32-bit access) | 242 // - Normal global entries || Global part 243 // - Reloc-only global entries || 244 // - TLS entries ||| TLS part 245 // 246 // Header: 247 // Two entries hold predefined value 0x0 and 0x80000000. 248 // Page entries: 249 // These entries created by R_MIPS_GOT_PAGE relocation and R_MIPS_GOT16 250 // relocation against local symbols. They are initialized by higher 16-bit 251 // of the corresponding symbol's value. So each 64kb of address space 252 // requires a single GOT entry. 253 // Local entries (16-bit access): 254 // These entries created by GOT relocations against global non-preemptible 255 // symbols so dynamic linker is not necessary to resolve the symbol's 256 // values. "16-bit access" means that corresponding relocations address 257 // GOT using 16-bit index. Each unique Symbol-Addend pair has its own 258 // GOT entry. 259 // Local entries (32-bit access): 260 // These entries are the same as above but created by relocations which 261 // address GOT using 32-bit index (R_MIPS_GOT_HI16/LO16 etc). 262 // Normal global entries: 263 // These entries created by GOT relocations against preemptible global 264 // symbols. They need to be initialized by dynamic linker and they ordered 265 // exactly as the corresponding entries in the dynamic symbols table. 266 // Reloc-only global entries: 267 // These entries created for symbols that are referenced by dynamic 268 // relocations R_MIPS_REL32. These entries are not accessed with gp-relative 269 // addressing, but MIPS ABI requires that these entries be present in GOT. 270 // TLS entries: 271 // Entries created by TLS relocations. 272 // 273 // If the sum of local, global and tls entries is less than 64K only single 274 // got is enough. Otherwise, multi-got is created. Series of primary and 275 // multiple secondary GOTs have the following layout: 276 // - Primary GOT 277 // Header 278 // Local entries 279 // Global entries 280 // Relocation only entries 281 // TLS entries 282 // 283 // - Secondary GOT 284 // Local entries 285 // Global entries 286 // TLS entries 287 // ... 288 // 289 // All GOT entries required by relocations from a single input file entirely 290 // belong to either primary or one of secondary GOTs. To reference GOT entries 291 // each GOT has its own _gp value points to the "middle" of the GOT. 292 // In the code this value loaded to the register which is used for GOT access. 293 // 294 // MIPS 32 function's prologue: 295 // lui v0,0x0 296 // 0: R_MIPS_HI16 _gp_disp 297 // addiu v0,v0,0 298 // 4: R_MIPS_LO16 _gp_disp 299 // 300 // MIPS 64: 301 // lui at,0x0 302 // 14: R_MIPS_GPREL16 main 303 // 304 // Dynamic linker does not know anything about secondary GOTs and cannot 305 // use a regular MIPS mechanism for GOT entries initialization. So we have 306 // to use an approach accepted by other architectures and create dynamic 307 // relocations R_MIPS_REL32 to initialize global entries (and local in case 308 // of PIC code) in secondary GOTs. But ironically MIPS dynamic linker 309 // requires GOT entries and correspondingly ordered dynamic symbol table 310 // entries to deal with dynamic relocations. To handle this problem 311 // relocation-only section in the primary GOT contains entries for all 312 // symbols referenced in global parts of secondary GOTs. Although the sum 313 // of local and normal global entries of the primary got should be less 314 // than 64K, the size of the primary got (including relocation-only entries 315 // can be greater than 64K, because parts of the primary got that overflow 316 // the 64K limit are used only by the dynamic linker at dynamic link-time 317 // and not by 16-bit gp-relative addressing at run-time. 318 // 319 // For complete multi-GOT description see the following link 320 // https://dmz-portal.mips.com/wiki/MIPS_Multi_GOT 321 322 // Number of "Header" entries. 323 static const unsigned headerEntriesNum = 2; 324 325 uint64_t size = 0; 326 327 // Symbol and addend. 328 using GotEntry = std::pair<Symbol *, int64_t>; 329 330 struct FileGot { 331 InputFile *file = nullptr; 332 size_t startIndex = 0; 333 334 struct PageBlock { 335 size_t firstIndex; 336 size_t count; 337 PageBlock() : firstIndex(0), count(0) {} 338 }; 339 340 // Map output sections referenced by MIPS GOT relocations 341 // to the description (index/count) "page" entries allocated 342 // for this section. 343 llvm::SmallMapVector<const OutputSection *, PageBlock, 16> pagesMap; 344 // Maps from Symbol+Addend pair or just Symbol to the GOT entry index. 345 llvm::MapVector<GotEntry, size_t> local16; 346 llvm::MapVector<GotEntry, size_t> local32; 347 llvm::MapVector<Symbol *, size_t> global; 348 llvm::MapVector<Symbol *, size_t> relocs; 349 llvm::MapVector<Symbol *, size_t> tls; 350 // Set of symbols referenced by dynamic TLS relocations. 351 llvm::MapVector<Symbol *, size_t> dynTlsSymbols; 352 353 // Total number of all entries. 354 size_t getEntriesNum() const; 355 // Number of "page" entries. 356 size_t getPageEntriesNum() const; 357 // Number of entries require 16-bit index to access. 358 size_t getIndexedEntriesNum() const; 359 }; 360 361 // Container of GOT created for each input file. 362 // After building a final series of GOTs this container 363 // holds primary and secondary GOT's. 364 std::vector<FileGot> gots; 365 366 // Return (and create if necessary) `FileGot`. 367 FileGot &getGot(InputFile &f); 368 369 // Try to merge two GOTs. In case of success the `Dst` contains 370 // result of merging and the function returns true. In case of 371 // overflow the `Dst` is unchanged and the function returns false. 372 bool tryMergeGots(FileGot & dst, FileGot & src, bool isPrimary); 373 }; 374 375 class GotPltSection final : public SyntheticSection { 376 public: 377 GotPltSection(); 378 void addEntry(Symbol &sym); 379 size_t getSize() const override; 380 void writeTo(uint8_t *buf) override; 381 bool isNeeded() const override; 382 383 // Flag to force GotPlt to be in output if we have relocations 384 // that relies on its address. 385 bool hasGotPltOffRel = false; 386 387 private: 388 SmallVector<const Symbol *, 0> entries; 389 }; 390 391 // The IgotPltSection is a Got associated with the PltSection for GNU Ifunc 392 // Symbols that will be relocated by Target->IRelativeRel. 393 // On most Targets the IgotPltSection will immediately follow the GotPltSection 394 // on ARM the IgotPltSection will immediately follow the GotSection. 395 class IgotPltSection final : public SyntheticSection { 396 public: 397 IgotPltSection(); 398 void addEntry(Symbol &sym); 399 size_t getSize() const override; 400 void writeTo(uint8_t *buf) override; 401 bool isNeeded() const override { return !entries.empty(); } 402 403 private: 404 SmallVector<const Symbol *, 0> entries; 405 }; 406 407 class StringTableSection final : public SyntheticSection { 408 public: 409 StringTableSection(StringRef name, bool dynamic); 410 unsigned addString(StringRef s, bool hashIt = true); 411 void writeTo(uint8_t *buf) override; 412 size_t getSize() const override { return size; } 413 bool isDynamic() const { return dynamic; } 414 415 private: 416 const bool dynamic; 417 418 uint64_t size = 0; 419 420 llvm::DenseMap<llvm::CachedHashStringRef, unsigned> stringMap; 421 SmallVector<StringRef, 0> strings; 422 }; 423 424 class DynamicReloc { 425 public: 426 enum Kind { 427 /// The resulting dynamic relocation does not reference a symbol (#sym must 428 /// be nullptr) and uses #addend as the result of computeAddend(). 429 AddendOnly, 430 /// The resulting dynamic relocation will not reference a symbol: #sym is 431 /// only used to compute the addend with InputSection::getRelocTargetVA(). 432 /// Useful for various relative and TLS relocations (e.g. R_X86_64_TPOFF64). 433 AddendOnlyWithTargetVA, 434 /// The resulting dynamic relocation references symbol #sym from the dynamic 435 /// symbol table and uses #addend as the value of computeAddend(). 436 AgainstSymbol, 437 /// The resulting dynamic relocation references symbol #sym from the dynamic 438 /// symbol table and uses InputSection::getRelocTargetVA() + #addend for the 439 /// final addend. It can be used for relocations that write the symbol VA as 440 // the addend (e.g. R_MIPS_TLS_TPREL64) but still reference the symbol. 441 AgainstSymbolWithTargetVA, 442 /// This is used by the MIPS multi-GOT implementation. It relocates 443 /// addresses of 64kb pages that lie inside the output section. 444 MipsMultiGotPage, 445 }; 446 /// This constructor records a relocation against a symbol. 447 DynamicReloc(RelType type, const InputSectionBase *inputSec, 448 uint64_t offsetInSec, Kind kind, Symbol &sym, int64_t addend, 449 RelExpr expr) 450 : sym(&sym), inputSec(inputSec), offsetInSec(offsetInSec), type(type), 451 addend(addend), kind(kind), expr(expr) {} 452 /// This constructor records a relative relocation with no symbol. 453 DynamicReloc(RelType type, const InputSectionBase *inputSec, 454 uint64_t offsetInSec, int64_t addend = 0) 455 : sym(nullptr), inputSec(inputSec), offsetInSec(offsetInSec), type(type), 456 addend(addend), kind(AddendOnly), expr(R_ADDEND) {} 457 /// This constructor records dynamic relocation settings used by the MIPS 458 /// multi-GOT implementation. 459 DynamicReloc(RelType type, const InputSectionBase *inputSec, 460 uint64_t offsetInSec, const OutputSection *outputSec, 461 int64_t addend) 462 : sym(nullptr), outputSec(outputSec), inputSec(inputSec), 463 offsetInSec(offsetInSec), type(type), addend(addend), 464 kind(MipsMultiGotPage), expr(R_ADDEND) {} 465 466 uint64_t getOffset() const; 467 uint32_t getSymIndex(SymbolTableBaseSection *symTab) const; 468 bool needsDynSymIndex() const { 469 return kind == AgainstSymbol || kind == AgainstSymbolWithTargetVA; 470 } 471 472 /// Computes the addend of the dynamic relocation. Note that this is not the 473 /// same as the #addend member variable as it may also include the symbol 474 /// address/the address of the corresponding GOT entry/etc. 475 int64_t computeAddend() const; 476 477 void computeRaw(SymbolTableBaseSection *symtab); 478 479 Symbol *sym; 480 const OutputSection *outputSec = nullptr; 481 const InputSectionBase *inputSec; 482 uint64_t offsetInSec; 483 uint64_t r_offset; 484 RelType type; 485 uint32_t r_sym; 486 // Initially input addend, then the output addend after 487 // RelocationSection<ELFT>::writeTo. 488 int64_t addend; 489 490 private: 491 Kind kind; 492 // The kind of expression used to calculate the added (required e.g. for 493 // relative GOT relocations). 494 RelExpr expr; 495 }; 496 497 template <class ELFT> class DynamicSection final : public SyntheticSection { 498 LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) 499 500 public: 501 DynamicSection(); 502 void finalizeContents() override; 503 void writeTo(uint8_t *buf) override; 504 size_t getSize() const override { return size; } 505 506 private: 507 std::vector<std::pair<int32_t, uint64_t>> computeContents(); 508 uint64_t size = 0; 509 }; 510 511 class RelocationBaseSection : public SyntheticSection { 512 public: 513 RelocationBaseSection(StringRef name, uint32_t type, int32_t dynamicTag, 514 int32_t sizeDynamicTag, bool combreloc); 515 /// Add a dynamic relocation without writing an addend to the output section. 516 /// This overload can be used if the addends are written directly instead of 517 /// using relocations on the input section (e.g. MipsGotSection::writeTo()). 518 void addReloc(const DynamicReloc &reloc) { relocs.push_back(reloc); } 519 /// Add a dynamic relocation against \p sym with an optional addend. 520 void addSymbolReloc(RelType dynType, InputSectionBase &isec, 521 uint64_t offsetInSec, Symbol &sym, int64_t addend = 0, 522 llvm::Optional<RelType> addendRelType = llvm::None); 523 /// Add a relative dynamic relocation that uses the target address of \p sym 524 /// (i.e. InputSection::getRelocTargetVA()) + \p addend as the addend. 525 void addRelativeReloc(RelType dynType, InputSectionBase &isec, 526 uint64_t offsetInSec, Symbol &sym, int64_t addend, 527 RelType addendRelType, RelExpr expr); 528 /// Add a dynamic relocation using the target address of \p sym as the addend 529 /// if \p sym is non-preemptible. Otherwise add a relocation against \p sym. 530 void addAddendOnlyRelocIfNonPreemptible(RelType dynType, 531 InputSectionBase &isec, 532 uint64_t offsetInSec, Symbol &sym, 533 RelType addendRelType); 534 void addReloc(DynamicReloc::Kind kind, RelType dynType, 535 InputSectionBase &inputSec, uint64_t offsetInSec, Symbol &sym, 536 int64_t addend, RelExpr expr, RelType addendRelType); 537 bool isNeeded() const override { return !relocs.empty(); } 538 size_t getSize() const override { return relocs.size() * this->entsize; } 539 size_t getRelativeRelocCount() const { return numRelativeRelocs; } 540 void partitionRels(); 541 void finalizeContents() override; 542 static bool classof(const SectionBase *d) { 543 return SyntheticSection::classof(d) && 544 (d->type == llvm::ELF::SHT_RELA || d->type == llvm::ELF::SHT_REL || 545 d->type == llvm::ELF::SHT_RELR); 546 } 547 int32_t dynamicTag, sizeDynamicTag; 548 SmallVector<DynamicReloc, 0> relocs; 549 550 protected: 551 void computeRels(); 552 size_t numRelativeRelocs = 0; // used by -z combreloc 553 bool combreloc; 554 }; 555 556 template <class ELFT> 557 class RelocationSection final : public RelocationBaseSection { 558 using Elf_Rel = typename ELFT::Rel; 559 using Elf_Rela = typename ELFT::Rela; 560 561 public: 562 RelocationSection(StringRef name, bool combreloc); 563 void writeTo(uint8_t *buf) override; 564 }; 565 566 template <class ELFT> 567 class AndroidPackedRelocationSection final : public RelocationBaseSection { 568 using Elf_Rel = typename ELFT::Rel; 569 using Elf_Rela = typename ELFT::Rela; 570 571 public: 572 AndroidPackedRelocationSection(StringRef name); 573 574 bool updateAllocSize() override; 575 size_t getSize() const override { return relocData.size(); } 576 void writeTo(uint8_t *buf) override { 577 memcpy(buf, relocData.data(), relocData.size()); 578 } 579 580 private: 581 SmallVector<char, 0> relocData; 582 }; 583 584 struct RelativeReloc { 585 uint64_t getOffset() const { return inputSec->getVA(offsetInSec); } 586 587 const InputSectionBase *inputSec; 588 uint64_t offsetInSec; 589 }; 590 591 class RelrBaseSection : public SyntheticSection { 592 public: 593 RelrBaseSection(); 594 bool isNeeded() const override { return !relocs.empty(); } 595 SmallVector<RelativeReloc, 0> relocs; 596 }; 597 598 // RelrSection is used to encode offsets for relative relocations. 599 // Proposal for adding SHT_RELR sections to generic-abi is here: 600 // https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg 601 // For more details, see the comment in RelrSection::updateAllocSize(). 602 template <class ELFT> class RelrSection final : public RelrBaseSection { 603 using Elf_Relr = typename ELFT::Relr; 604 605 public: 606 RelrSection(); 607 608 bool updateAllocSize() override; 609 size_t getSize() const override { return relrRelocs.size() * this->entsize; } 610 void writeTo(uint8_t *buf) override { 611 memcpy(buf, relrRelocs.data(), getSize()); 612 } 613 614 private: 615 SmallVector<Elf_Relr, 0> relrRelocs; 616 }; 617 618 struct SymbolTableEntry { 619 Symbol *sym; 620 size_t strTabOffset; 621 }; 622 623 class SymbolTableBaseSection : public SyntheticSection { 624 public: 625 SymbolTableBaseSection(StringTableSection &strTabSec); 626 void finalizeContents() override; 627 size_t getSize() const override { return getNumSymbols() * entsize; } 628 void addSymbol(Symbol *sym); 629 unsigned getNumSymbols() const { return symbols.size() + 1; } 630 size_t getSymbolIndex(Symbol *sym); 631 ArrayRef<SymbolTableEntry> getSymbols() const { return symbols; } 632 633 protected: 634 void sortSymTabSymbols(); 635 636 // A vector of symbols and their string table offsets. 637 SmallVector<SymbolTableEntry, 0> symbols; 638 639 StringTableSection &strTabSec; 640 641 llvm::once_flag onceFlag; 642 llvm::DenseMap<Symbol *, size_t> symbolIndexMap; 643 llvm::DenseMap<OutputSection *, size_t> sectionIndexMap; 644 }; 645 646 template <class ELFT> 647 class SymbolTableSection final : public SymbolTableBaseSection { 648 using Elf_Sym = typename ELFT::Sym; 649 650 public: 651 SymbolTableSection(StringTableSection &strTabSec); 652 void writeTo(uint8_t *buf) override; 653 }; 654 655 class SymtabShndxSection final : public SyntheticSection { 656 public: 657 SymtabShndxSection(); 658 659 void writeTo(uint8_t *buf) override; 660 size_t getSize() const override; 661 bool isNeeded() const override; 662 void finalizeContents() override; 663 }; 664 665 // Outputs GNU Hash section. For detailed explanation see: 666 // https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections 667 class GnuHashTableSection final : public SyntheticSection { 668 public: 669 GnuHashTableSection(); 670 void finalizeContents() override; 671 void writeTo(uint8_t *buf) override; 672 size_t getSize() const override { return size; } 673 674 // Adds symbols to the hash table. 675 // Sorts the input to satisfy GNU hash section requirements. 676 void addSymbols(llvm::SmallVectorImpl<SymbolTableEntry> &symbols); 677 678 private: 679 // See the comment in writeBloomFilter. 680 enum { Shift2 = 26 }; 681 682 struct Entry { 683 Symbol *sym; 684 size_t strTabOffset; 685 uint32_t hash; 686 uint32_t bucketIdx; 687 }; 688 689 SmallVector<Entry, 0> symbols; 690 size_t maskWords; 691 size_t nBuckets = 0; 692 size_t size = 0; 693 }; 694 695 class HashTableSection final : public SyntheticSection { 696 public: 697 HashTableSection(); 698 void finalizeContents() override; 699 void writeTo(uint8_t *buf) override; 700 size_t getSize() const override { return size; } 701 702 private: 703 size_t size = 0; 704 }; 705 706 // Used for PLT entries. It usually has a PLT header for lazy binding. Each PLT 707 // entry is associated with a JUMP_SLOT relocation, which may be resolved lazily 708 // at runtime. 709 // 710 // On PowerPC, this section contains lazy symbol resolvers. A branch instruction 711 // jumps to a PLT call stub, which will then jump to the target (BIND_NOW) or a 712 // lazy symbol resolver. 713 // 714 // On x86 when IBT is enabled, this section (.plt.sec) contains PLT call stubs. 715 // A call instruction jumps to a .plt.sec entry, which will then jump to the 716 // target (BIND_NOW) or a .plt entry. 717 class PltSection : public SyntheticSection { 718 public: 719 PltSection(); 720 void writeTo(uint8_t *buf) override; 721 size_t getSize() const override; 722 bool isNeeded() const override; 723 void addSymbols(); 724 void addEntry(Symbol &sym); 725 size_t getNumEntries() const { return entries.size(); } 726 727 size_t headerSize; 728 729 SmallVector<const Symbol *, 0> entries; 730 }; 731 732 // Used for non-preemptible ifuncs. It does not have a header. Each entry is 733 // associated with an IRELATIVE relocation, which will be resolved eagerly at 734 // runtime. PltSection can only contain entries associated with JUMP_SLOT 735 // relocations, so IPLT entries are in a separate section. 736 class IpltSection final : public SyntheticSection { 737 SmallVector<const Symbol *, 0> entries; 738 739 public: 740 IpltSection(); 741 void writeTo(uint8_t *buf) override; 742 size_t getSize() const override; 743 bool isNeeded() const override { return !entries.empty(); } 744 void addSymbols(); 745 void addEntry(Symbol &sym); 746 }; 747 748 class PPC32GlinkSection : public PltSection { 749 public: 750 PPC32GlinkSection(); 751 void writeTo(uint8_t *buf) override; 752 size_t getSize() const override; 753 754 SmallVector<const Symbol *, 0> canonical_plts; 755 static constexpr size_t footerSize = 64; 756 }; 757 758 // This is x86-only. 759 class IBTPltSection : public SyntheticSection { 760 public: 761 IBTPltSection(); 762 void writeTo(uint8_t *Buf) override; 763 bool isNeeded() const override; 764 size_t getSize() const override; 765 }; 766 767 class GdbIndexSection final : public SyntheticSection { 768 public: 769 struct AddressEntry { 770 InputSection *section; 771 uint64_t lowAddress; 772 uint64_t highAddress; 773 uint32_t cuIndex; 774 }; 775 776 struct CuEntry { 777 uint64_t cuOffset; 778 uint64_t cuLength; 779 }; 780 781 struct NameAttrEntry { 782 llvm::CachedHashStringRef name; 783 uint32_t cuIndexAndAttrs; 784 }; 785 786 struct GdbChunk { 787 InputSection *sec; 788 SmallVector<AddressEntry, 0> addressAreas; 789 SmallVector<CuEntry, 0> compilationUnits; 790 }; 791 792 struct GdbSymbol { 793 llvm::CachedHashStringRef name; 794 SmallVector<uint32_t, 0> cuVector; 795 uint32_t nameOff; 796 uint32_t cuVectorOff; 797 }; 798 799 GdbIndexSection(); 800 template <typename ELFT> static GdbIndexSection *create(); 801 void writeTo(uint8_t *buf) override; 802 size_t getSize() const override { return size; } 803 bool isNeeded() const override; 804 805 private: 806 struct GdbIndexHeader { 807 llvm::support::ulittle32_t version; 808 llvm::support::ulittle32_t cuListOff; 809 llvm::support::ulittle32_t cuTypesOff; 810 llvm::support::ulittle32_t addressAreaOff; 811 llvm::support::ulittle32_t symtabOff; 812 llvm::support::ulittle32_t constantPoolOff; 813 }; 814 815 void initOutputSize(); 816 size_t computeSymtabSize() const; 817 818 // Each chunk contains information gathered from debug sections of a 819 // single object file. 820 SmallVector<GdbChunk, 0> chunks; 821 822 // A symbol table for this .gdb_index section. 823 SmallVector<GdbSymbol, 0> symbols; 824 825 size_t size; 826 }; 827 828 // --eh-frame-hdr option tells linker to construct a header for all the 829 // .eh_frame sections. This header is placed to a section named .eh_frame_hdr 830 // and also to a PT_GNU_EH_FRAME segment. 831 // At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by 832 // calling dl_iterate_phdr. 833 // This section contains a lookup table for quick binary search of FDEs. 834 // Detailed info about internals can be found in Ian Lance Taylor's blog: 835 // http://www.airs.com/blog/archives/460 (".eh_frame") 836 // http://www.airs.com/blog/archives/462 (".eh_frame_hdr") 837 class EhFrameHeader final : public SyntheticSection { 838 public: 839 EhFrameHeader(); 840 void write(); 841 void writeTo(uint8_t *buf) override; 842 size_t getSize() const override; 843 bool isNeeded() const override; 844 }; 845 846 // For more information about .gnu.version and .gnu.version_r see: 847 // https://www.akkadia.org/drepper/symbol-versioning 848 849 // The .gnu.version_d section which has a section type of SHT_GNU_verdef shall 850 // contain symbol version definitions. The number of entries in this section 851 // shall be contained in the DT_VERDEFNUM entry of the .dynamic section. 852 // The section shall contain an array of Elf_Verdef structures, optionally 853 // followed by an array of Elf_Verdaux structures. 854 class VersionDefinitionSection final : public SyntheticSection { 855 public: 856 VersionDefinitionSection(); 857 void finalizeContents() override; 858 size_t getSize() const override; 859 void writeTo(uint8_t *buf) override; 860 861 private: 862 enum { EntrySize = 28 }; 863 void writeOne(uint8_t *buf, uint32_t index, StringRef name, size_t nameOff); 864 StringRef getFileDefName(); 865 866 unsigned fileDefNameOff; 867 SmallVector<unsigned, 0> verDefNameOffs; 868 }; 869 870 // The .gnu.version section specifies the required version of each symbol in the 871 // dynamic symbol table. It contains one Elf_Versym for each dynamic symbol 872 // table entry. An Elf_Versym is just a 16-bit integer that refers to a version 873 // identifier defined in the either .gnu.version_r or .gnu.version_d section. 874 // The values 0 and 1 are reserved. All other values are used for versions in 875 // the own object or in any of the dependencies. 876 class VersionTableSection final : public SyntheticSection { 877 public: 878 VersionTableSection(); 879 void finalizeContents() override; 880 size_t getSize() const override; 881 void writeTo(uint8_t *buf) override; 882 bool isNeeded() const override; 883 }; 884 885 // The .gnu.version_r section defines the version identifiers used by 886 // .gnu.version. It contains a linked list of Elf_Verneed data structures. Each 887 // Elf_Verneed specifies the version requirements for a single DSO, and contains 888 // a reference to a linked list of Elf_Vernaux data structures which define the 889 // mapping from version identifiers to version names. 890 template <class ELFT> 891 class VersionNeedSection final : public SyntheticSection { 892 using Elf_Verneed = typename ELFT::Verneed; 893 using Elf_Vernaux = typename ELFT::Vernaux; 894 895 struct Vernaux { 896 uint64_t hash; 897 uint32_t verneedIndex; 898 uint64_t nameStrTab; 899 }; 900 901 struct Verneed { 902 uint64_t nameStrTab; 903 std::vector<Vernaux> vernauxs; 904 }; 905 906 SmallVector<Verneed, 0> verneeds; 907 908 public: 909 VersionNeedSection(); 910 void finalizeContents() override; 911 void writeTo(uint8_t *buf) override; 912 size_t getSize() const override; 913 bool isNeeded() const override; 914 }; 915 916 // MergeSyntheticSection is a class that allows us to put mergeable sections 917 // with different attributes in a single output sections. To do that 918 // we put them into MergeSyntheticSection synthetic input sections which are 919 // attached to regular output sections. 920 class MergeSyntheticSection : public SyntheticSection { 921 public: 922 void addSection(MergeInputSection *ms); 923 SmallVector<MergeInputSection *, 0> sections; 924 925 protected: 926 MergeSyntheticSection(StringRef name, uint32_t type, uint64_t flags, 927 uint32_t alignment) 928 : SyntheticSection(flags, type, alignment, name) {} 929 }; 930 931 class MergeTailSection final : public MergeSyntheticSection { 932 public: 933 MergeTailSection(StringRef name, uint32_t type, uint64_t flags, 934 uint32_t alignment); 935 936 size_t getSize() const override; 937 void writeTo(uint8_t *buf) override; 938 void finalizeContents() override; 939 940 private: 941 llvm::StringTableBuilder builder; 942 }; 943 944 class MergeNoTailSection final : public MergeSyntheticSection { 945 public: 946 MergeNoTailSection(StringRef name, uint32_t type, uint64_t flags, 947 uint32_t alignment) 948 : MergeSyntheticSection(name, type, flags, alignment) {} 949 950 size_t getSize() const override { return size; } 951 void writeTo(uint8_t *buf) override; 952 void finalizeContents() override; 953 954 private: 955 // We use the most significant bits of a hash as a shard ID. 956 // The reason why we don't want to use the least significant bits is 957 // because DenseMap also uses lower bits to determine a bucket ID. 958 // If we use lower bits, it significantly increases the probability of 959 // hash collisons. 960 size_t getShardId(uint32_t hash) { 961 assert((hash >> 31) == 0); 962 return hash >> (31 - llvm::countTrailingZeros(numShards)); 963 } 964 965 // Section size 966 size_t size; 967 968 // String table contents 969 constexpr static size_t numShards = 32; 970 SmallVector<llvm::StringTableBuilder, 0> shards; 971 size_t shardOffsets[numShards]; 972 }; 973 974 // .MIPS.abiflags section. 975 template <class ELFT> 976 class MipsAbiFlagsSection final : public SyntheticSection { 977 using Elf_Mips_ABIFlags = llvm::object::Elf_Mips_ABIFlags<ELFT>; 978 979 public: 980 static std::unique_ptr<MipsAbiFlagsSection> create(); 981 982 MipsAbiFlagsSection(Elf_Mips_ABIFlags flags); 983 size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); } 984 void writeTo(uint8_t *buf) override; 985 986 private: 987 Elf_Mips_ABIFlags flags; 988 }; 989 990 // .MIPS.options section. 991 template <class ELFT> class MipsOptionsSection final : public SyntheticSection { 992 using Elf_Mips_Options = llvm::object::Elf_Mips_Options<ELFT>; 993 using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>; 994 995 public: 996 static std::unique_ptr<MipsOptionsSection<ELFT>> create(); 997 998 MipsOptionsSection(Elf_Mips_RegInfo reginfo); 999 void writeTo(uint8_t *buf) override; 1000 1001 size_t getSize() const override { 1002 return sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo); 1003 } 1004 1005 private: 1006 Elf_Mips_RegInfo reginfo; 1007 }; 1008 1009 // MIPS .reginfo section. 1010 template <class ELFT> class MipsReginfoSection final : public SyntheticSection { 1011 using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>; 1012 1013 public: 1014 static std::unique_ptr<MipsReginfoSection> create(); 1015 1016 MipsReginfoSection(Elf_Mips_RegInfo reginfo); 1017 size_t getSize() const override { return sizeof(Elf_Mips_RegInfo); } 1018 void writeTo(uint8_t *buf) override; 1019 1020 private: 1021 Elf_Mips_RegInfo reginfo; 1022 }; 1023 1024 // This is a MIPS specific section to hold a space within the data segment 1025 // of executable file which is pointed to by the DT_MIPS_RLD_MAP entry. 1026 // See "Dynamic section" in Chapter 5 in the following document: 1027 // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf 1028 class MipsRldMapSection : public SyntheticSection { 1029 public: 1030 MipsRldMapSection(); 1031 size_t getSize() const override { return config->wordsize; } 1032 void writeTo(uint8_t *buf) override {} 1033 }; 1034 1035 // Representation of the combined .ARM.Exidx input sections. We process these 1036 // as a SyntheticSection like .eh_frame as we need to merge duplicate entries 1037 // and add terminating sentinel entries. 1038 // 1039 // The .ARM.exidx input sections after SHF_LINK_ORDER processing is done form 1040 // a table that the unwinder can derive (Addresses are encoded as offsets from 1041 // table): 1042 // | Address of function | Unwind instructions for function | 1043 // where the unwind instructions are either a small number of unwind or the 1044 // special EXIDX_CANTUNWIND entry representing no unwinding information. 1045 // When an exception is thrown from an address A, the unwinder searches the 1046 // table for the closest table entry with Address of function <= A. This means 1047 // that for two consecutive table entries: 1048 // | A1 | U1 | 1049 // | A2 | U2 | 1050 // The range of addresses described by U1 is [A1, A2) 1051 // 1052 // There are two cases where we need a linker generated table entry to fixup 1053 // the address ranges in the table 1054 // Case 1: 1055 // - A sentinel entry added with an address higher than all 1056 // executable sections. This was needed to work around libunwind bug pr31091. 1057 // - After address assignment we need to find the highest addressed executable 1058 // section and use the limit of that section so that the unwinder never 1059 // matches it. 1060 // Case 2: 1061 // - InputSections without a .ARM.exidx section (usually from Assembly) 1062 // need a table entry so that they terminate the range of the previously 1063 // function. This is pr40277. 1064 // 1065 // Instead of storing pointers to the .ARM.exidx InputSections from 1066 // InputObjects, we store pointers to the executable sections that need 1067 // .ARM.exidx sections. We can then use the dependentSections of these to 1068 // either find the .ARM.exidx section or know that we need to generate one. 1069 class ARMExidxSyntheticSection : public SyntheticSection { 1070 public: 1071 ARMExidxSyntheticSection(); 1072 1073 // Add an input section to the ARMExidxSyntheticSection. Returns whether the 1074 // section needs to be removed from the main input section list. 1075 bool addSection(InputSection *isec); 1076 1077 size_t getSize() const override { return size; } 1078 void writeTo(uint8_t *buf) override; 1079 bool isNeeded() const override; 1080 // Sort and remove duplicate entries. 1081 void finalizeContents() override; 1082 InputSection *getLinkOrderDep() const; 1083 1084 static bool classof(const SectionBase *d); 1085 1086 // Links to the ARMExidxSections so we can transfer the relocations once the 1087 // layout is known. 1088 SmallVector<InputSection *, 0> exidxSections; 1089 1090 private: 1091 size_t size = 0; 1092 1093 // Instead of storing pointers to the .ARM.exidx InputSections from 1094 // InputObjects, we store pointers to the executable sections that need 1095 // .ARM.exidx sections. We can then use the dependentSections of these to 1096 // either find the .ARM.exidx section or know that we need to generate one. 1097 SmallVector<InputSection *, 0> executableSections; 1098 1099 // The executable InputSection with the highest address to use for the 1100 // sentinel. We store separately from ExecutableSections as merging of 1101 // duplicate entries may mean this InputSection is removed from 1102 // ExecutableSections. 1103 InputSection *sentinel = nullptr; 1104 }; 1105 1106 // A container for one or more linker generated thunks. Instances of these 1107 // thunks including ARM interworking and Mips LA25 PI to non-PI thunks. 1108 class ThunkSection : public SyntheticSection { 1109 public: 1110 // ThunkSection in OS, with desired outSecOff of Off 1111 ThunkSection(OutputSection *os, uint64_t off); 1112 1113 // Add a newly created Thunk to this container: 1114 // Thunk is given offset from start of this InputSection 1115 // Thunk defines a symbol in this InputSection that can be used as target 1116 // of a relocation 1117 void addThunk(Thunk *t); 1118 size_t getSize() const override; 1119 void writeTo(uint8_t *buf) override; 1120 InputSection *getTargetInputSection() const; 1121 bool assignOffsets(); 1122 1123 // When true, round up reported size of section to 4 KiB. See comment 1124 // in addThunkSection() for more details. 1125 bool roundUpSizeForErrata = false; 1126 1127 private: 1128 SmallVector<Thunk *, 0> thunks; 1129 size_t size = 0; 1130 }; 1131 1132 // Used to compute outSecOff of .got2 in each object file. This is needed to 1133 // synthesize PLT entries for PPC32 Secure PLT ABI. 1134 class PPC32Got2Section final : public SyntheticSection { 1135 public: 1136 PPC32Got2Section(); 1137 size_t getSize() const override { return 0; } 1138 bool isNeeded() const override; 1139 void finalizeContents() override; 1140 void writeTo(uint8_t *buf) override {} 1141 }; 1142 1143 // This section is used to store the addresses of functions that are called 1144 // in range-extending thunks on PowerPC64. When producing position dependent 1145 // code the addresses are link-time constants and the table is written out to 1146 // the binary. When producing position-dependent code the table is allocated and 1147 // filled in by the dynamic linker. 1148 class PPC64LongBranchTargetSection final : public SyntheticSection { 1149 public: 1150 PPC64LongBranchTargetSection(); 1151 uint64_t getEntryVA(const Symbol *sym, int64_t addend); 1152 llvm::Optional<uint32_t> addEntry(const Symbol *sym, int64_t addend); 1153 size_t getSize() const override; 1154 void writeTo(uint8_t *buf) override; 1155 bool isNeeded() const override; 1156 void finalizeContents() override { finalized = true; } 1157 1158 private: 1159 SmallVector<std::pair<const Symbol *, int64_t>, 0> entries; 1160 llvm::DenseMap<std::pair<const Symbol *, int64_t>, uint32_t> entry_index; 1161 bool finalized = false; 1162 }; 1163 1164 template <typename ELFT> 1165 class PartitionElfHeaderSection : public SyntheticSection { 1166 public: 1167 PartitionElfHeaderSection(); 1168 size_t getSize() const override; 1169 void writeTo(uint8_t *buf) override; 1170 }; 1171 1172 template <typename ELFT> 1173 class PartitionProgramHeadersSection : public SyntheticSection { 1174 public: 1175 PartitionProgramHeadersSection(); 1176 size_t getSize() const override; 1177 void writeTo(uint8_t *buf) override; 1178 }; 1179 1180 class PartitionIndexSection : public SyntheticSection { 1181 public: 1182 PartitionIndexSection(); 1183 size_t getSize() const override; 1184 void finalizeContents() override; 1185 void writeTo(uint8_t *buf) override; 1186 }; 1187 1188 InputSection *createInterpSection(); 1189 MergeInputSection *createCommentSection(); 1190 template <class ELFT> void splitSections(); 1191 1192 template <typename ELFT> void writeEhdr(uint8_t *buf, Partition &part); 1193 template <typename ELFT> void writePhdrs(uint8_t *buf, Partition &part); 1194 1195 Defined *addSyntheticLocal(StringRef name, uint8_t type, uint64_t value, 1196 uint64_t size, InputSectionBase §ion); 1197 1198 void addVerneed(Symbol *ss); 1199 1200 // Linker generated per-partition sections. 1201 struct Partition { 1202 StringRef name; 1203 uint64_t nameStrTab; 1204 1205 std::unique_ptr<SyntheticSection> elfHeader; 1206 std::unique_ptr<SyntheticSection> programHeaders; 1207 SmallVector<PhdrEntry *, 0> phdrs; 1208 1209 std::unique_ptr<ARMExidxSyntheticSection> armExidx; 1210 std::unique_ptr<BuildIdSection> buildId; 1211 std::unique_ptr<SyntheticSection> dynamic; 1212 std::unique_ptr<StringTableSection> dynStrTab; 1213 std::unique_ptr<SymbolTableBaseSection> dynSymTab; 1214 std::unique_ptr<EhFrameHeader> ehFrameHdr; 1215 std::unique_ptr<EhFrameSection> ehFrame; 1216 std::unique_ptr<GnuHashTableSection> gnuHashTab; 1217 std::unique_ptr<HashTableSection> hashTab; 1218 std::unique_ptr<RelocationBaseSection> relaDyn; 1219 std::unique_ptr<RelrBaseSection> relrDyn; 1220 std::unique_ptr<VersionDefinitionSection> verDef; 1221 std::unique_ptr<SyntheticSection> verNeed; 1222 std::unique_ptr<VersionTableSection> verSym; 1223 1224 unsigned getNumber() const { return this - &partitions[0] + 1; } 1225 }; 1226 1227 extern Partition *mainPart; 1228 1229 inline Partition &SectionBase::getPartition() const { 1230 assert(isLive()); 1231 return partitions[partition - 1]; 1232 } 1233 1234 // Linker generated sections which can be used as inputs and are not specific to 1235 // a partition. 1236 struct InStruct { 1237 std::unique_ptr<InputSection> attributes; 1238 std::unique_ptr<BssSection> bss; 1239 std::unique_ptr<BssSection> bssRelRo; 1240 std::unique_ptr<GotSection> got; 1241 std::unique_ptr<GotPltSection> gotPlt; 1242 std::unique_ptr<IgotPltSection> igotPlt; 1243 std::unique_ptr<PPC64LongBranchTargetSection> ppc64LongBranchTarget; 1244 std::unique_ptr<SyntheticSection> mipsAbiFlags; 1245 std::unique_ptr<MipsGotSection> mipsGot; 1246 std::unique_ptr<SyntheticSection> mipsOptions; 1247 std::unique_ptr<SyntheticSection> mipsReginfo; 1248 std::unique_ptr<MipsRldMapSection> mipsRldMap; 1249 std::unique_ptr<SyntheticSection> partEnd; 1250 std::unique_ptr<SyntheticSection> partIndex; 1251 std::unique_ptr<PltSection> plt; 1252 std::unique_ptr<IpltSection> iplt; 1253 std::unique_ptr<PPC32Got2Section> ppc32Got2; 1254 std::unique_ptr<IBTPltSection> ibtPlt; 1255 std::unique_ptr<RelocationBaseSection> relaPlt; 1256 std::unique_ptr<RelocationBaseSection> relaIplt; 1257 std::unique_ptr<StringTableSection> shStrTab; 1258 std::unique_ptr<StringTableSection> strTab; 1259 std::unique_ptr<SymbolTableBaseSection> symTab; 1260 std::unique_ptr<SymtabShndxSection> symTabShndx; 1261 1262 void reset(); 1263 }; 1264 1265 extern InStruct in; 1266 1267 } // namespace elf 1268 } // namespace lld 1269 1270 #endif 1271