summaryrefslogtreecommitdiff
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-11-16 23:50:34 -0800
committerFangrui Song <i@maskray.me>2024-11-16 23:50:35 -0800
commitdbf37e956a0dd60ac84e3c08bc1fe8170cf44d22 (patch)
tree866c2e41a4b8ae915df12c992a81b0508329a45b /lld/ELF/InputFiles.cpp
parent2991a4e2097ab3f32d37fdceab08c658836e312c (diff)
[ELF] Move InputFile storage from make<> to LinkerDriver::files
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 224912706f20..3a0ae43b813f 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -216,6 +216,8 @@ InputFile::InputFile(Ctx &ctx, Kind k, MemoryBufferRef m)
++ctx.driver.nextGroupId;
}
+InputFile::~InputFile() {}
+
std::optional<MemoryBufferRef> elf::readFile(Ctx &ctx, StringRef path) {
llvm::TimeTraceScope timeScope("Load input files", path);
@@ -345,19 +347,22 @@ extern template void ObjFile<ELF64LE>::importCmseSymbols();
extern template void ObjFile<ELF64BE>::importCmseSymbols();
template <class ELFT>
-static void doParseFiles(Ctx &ctx, const std::vector<InputFile *> &files) {
+static void
+doParseFiles(Ctx &ctx,
+ const SmallVector<std::unique_ptr<InputFile>, 0> &files) {
// Add all files to the symbol table. This will add almost all symbols that we
// need to the symbol table. This process might add files to the link due to
// addDependentLibrary.
for (size_t i = 0; i < files.size(); ++i) {
llvm::TimeTraceScope timeScope("Parse input files", files[i]->getName());
- doParseFile<ELFT>(ctx, files[i]);
+ doParseFile<ELFT>(ctx, files[i].get());
}
if (ctx.driver.armCmseImpLib)
cast<ObjFile<ELFT>>(*ctx.driver.armCmseImpLib).importCmseSymbols();
}
-void elf::parseFiles(Ctx &ctx, const std::vector<InputFile *> &files) {
+void elf::parseFiles(Ctx &ctx,
+ const SmallVector<std::unique_ptr<InputFile>, 0> &files) {
llvm::TimeTraceScope timeScope("Parse input files");
invokeELFT(doParseFiles, ctx, files);
}
@@ -1878,21 +1883,22 @@ InputFile *elf::createInternalFile(Ctx &ctx, StringRef name) {
return file;
}
-ELFFileBase *elf::createObjFile(Ctx &ctx, MemoryBufferRef mb,
- StringRef archiveName, bool lazy) {
- ELFFileBase *f;
+std::unique_ptr<ELFFileBase> elf::createObjFile(Ctx &ctx, MemoryBufferRef mb,
+ StringRef archiveName,
+ bool lazy) {
+ std::unique_ptr<ELFFileBase> f;
switch (getELFKind(ctx, mb, archiveName)) {
case ELF32LEKind:
- f = make<ObjFile<ELF32LE>>(ctx, ELF32LEKind, mb, archiveName);
+ f = std::make_unique<ObjFile<ELF32LE>>(ctx, ELF32LEKind, mb, archiveName);
break;
case ELF32BEKind:
- f = make<ObjFile<ELF32BE>>(ctx, ELF32BEKind, mb, archiveName);
+ f = std::make_unique<ObjFile<ELF32BE>>(ctx, ELF32BEKind, mb, archiveName);
break;
case ELF64LEKind:
- f = make<ObjFile<ELF64LE>>(ctx, ELF64LEKind, mb, archiveName);
+ f = std::make_unique<ObjFile<ELF64LE>>(ctx, ELF64LEKind, mb, archiveName);
break;
case ELF64BEKind:
- f = make<ObjFile<ELF64BE>>(ctx, ELF64BEKind, mb, archiveName);
+ f = std::make_unique<ObjFile<ELF64BE>>(ctx, ELF64BEKind, mb, archiveName);
break;
default:
llvm_unreachable("getELFKind");