return false;
}
std::unique_ptr<InputFile> File = std::move(FileOrErr.get());
+ if (Config->Verbose)
+ llvm::outs() << "Reading " << File->getName() << "\n";
if (auto EC = Symtab.addFile(std::move(File))) {
llvm::errs() << Path << ": " << EC.message() << "\n";
return false;
// Sets a parent filename if this file is created from an archive.
void setParentName(StringRef N) { ParentName = N; }
+ // Returns .drectve section contents if exist.
+ virtual StringRef getDirectives() { return ""; }
+
protected:
explicit InputFile(Kind K, MemoryBufferRef M) : MB(M), FileKind(K) {}
MemoryBufferRef MB;
// underlying object file.
SymbolBody *getSymbolBody(uint32_t SymbolIndex);
- // Returns .drectve section contents if exist.
- StringRef getDirectives() { return Directives; }
-
// Returns the underying COFF file.
COFFObjectFile *getCOFFObj() { return COFFObj.get(); }
+ StringRef getDirectives() override { return Directives; }
+
private:
std::error_code initializeChunks();
std::error_code initializeSymbols();
LTOModule *releaseModule() { return M.release(); }
// Returns linker directives from module flags metadata if present.
- StringRef getDirectives() { return Directives; }
+ StringRef getDirectives() override { return Directives; }
private:
std::error_code parse() override;
return addImport(cast<ImportFile>(FileP));
}
-std::error_code SymbolTable::addDirectives(StringRef Dir) {
- if (Dir.empty())
+std::error_code SymbolTable::addDirectives(InputFile *File) {
+ StringRef S = File->getDirectives();
+ if (S.empty())
return std::error_code();
std::vector<std::unique_ptr<InputFile>> Libs;
- if (auto EC = Driver->parseDirectives(Dir, &Libs))
+ if (auto EC = Driver->parseDirectives(S, &Libs))
return EC;
- for (std::unique_ptr<InputFile> &Lib : Libs)
+ for (std::unique_ptr<InputFile> &Lib : Libs) {
+ if (Config->Verbose) {
+ llvm::outs() << "Reading " << Lib->getName()
+ << " for " << File->getName() << "\n";
+ }
addFile(std::move(Lib));
+ }
return std::error_code();
}
// If an object file contains .drectve section, read it and add
// files listed in the section.
- return addDirectives(File->getDirectives());
+ return addDirectives(File);
}
std::error_code SymbolTable::addArchive(ArchiveFile *File) {
return EC;
// Add any linker directives from the module flags metadata.
- return addDirectives(File->getDirectives());
+ return addDirectives(File);
}
std::error_code SymbolTable::addImport(ImportFile *File) {
std::error_code rename(StringRef From, StringRef To);
private:
- std::error_code addDirectives(StringRef Dir);
+ std::error_code addDirectives(InputFile *File);
std::error_code addObject(ObjectFile *File);
std::error_code addArchive(ArchiveFile *File);