1 //===- Symbols.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 // This file defines various types of Symbols. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLD_ELF_SYMBOLS_H 14 #define LLD_ELF_SYMBOLS_H 15 16 #include "InputFiles.h" 17 #include "InputSection.h" 18 #include "lld/Common/LLVM.h" 19 #include "lld/Common/Memory.h" 20 #include "lld/Common/Strings.h" 21 #include "llvm/ADT/DenseMap.h" 22 #include "llvm/Object/Archive.h" 23 #include "llvm/Object/ELF.h" 24 #include <tuple> 25 26 namespace lld { 27 // Returns a string representation for a symbol for diagnostics. 28 std::string toString(const elf::Symbol &); 29 30 // There are two different ways to convert an Archive::Symbol to a string: 31 // One for Microsoft name mangling and one for Itanium name mangling. 32 // Call the functions toCOFFString and toELFString, not just toString. 33 std::string toELFString(const llvm::object::Archive::Symbol &); 34 35 namespace elf { 36 class CommonSymbol; 37 class Defined; 38 class InputFile; 39 class LazyArchive; 40 class LazyObject; 41 class SharedSymbol; 42 class Symbol; 43 class Undefined; 44 45 // Some index properties of a symbol are stored separately in this auxiliary 46 // struct to decrease sizeof(SymbolUnion) in the majority of cases. 47 struct SymbolAux { 48 uint32_t gotIdx = -1; 49 uint32_t pltIdx = -1; 50 uint32_t tlsDescIdx = -1; 51 uint32_t tlsGdIdx = -1; 52 }; 53 54 extern SmallVector<SymbolAux, 0> symAux; 55 56 // The base class for real symbol classes. 57 class Symbol { 58 public: 59 enum Kind { 60 PlaceholderKind, 61 DefinedKind, 62 CommonKind, 63 SharedKind, 64 UndefinedKind, 65 LazyArchiveKind, 66 LazyObjectKind, 67 }; 68 69 Kind kind() const { return static_cast<Kind>(symbolKind); } 70 71 // The file from which this symbol was created. 72 InputFile *file; 73 74 protected: 75 const char *nameData; 76 // 32-bit size saves space. 77 uint32_t nameSize; 78 79 public: 80 // A symAux index used to access GOT/PLT entry indexes. This is allocated in 81 // postScanRelocations(). 82 uint32_t auxIdx = -1; 83 uint32_t dynsymIndex = 0; 84 85 // This field is a index to the symbol's version definition. 86 uint16_t verdefIndex = -1; 87 88 // Version definition index. 89 uint16_t versionId; 90 91 // Symbol binding. This is not overwritten by replace() to track 92 // changes during resolution. In particular: 93 // - An undefined weak is still weak when it resolves to a shared library. 94 // - An undefined weak will not extract archive members, but we have to 95 // remember it is weak. 96 uint8_t binding; 97 98 // The following fields have the same meaning as the ELF symbol attributes. 99 uint8_t type; // symbol type 100 uint8_t stOther; // st_other field value 101 102 uint8_t symbolKind; 103 104 // Symbol visibility. This is the computed minimum visibility of all 105 // observed non-DSO symbols. 106 uint8_t visibility : 2; 107 108 // True if the symbol was used for linking and thus need to be added to the 109 // output file's symbol table. This is true for all symbols except for 110 // unreferenced DSO symbols, lazy (archive) symbols, and bitcode symbols that 111 // are unreferenced except by other bitcode objects. 112 uint8_t isUsedInRegularObj : 1; 113 114 // Used by a Defined symbol with protected or default visibility, to record 115 // whether it is required to be exported into .dynsym. This is set when any of 116 // the following conditions hold: 117 // 118 // - If there is an interposable symbol from a DSO. 119 // - If -shared or --export-dynamic is specified, any symbol in an object 120 // file/bitcode sets this property, unless suppressed by LTO 121 // canBeOmittedFromSymbolTable(). 122 uint8_t exportDynamic : 1; 123 124 // True if the symbol is in the --dynamic-list file. A Defined symbol with 125 // protected or default visibility with this property is required to be 126 // exported into .dynsym. 127 uint8_t inDynamicList : 1; 128 129 // False if LTO shouldn't inline whatever this symbol points to. If a symbol 130 // is overwritten after LTO, LTO shouldn't inline the symbol because it 131 // doesn't know the final contents of the symbol. 132 uint8_t canInline : 1; 133 134 // Used to track if there has been at least one undefined reference to the 135 // symbol. For Undefined and SharedSymbol, the binding may change to STB_WEAK 136 // if the first undefined reference from a non-shared object is weak. 137 // 138 // This is also used to retain __wrap_foo when foo is referenced. 139 uint8_t referenced : 1; 140 141 // True if this symbol is specified by --trace-symbol option. 142 uint8_t traced : 1; 143 144 // True if the name contains '@'. 145 uint8_t hasVersionSuffix : 1; 146 147 inline void replace(const Symbol &newSym); 148 149 bool includeInDynsym() const; 150 uint8_t computeBinding() const; 151 bool isWeak() const { return binding == llvm::ELF::STB_WEAK; } 152 153 bool isUndefined() const { return symbolKind == UndefinedKind; } 154 bool isCommon() const { return symbolKind == CommonKind; } 155 bool isDefined() const { return symbolKind == DefinedKind; } 156 bool isShared() const { return symbolKind == SharedKind; } 157 bool isPlaceholder() const { return symbolKind == PlaceholderKind; } 158 159 bool isLocal() const { return binding == llvm::ELF::STB_LOCAL; } 160 161 bool isLazy() const { 162 return symbolKind == LazyArchiveKind || symbolKind == LazyObjectKind; 163 } 164 165 // True if this is an undefined weak symbol. This only works once 166 // all input files have been added. 167 bool isUndefWeak() const { return isWeak() && isUndefined(); } 168 169 StringRef getName() const { return {nameData, nameSize}; } 170 171 void setName(StringRef s) { 172 nameData = s.data(); 173 nameSize = s.size(); 174 } 175 176 void parseSymbolVersion(); 177 178 // Get the NUL-terminated version suffix ("", "@...", or "@@..."). 179 // 180 // For @@, the name has been truncated by insert(). For @, the name has been 181 // truncated by Symbol::parseSymbolVersion(). 182 const char *getVersionSuffix() const { return nameData + nameSize; } 183 184 uint32_t getGotIdx() const { 185 return auxIdx == uint32_t(-1) ? uint32_t(-1) : symAux[auxIdx].gotIdx; 186 } 187 uint32_t getPltIdx() const { 188 return auxIdx == uint32_t(-1) ? uint32_t(-1) : symAux[auxIdx].pltIdx; 189 } 190 uint32_t getTlsDescIdx() const { 191 return auxIdx == uint32_t(-1) ? uint32_t(-1) : symAux[auxIdx].tlsDescIdx; 192 } 193 uint32_t getTlsGdIdx() const { 194 return auxIdx == uint32_t(-1) ? uint32_t(-1) : symAux[auxIdx].tlsGdIdx; 195 } 196 197 bool isInGot() const { return getGotIdx() != uint32_t(-1); } 198 bool isInPlt() const { return getPltIdx() != uint32_t(-1); } 199 200 uint64_t getVA(int64_t addend = 0) const; 201 202 uint64_t getGotOffset() const; 203 uint64_t getGotVA() const; 204 uint64_t getGotPltOffset() const; 205 uint64_t getGotPltVA() const; 206 uint64_t getPltVA() const; 207 uint64_t getSize() const; 208 OutputSection *getOutputSection() const; 209 210 // The following two functions are used for symbol resolution. 211 // 212 // You are expected to call mergeProperties for all symbols in input 213 // files so that attributes that are attached to names rather than 214 // indivisual symbol (such as visibility) are merged together. 215 // 216 // Every time you read a new symbol from an input, you are supposed 217 // to call resolve() with the new symbol. That function replaces 218 // "this" object as a result of name resolution if the new symbol is 219 // more appropriate to be included in the output. 220 // 221 // For example, if "this" is an undefined symbol and a new symbol is 222 // a defined symbol, "this" is replaced with the new symbol. 223 void mergeProperties(const Symbol &other); 224 void resolve(const Symbol &other); 225 226 // If this is a lazy symbol, extract an input file and add the symbol 227 // in the file to the symbol table. Calling this function on 228 // non-lazy object causes a runtime error. 229 void extract() const; 230 231 static bool isExportDynamic(Kind k, uint8_t visibility) { 232 if (k == SharedKind) 233 return visibility == llvm::ELF::STV_DEFAULT; 234 return config->shared || config->exportDynamic; 235 } 236 237 private: 238 void resolveUndefined(const Undefined &other); 239 void resolveCommon(const CommonSymbol &other); 240 void resolveDefined(const Defined &other); 241 template <class LazyT> void resolveLazy(const LazyT &other); 242 void resolveShared(const SharedSymbol &other); 243 244 int compare(const Symbol *other) const; 245 246 inline size_t getSymbolSize() const; 247 248 protected: 249 Symbol(Kind k, InputFile *file, StringRef name, uint8_t binding, 250 uint8_t stOther, uint8_t type) 251 : file(file), nameData(name.data()), nameSize(name.size()), 252 binding(binding), type(type), stOther(stOther), symbolKind(k), 253 visibility(stOther & 3), 254 isUsedInRegularObj(!file || file->kind() == InputFile::ObjKind), 255 exportDynamic(isExportDynamic(k, visibility)), inDynamicList(false), 256 canInline(false), referenced(false), traced(false), 257 hasVersionSuffix(false), isInIplt(false), gotInIgot(false), 258 isPreemptible(false), used(!config->gcSections), folded(false), 259 needsTocRestore(false), scriptDefined(false), needsCopy(false), 260 needsGot(false), needsPlt(false), needsTlsDesc(false), 261 needsTlsGd(false), needsTlsGdToIe(false), needsTlsLd(false), 262 needsGotDtprel(false), needsTlsIe(false), hasDirectReloc(false) {} 263 264 public: 265 // True if this symbol is in the Iplt sub-section of the Plt and the Igot 266 // sub-section of the .got.plt or .got. 267 uint8_t isInIplt : 1; 268 269 // True if this symbol needs a GOT entry and its GOT entry is actually in 270 // Igot. This will be true only for certain non-preemptible ifuncs. 271 uint8_t gotInIgot : 1; 272 273 // True if this symbol is preemptible at load time. 274 uint8_t isPreemptible : 1; 275 276 // True if an undefined or shared symbol is used from a live section. 277 // 278 // NOTE: In Writer.cpp the field is used to mark local defined symbols 279 // which are referenced by relocations when -r or --emit-relocs is given. 280 uint8_t used : 1; 281 282 // True if defined relative to a section discarded by ICF. 283 uint8_t folded : 1; 284 285 // True if a call to this symbol needs to be followed by a restore of the 286 // PPC64 toc pointer. 287 uint8_t needsTocRestore : 1; 288 289 // True if this symbol is defined by a linker script. 290 uint8_t scriptDefined : 1; 291 292 // True if this symbol needs a canonical PLT entry, or (during 293 // postScanRelocations) a copy relocation. 294 uint8_t needsCopy : 1; 295 296 // Temporary flags used to communicate which symbol entries need PLT and GOT 297 // entries during postScanRelocations(); 298 uint8_t needsGot : 1; 299 uint8_t needsPlt : 1; 300 uint8_t needsTlsDesc : 1; 301 uint8_t needsTlsGd : 1; 302 uint8_t needsTlsGdToIe : 1; 303 uint8_t needsTlsLd : 1; 304 uint8_t needsGotDtprel : 1; 305 uint8_t needsTlsIe : 1; 306 uint8_t hasDirectReloc : 1; 307 308 bool needsDynReloc() const { 309 return needsCopy || needsGot || needsPlt || needsTlsDesc || needsTlsGd || 310 needsTlsGdToIe || needsTlsLd || needsGotDtprel || needsTlsIe; 311 } 312 void allocateAux() { 313 assert(auxIdx == uint32_t(-1)); 314 auxIdx = symAux.size(); 315 symAux.emplace_back(); 316 } 317 318 // The partition whose dynamic symbol table contains this symbol's definition. 319 uint8_t partition = 1; 320 321 bool isSection() const { return type == llvm::ELF::STT_SECTION; } 322 bool isTls() const { return type == llvm::ELF::STT_TLS; } 323 bool isFunc() const { return type == llvm::ELF::STT_FUNC; } 324 bool isGnuIFunc() const { return type == llvm::ELF::STT_GNU_IFUNC; } 325 bool isObject() const { return type == llvm::ELF::STT_OBJECT; } 326 bool isFile() const { return type == llvm::ELF::STT_FILE; } 327 }; 328 329 // Represents a symbol that is defined in the current output file. 330 class Defined : public Symbol { 331 public: 332 Defined(InputFile *file, StringRef name, uint8_t binding, uint8_t stOther, 333 uint8_t type, uint64_t value, uint64_t size, SectionBase *section) 334 : Symbol(DefinedKind, file, name, binding, stOther, type), value(value), 335 size(size), section(section) {} 336 337 static bool classof(const Symbol *s) { return s->isDefined(); } 338 339 uint64_t value; 340 uint64_t size; 341 SectionBase *section; 342 }; 343 344 // Represents a common symbol. 345 // 346 // On Unix, it is traditionally allowed to write variable definitions 347 // without initialization expressions (such as "int foo;") to header 348 // files. Such definition is called "tentative definition". 349 // 350 // Using tentative definition is usually considered a bad practice 351 // because you should write only declarations (such as "extern int 352 // foo;") to header files. Nevertheless, the linker and the compiler 353 // have to do something to support bad code by allowing duplicate 354 // definitions for this particular case. 355 // 356 // Common symbols represent variable definitions without initializations. 357 // The compiler creates common symbols when it sees variable definitions 358 // without initialization (you can suppress this behavior and let the 359 // compiler create a regular defined symbol by -fno-common). 360 // 361 // The linker allows common symbols to be replaced by regular defined 362 // symbols. If there are remaining common symbols after name resolution is 363 // complete, they are converted to regular defined symbols in a .bss 364 // section. (Therefore, the later passes don't see any CommonSymbols.) 365 class CommonSymbol : public Symbol { 366 public: 367 CommonSymbol(InputFile *file, StringRef name, uint8_t binding, 368 uint8_t stOther, uint8_t type, uint64_t alignment, uint64_t size) 369 : Symbol(CommonKind, file, name, binding, stOther, type), 370 alignment(alignment), size(size) {} 371 372 static bool classof(const Symbol *s) { return s->isCommon(); } 373 374 uint32_t alignment; 375 uint64_t size; 376 }; 377 378 class Undefined : public Symbol { 379 public: 380 Undefined(InputFile *file, StringRef name, uint8_t binding, uint8_t stOther, 381 uint8_t type, uint32_t discardedSecIdx = 0) 382 : Symbol(UndefinedKind, file, name, binding, stOther, type), 383 discardedSecIdx(discardedSecIdx) {} 384 385 static bool classof(const Symbol *s) { return s->kind() == UndefinedKind; } 386 387 // The section index if in a discarded section, 0 otherwise. 388 uint32_t discardedSecIdx; 389 }; 390 391 class SharedSymbol : public Symbol { 392 public: 393 static bool classof(const Symbol *s) { return s->kind() == SharedKind; } 394 395 SharedSymbol(InputFile &file, StringRef name, uint8_t binding, 396 uint8_t stOther, uint8_t type, uint64_t value, uint64_t size, 397 uint32_t alignment, uint16_t verdefIndex) 398 : Symbol(SharedKind, &file, name, binding, stOther, type), value(value), 399 size(size), alignment(alignment) { 400 this->verdefIndex = verdefIndex; 401 // GNU ifunc is a mechanism to allow user-supplied functions to 402 // resolve PLT slot values at load-time. This is contrary to the 403 // regular symbol resolution scheme in which symbols are resolved just 404 // by name. Using this hook, you can program how symbols are solved 405 // for you program. For example, you can make "memcpy" to be resolved 406 // to a SSE-enabled version of memcpy only when a machine running the 407 // program supports the SSE instruction set. 408 // 409 // Naturally, such symbols should always be called through their PLT 410 // slots. What GNU ifunc symbols point to are resolver functions, and 411 // calling them directly doesn't make sense (unless you are writing a 412 // loader). 413 // 414 // For DSO symbols, we always call them through PLT slots anyway. 415 // So there's no difference between GNU ifunc and regular function 416 // symbols if they are in DSOs. So we can handle GNU_IFUNC as FUNC. 417 if (this->type == llvm::ELF::STT_GNU_IFUNC) 418 this->type = llvm::ELF::STT_FUNC; 419 } 420 421 SharedFile &getFile() const { return *cast<SharedFile>(file); } 422 423 uint64_t value; // st_value 424 uint64_t size; // st_size 425 uint32_t alignment; 426 }; 427 428 // LazyArchive and LazyObject represent a symbols that is not yet in the link, 429 // but we know where to find it if needed. If the resolver finds both Undefined 430 // and Lazy for the same name, it will ask the Lazy to load a file. 431 // 432 // A special complication is the handling of weak undefined symbols. They should 433 // not load a file, but we have to remember we have seen both the weak undefined 434 // and the lazy. We represent that with a lazy symbol with a weak binding. This 435 // means that code looking for undefined symbols normally also has to take lazy 436 // symbols into consideration. 437 438 // This class represents a symbol defined in an archive file. It is 439 // created from an archive file header, and it knows how to load an 440 // object file from an archive to replace itself with a defined 441 // symbol. 442 class LazyArchive : public Symbol { 443 public: 444 LazyArchive(InputFile &file, const llvm::object::Archive::Symbol s) 445 : Symbol(LazyArchiveKind, &file, s.getName(), llvm::ELF::STB_GLOBAL, 446 llvm::ELF::STV_DEFAULT, llvm::ELF::STT_NOTYPE), 447 sym(s) {} 448 449 static bool classof(const Symbol *s) { return s->kind() == LazyArchiveKind; } 450 451 MemoryBufferRef getMemberBuffer(); 452 453 const llvm::object::Archive::Symbol sym; 454 }; 455 456 // LazyObject symbols represents symbols in object files between 457 // --start-lib and --end-lib options. 458 class LazyObject : public Symbol { 459 public: 460 LazyObject(InputFile &file, StringRef name) 461 : Symbol(LazyObjectKind, &file, name, llvm::ELF::STB_GLOBAL, 462 llvm::ELF::STV_DEFAULT, llvm::ELF::STT_NOTYPE) { 463 isUsedInRegularObj = false; 464 } 465 466 static bool classof(const Symbol *s) { return s->kind() == LazyObjectKind; } 467 }; 468 469 // Some linker-generated symbols need to be created as 470 // Defined symbols. 471 struct ElfSym { 472 // __bss_start 473 static Defined *bss; 474 475 // etext and _etext 476 static Defined *etext1; 477 static Defined *etext2; 478 479 // edata and _edata 480 static Defined *edata1; 481 static Defined *edata2; 482 483 // end and _end 484 static Defined *end1; 485 static Defined *end2; 486 487 // The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention to 488 // be at some offset from the base of the .got section, usually 0 or 489 // the end of the .got. 490 static Defined *globalOffsetTable; 491 492 // _gp, _gp_disp and __gnu_local_gp symbols. Only for MIPS. 493 static Defined *mipsGp; 494 static Defined *mipsGpDisp; 495 static Defined *mipsLocalGp; 496 497 // __rel{,a}_iplt_{start,end} symbols. 498 static Defined *relaIpltStart; 499 static Defined *relaIpltEnd; 500 501 // __global_pointer$ for RISC-V. 502 static Defined *riscvGlobalPointer; 503 504 // _TLS_MODULE_BASE_ on targets that support TLSDESC. 505 static Defined *tlsModuleBase; 506 }; 507 508 // A buffer class that is large enough to hold any Symbol-derived 509 // object. We allocate memory using this class and instantiate a symbol 510 // using the placement new. 511 union SymbolUnion { 512 alignas(Defined) char a[sizeof(Defined)]; 513 alignas(CommonSymbol) char b[sizeof(CommonSymbol)]; 514 alignas(Undefined) char c[sizeof(Undefined)]; 515 alignas(SharedSymbol) char d[sizeof(SharedSymbol)]; 516 alignas(LazyArchive) char e[sizeof(LazyArchive)]; 517 alignas(LazyObject) char f[sizeof(LazyObject)]; 518 }; 519 520 // It is important to keep the size of SymbolUnion small for performance and 521 // memory usage reasons. 72 bytes is a soft limit based on the size of Defined 522 // on a 64-bit system. 523 static_assert(sizeof(SymbolUnion) <= 72, "SymbolUnion too large"); 524 525 template <typename T> struct AssertSymbol { 526 static_assert(std::is_trivially_destructible<T>(), 527 "Symbol types must be trivially destructible"); 528 static_assert(sizeof(T) <= sizeof(SymbolUnion), "SymbolUnion too small"); 529 static_assert(alignof(T) <= alignof(SymbolUnion), 530 "SymbolUnion not aligned enough"); 531 }; 532 533 static inline void assertSymbols() { 534 AssertSymbol<Defined>(); 535 AssertSymbol<CommonSymbol>(); 536 AssertSymbol<Undefined>(); 537 AssertSymbol<SharedSymbol>(); 538 AssertSymbol<LazyArchive>(); 539 AssertSymbol<LazyObject>(); 540 } 541 542 void printTraceSymbol(const Symbol *sym); 543 544 size_t Symbol::getSymbolSize() const { 545 switch (kind()) { 546 case CommonKind: 547 return sizeof(CommonSymbol); 548 case DefinedKind: 549 return sizeof(Defined); 550 case LazyArchiveKind: 551 return sizeof(LazyArchive); 552 case LazyObjectKind: 553 return sizeof(LazyObject); 554 case SharedKind: 555 return sizeof(SharedSymbol); 556 case UndefinedKind: 557 return sizeof(Undefined); 558 case PlaceholderKind: 559 return sizeof(Symbol); 560 } 561 llvm_unreachable("unknown symbol kind"); 562 } 563 564 // replace() replaces "this" object with a given symbol by memcpy'ing 565 // it over to "this". This function is called as a result of name 566 // resolution, e.g. to replace an undefind symbol with a defined symbol. 567 void Symbol::replace(const Symbol &newSym) { 568 using llvm::ELF::STT_TLS; 569 570 // st_value of STT_TLS represents the assigned offset, not the actual address 571 // which is used by STT_FUNC and STT_OBJECT. STT_TLS symbols can only be 572 // referenced by special TLS relocations. It is usually an error if a STT_TLS 573 // symbol is replaced by a non-STT_TLS symbol, vice versa. There are two 574 // exceptions: (a) a STT_NOTYPE lazy/undefined symbol can be replaced by a 575 // STT_TLS symbol, (b) a STT_TLS undefined symbol can be replaced by a 576 // STT_NOTYPE lazy symbol. 577 if (symbolKind != PlaceholderKind && !newSym.isLazy() && 578 (type == STT_TLS) != (newSym.type == STT_TLS) && 579 type != llvm::ELF::STT_NOTYPE) 580 error("TLS attribute mismatch: " + toString(*this) + "\n>>> defined in " + 581 toString(newSym.file) + "\n>>> defined in " + toString(file)); 582 583 Symbol old = *this; 584 memcpy(this, &newSym, newSym.getSymbolSize()); 585 586 // old may be a placeholder. The referenced fields must be initialized in 587 // SymbolTable::insert. 588 versionId = old.versionId; 589 visibility = old.visibility; 590 isUsedInRegularObj = old.isUsedInRegularObj; 591 exportDynamic = old.exportDynamic; 592 inDynamicList = old.inDynamicList; 593 canInline = old.canInline; 594 referenced = old.referenced; 595 traced = old.traced; 596 hasVersionSuffix = old.hasVersionSuffix; 597 isPreemptible = old.isPreemptible; 598 scriptDefined = old.scriptDefined; 599 partition = old.partition; 600 601 // Print out a log message if --trace-symbol was specified. 602 // This is for debugging. 603 if (traced) 604 printTraceSymbol(this); 605 } 606 607 template <typename... T> Defined *makeDefined(T &&...args) { 608 return new (reinterpret_cast<Defined *>( 609 getSpecificAllocSingleton<SymbolUnion>().Allocate())) 610 Defined(std::forward<T>(args)...); 611 } 612 613 void maybeWarnUnorderableSymbol(const Symbol *sym); 614 bool computeIsPreemptible(const Symbol &sym); 615 void reportBackrefs(); 616 617 // A mapping from a symbol to an InputFile referencing it backward. Used by 618 // --warn-backrefs. 619 extern llvm::DenseMap<const Symbol *, 620 std::pair<const InputFile *, const InputFile *>> 621 backwardReferences; 622 623 // A tuple of (reference, extractedFile, sym). Used by --why-extract=. 624 extern SmallVector<std::tuple<std::string, const InputFile *, const Symbol &>, 625 0> 626 whyExtract; 627 628 } // namespace elf 629 } // namespace lld 630 631 #endif 632