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 #include "InputFiles.h"
10 #include "Chunks.h"
11 #include "Config.h"
12 #include "Driver.h"
13 #include "SymbolTable.h"
14 #include "Symbols.h"
15 #include "lld/Common/ErrorHandler.h"
16 #include "lld/Common/Memory.h"
17 #include "llvm-c/lto.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/ADT/Twine.h"
21 #include "llvm/BinaryFormat/COFF.h"
22 #include "llvm/Object/Binary.h"
23 #include "llvm/Object/COFF.h"
24 #include "llvm/Support/Casting.h"
25 #include "llvm/Support/Endian.h"
26 #include "llvm/Support/Error.h"
27 #include "llvm/Support/ErrorOr.h"
28 #include "llvm/Support/FileSystem.h"
29 #include "llvm/Support/Path.h"
30 #include "llvm/Target/TargetOptions.h"
31 #include <cstring>
32 #include <system_error>
33 #include <utility>
34 
35 using namespace llvm;
36 using namespace llvm::COFF;
37 using namespace llvm::object;
38 using namespace llvm::support::endian;
39 
40 using llvm::Triple;
41 using llvm::support::ulittle32_t;
42 
43 namespace lld {
44 namespace coff {
45 
46 std::vector<ObjFile *> ObjFile::Instances;
47 std::vector<ImportFile *> ImportFile::Instances;
48 std::vector<BitcodeFile *> BitcodeFile::Instances;
49 
50 /// Checks that Source is compatible with being a weak alias to Target.
51 /// If Source is Undefined and has no weak alias set, makes it a weak
52 /// alias to Target.
53 static void checkAndSetWeakAlias(SymbolTable *Symtab, InputFile *F,
54                                  Symbol *Source, Symbol *Target) {
55   if (auto *U = dyn_cast<Undefined>(Source)) {
56     if (U->WeakAlias && U->WeakAlias != Target) {
57       // Weak aliases as produced by GCC are named in the form
58       // .weak.<weaksymbol>.<othersymbol>, where <othersymbol> is the name
59       // of another symbol emitted near the weak symbol.
60       // Just use the definition from the first object file that defined
61       // this weak symbol.
62       if (Config->MinGW)
63         return;
64       Symtab->reportDuplicate(Source, F);
65     }
66     U->WeakAlias = Target;
67   }
68 }
69 
70 ArchiveFile::ArchiveFile(MemoryBufferRef M) : InputFile(ArchiveKind, M) {}
71 
72 void ArchiveFile::parse() {
73   // Parse a MemoryBufferRef as an archive file.
74   File = CHECK(Archive::create(MB), this);
75 
76   // Read the symbol table to construct Lazy objects.
77   for (const Archive::Symbol &Sym : File->symbols())
78     Symtab->addLazy(this, Sym);
79 }
80 
81 // Returns a buffer pointing to a member file containing a given symbol.
82 void ArchiveFile::addMember(const Archive::Symbol *Sym) {
83   const Archive::Child &C =
84       CHECK(Sym->getMember(),
85             "could not get the member for symbol " + Sym->getName());
86 
87   // Return an empty buffer if we have already returned the same buffer.
88   if (!Seen.insert(C.getChildOffset()).second)
89     return;
90 
91   Driver->enqueueArchiveMember(C, Sym->getName(), getName());
92 }
93 
94 std::vector<MemoryBufferRef> getArchiveMembers(Archive *File) {
95   std::vector<MemoryBufferRef> V;
96   Error Err = Error::success();
97   for (const ErrorOr<Archive::Child> &COrErr : File->children(Err)) {
98     Archive::Child C =
99         CHECK(COrErr,
100               File->getFileName() + ": could not get the child of the archive");
101     MemoryBufferRef MBRef =
102         CHECK(C.getMemoryBufferRef(),
103               File->getFileName() +
104                   ": could not get the buffer for a child of the archive");
105     V.push_back(MBRef);
106   }
107   if (Err)
108     fatal(File->getFileName() +
109           ": Archive::children failed: " + toString(std::move(Err)));
110   return V;
111 }
112 
113 void ObjFile::parse() {
114   // Parse a memory buffer as a COFF file.
115   std::unique_ptr<Binary> Bin = CHECK(createBinary(MB), this);
116 
117   if (auto *Obj = dyn_cast<COFFObjectFile>(Bin.get())) {
118     Bin.release();
119     COFFObj.reset(Obj);
120   } else {
121     fatal(toString(this) + " is not a COFF file");
122   }
123 
124   // Read section and symbol tables.
125   initializeChunks();
126   initializeSymbols();
127 }
128 
129 // We set SectionChunk pointers in the SparseChunks vector to this value
130 // temporarily to mark comdat sections as having an unknown resolution. As we
131 // walk the object file's symbol table, once we visit either a leader symbol or
132 // an associative section definition together with the parent comdat's leader,
133 // we set the pointer to either nullptr (to mark the section as discarded) or a
134 // valid SectionChunk for that section.
135 static SectionChunk *const PendingComdat = reinterpret_cast<SectionChunk *>(1);
136 
137 void ObjFile::initializeChunks() {
138   uint32_t NumSections = COFFObj->getNumberOfSections();
139   Chunks.reserve(NumSections);
140   SparseChunks.resize(NumSections + 1);
141   for (uint32_t I = 1; I < NumSections + 1; ++I) {
142     const coff_section *Sec;
143     if (auto EC = COFFObj->getSection(I, Sec))
144       fatal("getSection failed: #" + Twine(I) + ": " + EC.message());
145 
146     if (Sec->Characteristics & IMAGE_SCN_LNK_COMDAT)
147       SparseChunks[I] = PendingComdat;
148     else
149       SparseChunks[I] = readSection(I, nullptr, "");
150   }
151 }
152 
153 SectionChunk *ObjFile::readSection(uint32_t SectionNumber,
154                                    const coff_aux_section_definition *Def,
155                                    StringRef LeaderName) {
156   const coff_section *Sec;
157   if (auto EC = COFFObj->getSection(SectionNumber, Sec))
158     fatal("getSection failed: #" + Twine(SectionNumber) + ": " + EC.message());
159 
160   StringRef Name;
161   if (auto EC = COFFObj->getSectionName(Sec, Name))
162     fatal("getSectionName failed: #" + Twine(SectionNumber) + ": " +
163           EC.message());
164 
165   if (Name == ".drectve") {
166     ArrayRef<uint8_t> Data;
167     COFFObj->getSectionContents(Sec, Data);
168     Directives = std::string((const char *)Data.data(), Data.size());
169     return nullptr;
170   }
171 
172   if (Name == ".llvm_addrsig") {
173     AddrsigSec = Sec;
174     return nullptr;
175   }
176 
177   // Object files may have DWARF debug info or MS CodeView debug info
178   // (or both).
179   //
180   // DWARF sections don't need any special handling from the perspective
181   // of the linker; they are just a data section containing relocations.
182   // We can just link them to complete debug info.
183   //
184   // CodeView needs linker support. We need to interpret debug info,
185   // and then write it to a separate .pdb file.
186 
187   // Ignore DWARF debug info unless /debug is given.
188   if (!Config->Debug && Name.startswith(".debug_"))
189     return nullptr;
190 
191   if (Sec->Characteristics & llvm::COFF::IMAGE_SCN_LNK_REMOVE)
192     return nullptr;
193   auto *C = make<SectionChunk>(this, Sec);
194   if (Def)
195     C->Checksum = Def->CheckSum;
196 
197   // CodeView sections are stored to a different vector because they are not
198   // linked in the regular manner.
199   if (C->isCodeView())
200     DebugChunks.push_back(C);
201   else if (Config->GuardCF != GuardCFLevel::Off && Name == ".gfids$y")
202     GuardFidChunks.push_back(C);
203   else if (Config->GuardCF != GuardCFLevel::Off && Name == ".gljmp$y")
204     GuardLJmpChunks.push_back(C);
205   else if (Name == ".sxdata")
206     SXDataChunks.push_back(C);
207   else if (Config->TailMerge && Sec->NumberOfRelocations == 0 &&
208            Name == ".rdata" && LeaderName.startswith("??_C@"))
209     // COFF sections that look like string literal sections (i.e. no
210     // relocations, in .rdata, leader symbol name matches the MSVC name mangling
211     // for string literals) are subject to string tail merging.
212     MergeChunk::addSection(C);
213   else
214     Chunks.push_back(C);
215 
216   return C;
217 }
218 
219 void ObjFile::readAssociativeDefinition(
220     COFFSymbolRef Sym, const coff_aux_section_definition *Def) {
221   readAssociativeDefinition(Sym, Def, Def->getNumber(Sym.isBigObj()));
222 }
223 
224 void ObjFile::readAssociativeDefinition(COFFSymbolRef Sym,
225                                         const coff_aux_section_definition *Def,
226                                         uint32_t ParentIndex) {
227   SectionChunk *Parent = SparseChunks[ParentIndex];
228 
229   if (Parent == PendingComdat) {
230     // This can happen if an associative comdat refers to another associative
231     // comdat that appears after it (invalid per COFF spec) or to a section
232     // without any symbols.
233     StringRef Name, ParentName;
234     COFFObj->getSymbolName(Sym, Name);
235 
236     const coff_section *ParentSec;
237     COFFObj->getSection(ParentIndex, ParentSec);
238     COFFObj->getSectionName(ParentSec, ParentName);
239     error(toString(this) + ": associative comdat " + Name +
240           " has invalid reference to section " + ParentName);
241     return;
242   }
243 
244   // Check whether the parent is prevailing. If it is, so are we, and we read
245   // the section; otherwise mark it as discarded.
246   int32_t SectionNumber = Sym.getSectionNumber();
247   if (Parent) {
248     SparseChunks[SectionNumber] = readSection(SectionNumber, Def, "");
249     if (SparseChunks[SectionNumber])
250       Parent->addAssociative(SparseChunks[SectionNumber]);
251   } else {
252     SparseChunks[SectionNumber] = nullptr;
253   }
254 }
255 
256 void ObjFile::recordPrevailingSymbolForMingw(
257     COFFSymbolRef Sym, DenseMap<StringRef, uint32_t> &PrevailingSectionMap) {
258   // For comdat symbols in executable sections, where this is the copy
259   // of the section chunk we actually include instead of discarding it,
260   // add the symbol to a map to allow using it for implicitly
261   // associating .[px]data$<func> sections to it.
262   int32_t SectionNumber = Sym.getSectionNumber();
263   SectionChunk *SC = SparseChunks[SectionNumber];
264   if (SC && SC->getOutputCharacteristics() & IMAGE_SCN_MEM_EXECUTE) {
265     StringRef Name;
266     COFFObj->getSymbolName(Sym, Name);
267     PrevailingSectionMap[Name] = SectionNumber;
268   }
269 }
270 
271 void ObjFile::maybeAssociateSEHForMingw(
272     COFFSymbolRef Sym, const coff_aux_section_definition *Def,
273     const DenseMap<StringRef, uint32_t> &PrevailingSectionMap) {
274   StringRef Name;
275   COFFObj->getSymbolName(Sym, Name);
276   if (Name.consume_front(".pdata$") || Name.consume_front(".xdata$")) {
277     // For MinGW, treat .[px]data$<func> as implicitly associative to
278     // the symbol <func>.
279     auto ParentSym = PrevailingSectionMap.find(Name);
280     if (ParentSym != PrevailingSectionMap.end())
281       readAssociativeDefinition(Sym, Def, ParentSym->second);
282   }
283 }
284 
285 Symbol *ObjFile::createRegular(COFFSymbolRef Sym) {
286   SectionChunk *SC = SparseChunks[Sym.getSectionNumber()];
287   if (Sym.isExternal()) {
288     StringRef Name;
289     COFFObj->getSymbolName(Sym, Name);
290     if (SC)
291       return Symtab->addRegular(this, Name, Sym.getGeneric(), SC);
292     // For MinGW symbols named .weak.* that point to a discarded section,
293     // don't create an Undefined symbol. If nothing ever refers to the symbol,
294     // everything should be fine. If something actually refers to the symbol
295     // (e.g. the undefined weak alias), linking will fail due to undefined
296     // references at the end.
297     if (Config->MinGW && Name.startswith(".weak."))
298       return nullptr;
299     return Symtab->addUndefined(Name, this, false);
300   }
301   if (SC)
302     return make<DefinedRegular>(this, /*Name*/ "", /*IsCOMDAT*/ false,
303                                 /*IsExternal*/ false, Sym.getGeneric(), SC);
304   return nullptr;
305 }
306 
307 void ObjFile::initializeSymbols() {
308   uint32_t NumSymbols = COFFObj->getNumberOfSymbols();
309   Symbols.resize(NumSymbols);
310 
311   SmallVector<std::pair<Symbol *, uint32_t>, 8> WeakAliases;
312   std::vector<uint32_t> PendingIndexes;
313   PendingIndexes.reserve(NumSymbols);
314 
315   DenseMap<StringRef, uint32_t> PrevailingSectionMap;
316   std::vector<const coff_aux_section_definition *> ComdatDefs(
317       COFFObj->getNumberOfSections() + 1);
318 
319   for (uint32_t I = 0; I < NumSymbols; ++I) {
320     COFFSymbolRef COFFSym = check(COFFObj->getSymbol(I));
321     bool PrevailingComdat;
322     if (COFFSym.isUndefined()) {
323       Symbols[I] = createUndefined(COFFSym);
324     } else if (COFFSym.isWeakExternal()) {
325       Symbols[I] = createUndefined(COFFSym);
326       uint32_t TagIndex = COFFSym.getAux<coff_aux_weak_external>()->TagIndex;
327       WeakAliases.emplace_back(Symbols[I], TagIndex);
328     } else if (Optional<Symbol *> OptSym =
329                    createDefined(COFFSym, ComdatDefs, PrevailingComdat)) {
330       Symbols[I] = *OptSym;
331       if (Config->MinGW && PrevailingComdat)
332         recordPrevailingSymbolForMingw(COFFSym, PrevailingSectionMap);
333     } else {
334       // createDefined() returns None if a symbol belongs to a section that
335       // was pending at the point when the symbol was read. This can happen in
336       // two cases:
337       // 1) section definition symbol for a comdat leader;
338       // 2) symbol belongs to a comdat section associated with another section.
339       // In both of these cases, we can expect the section to be resolved by
340       // the time we finish visiting the remaining symbols in the symbol
341       // table. So we postpone the handling of this symbol until that time.
342       PendingIndexes.push_back(I);
343     }
344     I += COFFSym.getNumberOfAuxSymbols();
345   }
346 
347   for (uint32_t I : PendingIndexes) {
348     COFFSymbolRef Sym = check(COFFObj->getSymbol(I));
349     if (const coff_aux_section_definition *Def = Sym.getSectionDefinition()) {
350       if (Def->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE)
351         readAssociativeDefinition(Sym, Def);
352       else if (Config->MinGW)
353         maybeAssociateSEHForMingw(Sym, Def, PrevailingSectionMap);
354     }
355     if (SparseChunks[Sym.getSectionNumber()] == PendingComdat) {
356       StringRef Name;
357       COFFObj->getSymbolName(Sym, Name);
358       log("comdat section " + Name +
359           " without leader and unassociated, discarding");
360       continue;
361     }
362     Symbols[I] = createRegular(Sym);
363   }
364 
365   for (auto &KV : WeakAliases) {
366     Symbol *Sym = KV.first;
367     uint32_t Idx = KV.second;
368     checkAndSetWeakAlias(Symtab, this, Sym, Symbols[Idx]);
369   }
370 }
371 
372 Symbol *ObjFile::createUndefined(COFFSymbolRef Sym) {
373   StringRef Name;
374   COFFObj->getSymbolName(Sym, Name);
375   return Symtab->addUndefined(Name, this, Sym.isWeakExternal());
376 }
377 
378 Optional<Symbol *> ObjFile::createDefined(
379     COFFSymbolRef Sym,
380     std::vector<const coff_aux_section_definition *> &ComdatDefs,
381     bool &Prevailing) {
382   Prevailing = false;
383   auto GetName = [&]() {
384     StringRef S;
385     COFFObj->getSymbolName(Sym, S);
386     return S;
387   };
388 
389   if (Sym.isCommon()) {
390     auto *C = make<CommonChunk>(Sym);
391     Chunks.push_back(C);
392     return Symtab->addCommon(this, GetName(), Sym.getValue(), Sym.getGeneric(),
393                              C);
394   }
395 
396   if (Sym.isAbsolute()) {
397     StringRef Name = GetName();
398 
399     // Skip special symbols.
400     if (Name == "@comp.id")
401       return nullptr;
402     if (Name == "@feat.00") {
403       Feat00Flags = Sym.getValue();
404       return nullptr;
405     }
406 
407     if (Sym.isExternal())
408       return Symtab->addAbsolute(Name, Sym);
409     return make<DefinedAbsolute>(Name, Sym);
410   }
411 
412   int32_t SectionNumber = Sym.getSectionNumber();
413   if (SectionNumber == llvm::COFF::IMAGE_SYM_DEBUG)
414     return nullptr;
415 
416   if (llvm::COFF::isReservedSectionNumber(SectionNumber))
417     fatal(toString(this) + ": " + GetName() +
418           " should not refer to special section " + Twine(SectionNumber));
419 
420   if ((uint32_t)SectionNumber >= SparseChunks.size())
421     fatal(toString(this) + ": " + GetName() +
422           " should not refer to non-existent section " + Twine(SectionNumber));
423 
424   // Handle comdat leader symbols.
425   if (const coff_aux_section_definition *Def = ComdatDefs[SectionNumber]) {
426     ComdatDefs[SectionNumber] = nullptr;
427     Symbol *Leader;
428     if (Sym.isExternal()) {
429       std::tie(Leader, Prevailing) =
430           Symtab->addComdat(this, GetName(), Sym.getGeneric());
431     } else {
432       Leader = make<DefinedRegular>(this, /*Name*/ "", /*IsCOMDAT*/ false,
433                                     /*IsExternal*/ false, Sym.getGeneric());
434       Prevailing = true;
435     }
436 
437     if (Prevailing) {
438       SectionChunk *C = readSection(SectionNumber, Def, GetName());
439       SparseChunks[SectionNumber] = C;
440       C->Sym = cast<DefinedRegular>(Leader);
441       cast<DefinedRegular>(Leader)->Data = &C->Repl;
442     } else {
443       SparseChunks[SectionNumber] = nullptr;
444     }
445     return Leader;
446   }
447 
448   // Prepare to handle the comdat leader symbol by setting the section's
449   // ComdatDefs pointer if we encounter a non-associative comdat.
450   if (SparseChunks[SectionNumber] == PendingComdat) {
451     if (const coff_aux_section_definition *Def = Sym.getSectionDefinition()) {
452       if (Def->Selection != IMAGE_COMDAT_SELECT_ASSOCIATIVE)
453         ComdatDefs[SectionNumber] = Def;
454     }
455     return None;
456   }
457 
458   return createRegular(Sym);
459 }
460 
461 MachineTypes ObjFile::getMachineType() {
462   if (COFFObj)
463     return static_cast<MachineTypes>(COFFObj->getMachine());
464   return IMAGE_FILE_MACHINE_UNKNOWN;
465 }
466 
467 StringRef ltrim1(StringRef S, const char *Chars) {
468   if (!S.empty() && strchr(Chars, S[0]))
469     return S.substr(1);
470   return S;
471 }
472 
473 void ImportFile::parse() {
474   const char *Buf = MB.getBufferStart();
475   const char *End = MB.getBufferEnd();
476   const auto *Hdr = reinterpret_cast<const coff_import_header *>(Buf);
477 
478   // Check if the total size is valid.
479   if ((size_t)(End - Buf) != (sizeof(*Hdr) + Hdr->SizeOfData))
480     fatal("broken import library");
481 
482   // Read names and create an __imp_ symbol.
483   StringRef Name = Saver.save(StringRef(Buf + sizeof(*Hdr)));
484   StringRef ImpName = Saver.save("__imp_" + Name);
485   const char *NameStart = Buf + sizeof(coff_import_header) + Name.size() + 1;
486   DLLName = StringRef(NameStart);
487   StringRef ExtName;
488   switch (Hdr->getNameType()) {
489   case IMPORT_ORDINAL:
490     ExtName = "";
491     break;
492   case IMPORT_NAME:
493     ExtName = Name;
494     break;
495   case IMPORT_NAME_NOPREFIX:
496     ExtName = ltrim1(Name, "?@_");
497     break;
498   case IMPORT_NAME_UNDECORATE:
499     ExtName = ltrim1(Name, "?@_");
500     ExtName = ExtName.substr(0, ExtName.find('@'));
501     break;
502   }
503 
504   this->Hdr = Hdr;
505   ExternalName = ExtName;
506 
507   ImpSym = Symtab->addImportData(ImpName, this);
508   // If this was a duplicate, we logged an error but may continue;
509   // in this case, ImpSym is nullptr.
510   if (!ImpSym)
511     return;
512 
513   if (Hdr->getType() == llvm::COFF::IMPORT_CONST)
514     static_cast<void>(Symtab->addImportData(Name, this));
515 
516   // If type is function, we need to create a thunk which jump to an
517   // address pointed by the __imp_ symbol. (This allows you to call
518   // DLL functions just like regular non-DLL functions.)
519   if (Hdr->getType() == llvm::COFF::IMPORT_CODE)
520     ThunkSym = Symtab->addImportThunk(
521         Name, cast_or_null<DefinedImportData>(ImpSym), Hdr->Machine);
522 }
523 
524 void BitcodeFile::parse() {
525   Obj = check(lto::InputFile::create(MemoryBufferRef(
526       MB.getBuffer(), Saver.save(ParentName + MB.getBufferIdentifier()))));
527   std::vector<std::pair<Symbol *, bool>> Comdat(Obj->getComdatTable().size());
528   for (size_t I = 0; I != Obj->getComdatTable().size(); ++I)
529     Comdat[I] = Symtab->addComdat(this, Saver.save(Obj->getComdatTable()[I]));
530   for (const lto::InputFile::Symbol &ObjSym : Obj->symbols()) {
531     StringRef SymName = Saver.save(ObjSym.getName());
532     int ComdatIndex = ObjSym.getComdatIndex();
533     Symbol *Sym;
534     if (ObjSym.isUndefined()) {
535       Sym = Symtab->addUndefined(SymName, this, false);
536     } else if (ObjSym.isCommon()) {
537       Sym = Symtab->addCommon(this, SymName, ObjSym.getCommonSize());
538     } else if (ObjSym.isWeak() && ObjSym.isIndirect()) {
539       // Weak external.
540       Sym = Symtab->addUndefined(SymName, this, true);
541       std::string Fallback = ObjSym.getCOFFWeakExternalFallback();
542       Symbol *Alias = Symtab->addUndefined(Saver.save(Fallback));
543       checkAndSetWeakAlias(Symtab, this, Sym, Alias);
544     } else if (ComdatIndex != -1) {
545       if (SymName == Obj->getComdatTable()[ComdatIndex])
546         Sym = Comdat[ComdatIndex].first;
547       else if (Comdat[ComdatIndex].second)
548         Sym = Symtab->addRegular(this, SymName);
549       else
550         Sym = Symtab->addUndefined(SymName, this, false);
551     } else {
552       Sym = Symtab->addRegular(this, SymName);
553     }
554     Symbols.push_back(Sym);
555   }
556   Directives = Obj->getCOFFLinkerOpts();
557 }
558 
559 MachineTypes BitcodeFile::getMachineType() {
560   switch (Triple(Obj->getTargetTriple()).getArch()) {
561   case Triple::x86_64:
562     return AMD64;
563   case Triple::x86:
564     return I386;
565   case Triple::arm:
566     return ARMNT;
567   case Triple::aarch64:
568     return ARM64;
569   default:
570     return IMAGE_FILE_MACHINE_UNKNOWN;
571   }
572 }
573 } // namespace coff
574 } // namespace lld
575 
576 // Returns the last element of a path, which is supposed to be a filename.
577 static StringRef getBasename(StringRef Path) {
578   return sys::path::filename(Path, sys::path::Style::windows);
579 }
580 
581 // Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
582 std::string lld::toString(const coff::InputFile *File) {
583   if (!File)
584     return "<internal>";
585   if (File->ParentName.empty())
586     return File->getName();
587 
588   return (getBasename(File->ParentName) + "(" + getBasename(File->getName()) +
589           ")")
590       .str();
591 }
592