1 //===- InputFiles.cpp -----------------------------------------------------===// 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 contains functions to parse Mach-O object files. In this comment, 10 // we describe the Mach-O file structure and how we parse it. 11 // 12 // Mach-O is not very different from ELF or COFF. The notion of symbols, 13 // sections and relocations exists in Mach-O as it does in ELF and COFF. 14 // 15 // Perhaps the notion that is new to those who know ELF/COFF is "subsections". 16 // In ELF/COFF, sections are an atomic unit of data copied from input files to 17 // output files. When we merge or garbage-collect sections, we treat each 18 // section as an atomic unit. In Mach-O, that's not the case. Sections can 19 // consist of multiple subsections, and subsections are a unit of merging and 20 // garbage-collecting. Therefore, Mach-O's subsections are more similar to 21 // ELF/COFF's sections than Mach-O's sections are. 22 // 23 // A section can have multiple symbols. A symbol that does not have the 24 // N_ALT_ENTRY attribute indicates a beginning of a subsection. Therefore, by 25 // definition, a symbol is always present at the beginning of each subsection. A 26 // symbol with N_ALT_ENTRY attribute does not start a new subsection and can 27 // point to a middle of a subsection. 28 // 29 // The notion of subsections also affects how relocations are represented in 30 // Mach-O. All references within a section need to be explicitly represented as 31 // relocations if they refer to different subsections, because we obviously need 32 // to fix up addresses if subsections are laid out in an output file differently 33 // than they were in object files. To represent that, Mach-O relocations can 34 // refer to an unnamed location via its address. Scattered relocations (those 35 // with the R_SCATTERED bit set) always refer to unnamed locations. 36 // Non-scattered relocations refer to an unnamed location if r_extern is not set 37 // and r_symbolnum is zero. 38 // 39 // Without the above differences, I think you can use your knowledge about ELF 40 // and COFF for Mach-O. 41 // 42 //===----------------------------------------------------------------------===// 43 44 #include "InputFiles.h" 45 #include "Config.h" 46 #include "DriverUtils.h" 47 #include "ExportTrie.h" 48 #include "InputSection.h" 49 #include "MachOStructs.h" 50 #include "ObjC.h" 51 #include "OutputSection.h" 52 #include "OutputSegment.h" 53 #include "SymbolTable.h" 54 #include "Symbols.h" 55 #include "Target.h" 56 57 #include "lld/Common/ErrorHandler.h" 58 #include "lld/Common/Memory.h" 59 #include "llvm/ADT/iterator.h" 60 #include "llvm/BinaryFormat/MachO.h" 61 #include "llvm/Support/Endian.h" 62 #include "llvm/Support/MemoryBuffer.h" 63 #include "llvm/Support/Path.h" 64 65 using namespace llvm; 66 using namespace llvm::MachO; 67 using namespace llvm::support::endian; 68 using namespace llvm::sys; 69 using namespace lld; 70 using namespace lld::macho; 71 72 std::vector<InputFile *> macho::inputFiles; 73 74 // Open a given file path and return it as a memory-mapped file. 75 Optional<MemoryBufferRef> macho::readFile(StringRef path) { 76 // Open a file. 77 auto mbOrErr = MemoryBuffer::getFile(path); 78 if (auto ec = mbOrErr.getError()) { 79 error("cannot open " + path + ": " + ec.message()); 80 return None; 81 } 82 83 std::unique_ptr<MemoryBuffer> &mb = *mbOrErr; 84 MemoryBufferRef mbref = mb->getMemBufferRef(); 85 make<std::unique_ptr<MemoryBuffer>>(std::move(mb)); // take mb ownership 86 87 // If this is a regular non-fat file, return it. 88 const char *buf = mbref.getBufferStart(); 89 auto *hdr = reinterpret_cast<const MachO::fat_header *>(buf); 90 if (read32be(&hdr->magic) != MachO::FAT_MAGIC) 91 return mbref; 92 93 // Object files and archive files may be fat files, which contains 94 // multiple real files for different CPU ISAs. Here, we search for a 95 // file that matches with the current link target and returns it as 96 // a MemoryBufferRef. 97 auto *arch = reinterpret_cast<const MachO::fat_arch *>(buf + sizeof(*hdr)); 98 99 for (uint32_t i = 0, n = read32be(&hdr->nfat_arch); i < n; ++i) { 100 if (reinterpret_cast<const char *>(arch + i + 1) > 101 buf + mbref.getBufferSize()) { 102 error(path + ": fat_arch struct extends beyond end of file"); 103 return None; 104 } 105 106 if (read32be(&arch[i].cputype) != target->cpuType || 107 read32be(&arch[i].cpusubtype) != target->cpuSubtype) 108 continue; 109 110 uint32_t offset = read32be(&arch[i].offset); 111 uint32_t size = read32be(&arch[i].size); 112 if (offset + size > mbref.getBufferSize()) 113 error(path + ": slice extends beyond end of file"); 114 return MemoryBufferRef(StringRef(buf + offset, size), path.copy(bAlloc)); 115 } 116 117 error("unable to find matching architecture in " + path); 118 return None; 119 } 120 121 const load_command *macho::findCommand(const mach_header_64 *hdr, 122 uint32_t type) { 123 const uint8_t *p = 124 reinterpret_cast<const uint8_t *>(hdr) + sizeof(mach_header_64); 125 126 for (uint32_t i = 0, n = hdr->ncmds; i < n; ++i) { 127 auto *cmd = reinterpret_cast<const load_command *>(p); 128 if (cmd->cmd == type) 129 return cmd; 130 p += cmd->cmdsize; 131 } 132 return nullptr; 133 } 134 135 void InputFile::parseSections(ArrayRef<section_64> sections) { 136 subsections.reserve(sections.size()); 137 auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart()); 138 139 for (const section_64 &sec : sections) { 140 InputSection *isec = make<InputSection>(); 141 isec->file = this; 142 isec->name = 143 StringRef(sec.sectname, strnlen(sec.sectname, sizeof(sec.sectname))); 144 isec->segname = 145 StringRef(sec.segname, strnlen(sec.segname, sizeof(sec.segname))); 146 isec->data = {isZeroFill(sec.flags) ? nullptr : buf + sec.offset, 147 static_cast<size_t>(sec.size)}; 148 if (sec.align >= 32) 149 error("alignment " + std::to_string(sec.align) + " of section " + 150 isec->name + " is too large"); 151 else 152 isec->align = 1 << sec.align; 153 isec->flags = sec.flags; 154 subsections.push_back({{0, isec}}); 155 } 156 } 157 158 // Find the subsection corresponding to the greatest section offset that is <= 159 // that of the given offset. 160 // 161 // offset: an offset relative to the start of the original InputSection (before 162 // any subsection splitting has occurred). It will be updated to represent the 163 // same location as an offset relative to the start of the containing 164 // subsection. 165 static InputSection *findContainingSubsection(SubsectionMap &map, 166 uint32_t *offset) { 167 auto it = std::prev(map.upper_bound(*offset)); 168 *offset -= it->first; 169 return it->second; 170 } 171 172 void InputFile::parseRelocations(const section_64 &sec, 173 SubsectionMap &subsecMap) { 174 auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart()); 175 ArrayRef<any_relocation_info> anyRelInfos( 176 reinterpret_cast<const any_relocation_info *>(buf + sec.reloff), 177 sec.nreloc); 178 179 for (const any_relocation_info &anyRelInfo : anyRelInfos) { 180 if (anyRelInfo.r_word0 & R_SCATTERED) 181 fatal("TODO: Scattered relocations not supported"); 182 183 auto relInfo = reinterpret_cast<const relocation_info &>(anyRelInfo); 184 185 Reloc r; 186 r.type = relInfo.r_type; 187 r.pcrel = relInfo.r_pcrel; 188 r.length = relInfo.r_length; 189 uint64_t rawAddend = target->getImplicitAddend(mb, sec, relInfo); 190 191 if (relInfo.r_extern) { 192 r.referent = symbols[relInfo.r_symbolnum]; 193 r.addend = rawAddend; 194 } else { 195 if (relInfo.r_symbolnum == 0 || relInfo.r_symbolnum > subsections.size()) 196 fatal("invalid section index in relocation for offset " + 197 std::to_string(r.offset) + " in section " + sec.sectname + 198 " of " + getName()); 199 200 SubsectionMap &referentSubsecMap = subsections[relInfo.r_symbolnum - 1]; 201 const section_64 &referentSec = sectionHeaders[relInfo.r_symbolnum - 1]; 202 uint32_t referentOffset; 203 if (relInfo.r_pcrel) { 204 // The implicit addend for pcrel section relocations is the pcrel offset 205 // in terms of the addresses in the input file. Here we adjust it so 206 // that it describes the offset from the start of the referent section. 207 // TODO: The offset of 4 is probably not right for ARM64, nor for 208 // relocations with r_length != 2. 209 referentOffset = 210 sec.addr + relInfo.r_address + 4 + rawAddend - referentSec.addr; 211 } else { 212 // The addend for a non-pcrel relocation is its absolute address. 213 referentOffset = rawAddend - referentSec.addr; 214 } 215 r.referent = findContainingSubsection(referentSubsecMap, &referentOffset); 216 r.addend = referentOffset; 217 } 218 219 r.offset = relInfo.r_address; 220 InputSection *subsec = findContainingSubsection(subsecMap, &r.offset); 221 subsec->relocs.push_back(r); 222 } 223 } 224 225 static macho::Symbol *createDefined(const structs::nlist_64 &sym, 226 StringRef name, InputSection *isec, 227 uint32_t value) { 228 if (sym.n_type & N_EXT) 229 // Global defined symbol 230 return symtab->addDefined(name, isec, value, sym.n_desc & N_WEAK_DEF); 231 // Local defined symbol 232 return make<Defined>(name, isec, value, sym.n_desc & N_WEAK_DEF, 233 /*isExternal=*/false); 234 } 235 236 // Absolute symbols are defined symbols that do not have an associated 237 // InputSection. They cannot be weak. 238 static macho::Symbol *createAbsolute(const structs::nlist_64 &sym, 239 StringRef name) { 240 if (sym.n_type & N_EXT) 241 return symtab->addDefined(name, nullptr, sym.n_value, /*isWeakDef=*/false); 242 return make<Defined>(name, nullptr, sym.n_value, /*isWeakDef=*/false, 243 /*isExternal=*/false); 244 } 245 246 macho::Symbol *InputFile::parseNonSectionSymbol(const structs::nlist_64 &sym, 247 StringRef name) { 248 uint8_t type = sym.n_type & N_TYPE; 249 switch (type) { 250 case N_UNDF: 251 return sym.n_value == 0 252 ? symtab->addUndefined(name) 253 : symtab->addCommon(name, this, sym.n_value, 254 1 << GET_COMM_ALIGN(sym.n_desc)); 255 case N_ABS: 256 return createAbsolute(sym, name); 257 case N_PBUD: 258 case N_INDR: 259 error("TODO: support symbols of type " + std::to_string(type)); 260 return nullptr; 261 case N_SECT: 262 llvm_unreachable( 263 "N_SECT symbols should not be passed to parseNonSectionSymbol"); 264 default: 265 llvm_unreachable("invalid symbol type"); 266 } 267 } 268 269 void InputFile::parseSymbols(ArrayRef<structs::nlist_64> nList, 270 const char *strtab, bool subsectionsViaSymbols) { 271 // resize(), not reserve(), because we are going to create N_ALT_ENTRY symbols 272 // out-of-sequence. 273 symbols.resize(nList.size()); 274 std::vector<size_t> altEntrySymIdxs; 275 276 for (size_t i = 0, n = nList.size(); i < n; ++i) { 277 const structs::nlist_64 &sym = nList[i]; 278 StringRef name = strtab + sym.n_strx; 279 280 if ((sym.n_type & N_TYPE) != N_SECT) { 281 symbols[i] = parseNonSectionSymbol(sym, name); 282 continue; 283 } 284 285 const section_64 &sec = sectionHeaders[sym.n_sect - 1]; 286 SubsectionMap &subsecMap = subsections[sym.n_sect - 1]; 287 uint64_t offset = sym.n_value - sec.addr; 288 289 // If the input file does not use subsections-via-symbols, all symbols can 290 // use the same subsection. Otherwise, we must split the sections along 291 // symbol boundaries. 292 if (!subsectionsViaSymbols) { 293 symbols[i] = createDefined(sym, name, subsecMap[0], offset); 294 continue; 295 } 296 297 // nList entries aren't necessarily arranged in address order. Therefore, 298 // we can't create alt-entry symbols at this point because a later symbol 299 // may split its section, which may affect which subsection the alt-entry 300 // symbol is assigned to. So we need to handle them in a second pass below. 301 if (sym.n_desc & N_ALT_ENTRY) { 302 altEntrySymIdxs.push_back(i); 303 continue; 304 } 305 306 // Find the subsection corresponding to the greatest section offset that is 307 // <= that of the current symbol. The subsection that we find either needs 308 // to be used directly or split in two. 309 uint32_t firstSize = offset; 310 InputSection *firstIsec = findContainingSubsection(subsecMap, &firstSize); 311 312 if (firstSize == 0) { 313 // Alias of an existing symbol, or the first symbol in the section. These 314 // are handled by reusing the existing section. 315 symbols[i] = createDefined(sym, name, firstIsec, 0); 316 continue; 317 } 318 319 // We saw a symbol definition at a new offset. Split the section into two 320 // subsections. The new symbol uses the second subsection. 321 auto *secondIsec = make<InputSection>(*firstIsec); 322 secondIsec->data = firstIsec->data.slice(firstSize); 323 firstIsec->data = firstIsec->data.slice(0, firstSize); 324 // TODO: ld64 appears to preserve the original alignment as well as each 325 // subsection's offset from the last aligned address. We should consider 326 // emulating that behavior. 327 secondIsec->align = MinAlign(firstIsec->align, offset); 328 329 subsecMap[offset] = secondIsec; 330 // By construction, the symbol will be at offset zero in the new section. 331 symbols[i] = createDefined(sym, name, secondIsec, 0); 332 } 333 334 for (size_t idx : altEntrySymIdxs) { 335 const structs::nlist_64 &sym = nList[idx]; 336 StringRef name = strtab + sym.n_strx; 337 SubsectionMap &subsecMap = subsections[sym.n_sect - 1]; 338 uint32_t off = sym.n_value - sectionHeaders[sym.n_sect - 1].addr; 339 InputSection *subsec = findContainingSubsection(subsecMap, &off); 340 symbols[idx] = createDefined(sym, name, subsec, off); 341 } 342 } 343 344 OpaqueFile::OpaqueFile(MemoryBufferRef mb, StringRef segName, 345 StringRef sectName) 346 : InputFile(OpaqueKind, mb) { 347 InputSection *isec = make<InputSection>(); 348 isec->file = this; 349 isec->name = sectName.take_front(16); 350 isec->segname = segName.take_front(16); 351 const auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart()); 352 isec->data = {buf, mb.getBufferSize()}; 353 subsections.push_back({{0, isec}}); 354 } 355 356 ObjFile::ObjFile(MemoryBufferRef mb) : InputFile(ObjKind, mb) { 357 auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart()); 358 auto *hdr = reinterpret_cast<const mach_header_64 *>(mb.getBufferStart()); 359 360 if (const load_command *cmd = findCommand(hdr, LC_SEGMENT_64)) { 361 auto *c = reinterpret_cast<const segment_command_64 *>(cmd); 362 sectionHeaders = ArrayRef<section_64>{ 363 reinterpret_cast<const section_64 *>(c + 1), c->nsects}; 364 parseSections(sectionHeaders); 365 } 366 367 // TODO: Error on missing LC_SYMTAB? 368 if (const load_command *cmd = findCommand(hdr, LC_SYMTAB)) { 369 auto *c = reinterpret_cast<const symtab_command *>(cmd); 370 ArrayRef<structs::nlist_64> nList( 371 reinterpret_cast<const structs::nlist_64 *>(buf + c->symoff), c->nsyms); 372 const char *strtab = reinterpret_cast<const char *>(buf) + c->stroff; 373 bool subsectionsViaSymbols = hdr->flags & MH_SUBSECTIONS_VIA_SYMBOLS; 374 parseSymbols(nList, strtab, subsectionsViaSymbols); 375 } 376 377 // The relocations may refer to the symbols, so we parse them after we have 378 // parsed all the symbols. 379 for (size_t i = 0, n = subsections.size(); i < n; ++i) 380 parseRelocations(sectionHeaders[i], subsections[i]); 381 } 382 383 // The path can point to either a dylib or a .tbd file. 384 static Optional<DylibFile *> loadDylib(StringRef path, DylibFile *umbrella) { 385 Optional<MemoryBufferRef> mbref = readFile(path); 386 if (!mbref) { 387 error("could not read dylib file at " + path); 388 return {}; 389 } 390 391 file_magic magic = identify_magic(mbref->getBuffer()); 392 if (magic == file_magic::tapi_file) 393 return makeDylibFromTAPI(*mbref, umbrella); 394 assert(magic == file_magic::macho_dynamically_linked_shared_lib); 395 return make<DylibFile>(*mbref, umbrella); 396 } 397 398 // TBD files are parsed into a series of TAPI documents (InterfaceFiles), with 399 // the first document storing child pointers to the rest of them. When we are 400 // processing a given TBD file, we store that top-level document here. When 401 // processing re-exports, we search its children for potentially matching 402 // documents in the same TBD file. Note that the children themselves don't 403 // point to further documents, i.e. this is a two-level tree. 404 // 405 // ld64 allows a TAPI re-export to reference documents nested within other TBD 406 // files, but that seems like a strange design, so this is an intentional 407 // deviation. 408 const InterfaceFile *currentTopLevelTapi = nullptr; 409 410 // Re-exports can either refer to on-disk files, or to documents within .tbd 411 // files. 412 static Optional<DylibFile *> loadReexport(StringRef path, DylibFile *umbrella) { 413 if (path::is_absolute(path, path::Style::posix)) 414 for (StringRef root : config->systemLibraryRoots) 415 if (Optional<std::string> dylibPath = 416 resolveDylibPath((root + path).str())) 417 return loadDylib(*dylibPath, umbrella); 418 419 // TODO: Expand @loader_path, @executable_path etc 420 421 if (currentTopLevelTapi) { 422 for (InterfaceFile &child : 423 make_pointee_range(currentTopLevelTapi->documents())) { 424 if (path == child.getInstallName()) 425 return make<DylibFile>(child, umbrella); 426 assert(child.documents().empty()); 427 } 428 } 429 430 if (Optional<std::string> dylibPath = resolveDylibPath(path)) 431 return loadDylib(*dylibPath, umbrella); 432 433 error("unable to locate re-export with install name " + path); 434 return {}; 435 } 436 437 DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella) 438 : InputFile(DylibKind, mb) { 439 if (umbrella == nullptr) 440 umbrella = this; 441 442 auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart()); 443 auto *hdr = reinterpret_cast<const mach_header_64 *>(mb.getBufferStart()); 444 445 // Initialize dylibName. 446 if (const load_command *cmd = findCommand(hdr, LC_ID_DYLIB)) { 447 auto *c = reinterpret_cast<const dylib_command *>(cmd); 448 dylibName = reinterpret_cast<const char *>(cmd) + read32le(&c->dylib.name); 449 } else { 450 error("dylib " + getName() + " missing LC_ID_DYLIB load command"); 451 return; 452 } 453 454 // Initialize symbols. 455 // TODO: if a re-exported dylib is public (lives in /usr/lib or 456 // /System/Library/Frameworks), we should bind to its symbols directly 457 // instead of the re-exporting umbrella library. 458 if (const load_command *cmd = findCommand(hdr, LC_DYLD_INFO_ONLY)) { 459 auto *c = reinterpret_cast<const dyld_info_command *>(cmd); 460 parseTrie(buf + c->export_off, c->export_size, 461 [&](const Twine &name, uint64_t flags) { 462 bool isWeakDef = flags & EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION; 463 bool isTlv = flags & EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL; 464 symbols.push_back(symtab->addDylib(saver.save(name), umbrella, 465 isWeakDef, isTlv)); 466 }); 467 } else { 468 error("LC_DYLD_INFO_ONLY not found in " + getName()); 469 return; 470 } 471 472 if (hdr->flags & MH_NO_REEXPORTED_DYLIBS) 473 return; 474 475 const uint8_t *p = 476 reinterpret_cast<const uint8_t *>(hdr) + sizeof(mach_header_64); 477 for (uint32_t i = 0, n = hdr->ncmds; i < n; ++i) { 478 auto *cmd = reinterpret_cast<const load_command *>(p); 479 p += cmd->cmdsize; 480 if (cmd->cmd != LC_REEXPORT_DYLIB) 481 continue; 482 483 auto *c = reinterpret_cast<const dylib_command *>(cmd); 484 StringRef reexportPath = 485 reinterpret_cast<const char *>(c) + read32le(&c->dylib.name); 486 if (Optional<DylibFile *> reexport = loadReexport(reexportPath, umbrella)) 487 reexported.push_back(*reexport); 488 } 489 } 490 491 DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella) 492 : InputFile(DylibKind, interface) { 493 if (umbrella == nullptr) 494 umbrella = this; 495 496 dylibName = saver.save(interface.getInstallName()); 497 auto addSymbol = [&](const Twine &name) -> void { 498 symbols.push_back(symtab->addDylib(saver.save(name), umbrella, 499 /*isWeakDef=*/false, 500 /*isTlv=*/false)); 501 }; 502 // TODO(compnerd) filter out symbols based on the target platform 503 // TODO: handle weak defs, thread locals 504 for (const auto symbol : interface.symbols()) { 505 if (!symbol->getArchitectures().has(config->arch)) 506 continue; 507 508 switch (symbol->getKind()) { 509 case SymbolKind::GlobalSymbol: 510 addSymbol(symbol->getName()); 511 break; 512 case SymbolKind::ObjectiveCClass: 513 // XXX ld64 only creates these symbols when -ObjC is passed in. We may 514 // want to emulate that. 515 addSymbol(objc::klass + symbol->getName()); 516 addSymbol(objc::metaclass + symbol->getName()); 517 break; 518 case SymbolKind::ObjectiveCClassEHType: 519 addSymbol(objc::ehtype + symbol->getName()); 520 break; 521 case SymbolKind::ObjectiveCInstanceVariable: 522 addSymbol(objc::ivar + symbol->getName()); 523 break; 524 } 525 } 526 527 bool isTopLevelTapi = false; 528 if (currentTopLevelTapi == nullptr) { 529 currentTopLevelTapi = &interface; 530 isTopLevelTapi = true; 531 } 532 533 for (InterfaceFileRef intfRef : interface.reexportedLibraries()) 534 if (Optional<DylibFile *> reexport = 535 loadReexport(intfRef.getInstallName(), umbrella)) 536 reexported.push_back(*reexport); 537 538 if (isTopLevelTapi) 539 currentTopLevelTapi = nullptr; 540 } 541 542 ArchiveFile::ArchiveFile(std::unique_ptr<llvm::object::Archive> &&f) 543 : InputFile(ArchiveKind, f->getMemoryBufferRef()), file(std::move(f)) { 544 for (const object::Archive::Symbol &sym : file->symbols()) 545 symtab->addLazy(sym.getName(), this, sym); 546 } 547 548 void ArchiveFile::fetch(const object::Archive::Symbol &sym) { 549 object::Archive::Child c = 550 CHECK(sym.getMember(), toString(this) + 551 ": could not get the member for symbol " + 552 sym.getName()); 553 554 if (!seen.insert(c.getChildOffset()).second) 555 return; 556 557 MemoryBufferRef mb = 558 CHECK(c.getMemoryBufferRef(), 559 toString(this) + 560 ": could not get the buffer for the member defining symbol " + 561 sym.getName()); 562 auto file = make<ObjFile>(mb); 563 symbols.insert(symbols.end(), file->symbols.begin(), file->symbols.end()); 564 subsections.insert(subsections.end(), file->subsections.begin(), 565 file->subsections.end()); 566 } 567 568 // Returns "<internal>" or "baz.o". 569 std::string lld::toString(const InputFile *file) { 570 return file ? std::string(file->getName()) : "<internal>"; 571 } 572