summaryrefslogtreecommitdiff
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-24 15:03:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-07-24 15:03:44 +0000
commit4b4fe385e49bd883fd183b5f21c1ea486c722e61 (patch)
treec3d8fdb355c9c73e57723718c22103aaf7d15aa6 /lld/ELF/InputFiles.cpp
parent1f917f69ff07f09b6dbb670971f57f8efe718b84 (diff)
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp37
1 files changed, 15 insertions, 22 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 0ea2a2c74b63..c0076a3722fe 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -739,7 +739,7 @@ static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {
attributes.getAttributeValue(ARMBuildAttrs::CPU_arch);
if (!attr)
return;
- auto arch = attr.getValue();
+ auto arch = attr.value();
switch (arch) {
case ARMBuildAttrs::Pre_v4:
case ARMBuildAttrs::v4:
@@ -1710,34 +1710,27 @@ void BinaryFile::parse() {
data.size(), 0, nullptr});
}
-InputFile *elf::createObjectFile(MemoryBufferRef mb, StringRef archiveName,
- uint64_t offsetInArchive) {
- if (isBitcode(mb))
- return make<BitcodeFile>(mb, archiveName, offsetInArchive, /*lazy=*/false);
-
+ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,
+ bool lazy) {
+ ELFFileBase *f;
switch (getELFKind(mb, archiveName)) {
case ELF32LEKind:
- return make<ObjFile<ELF32LE>>(mb, archiveName);
+ f = make<ObjFile<ELF32LE>>(mb, archiveName);
+ break;
case ELF32BEKind:
- return make<ObjFile<ELF32BE>>(mb, archiveName);
+ f = make<ObjFile<ELF32BE>>(mb, archiveName);
+ break;
case ELF64LEKind:
- return make<ObjFile<ELF64LE>>(mb, archiveName);
+ f = make<ObjFile<ELF64LE>>(mb, archiveName);
+ break;
case ELF64BEKind:
- return make<ObjFile<ELF64BE>>(mb, archiveName);
+ f = make<ObjFile<ELF64BE>>(mb, archiveName);
+ break;
default:
llvm_unreachable("getELFKind");
}
-}
-
-InputFile *elf::createLazyFile(MemoryBufferRef mb, StringRef archiveName,
- uint64_t offsetInArchive) {
- if (isBitcode(mb))
- return make<BitcodeFile>(mb, archiveName, offsetInArchive, /*lazy=*/true);
-
- auto *file =
- cast<ELFFileBase>(createObjectFile(mb, archiveName, offsetInArchive));
- file->lazy = true;
- return file;
+ f->lazy = lazy;
+ return f;
}
template <class ELFT> void ObjFile<ELFT>::parseLazy() {
@@ -1763,7 +1756,7 @@ template <class ELFT> void ObjFile<ELFT>::parseLazy() {
}
bool InputFile::shouldExtractForCommon(StringRef name) {
- if (isBitcode(mb))
+ if (isa<BitcodeFile>(this))
return isBitcodeNonCommonDef(mb, name, archiveName);
return isNonCommonDef(mb, name, archiveName);