1 //===- ELFObjectFile.cpp - ELF object file implementation -----------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Part of the ELFObjectFile class implementation.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Object/ELFObjectFile.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/BinaryFormat/ELF.h"
16 #include "llvm/MC/MCInstrAnalysis.h"
17 #include "llvm/MC/SubtargetFeature.h"
18 #include "llvm/Object/ELF.h"
19 #include "llvm/Object/ELFTypes.h"
20 #include "llvm/Object/Error.h"
21 #include "llvm/Support/ARMAttributeParser.h"
22 #include "llvm/Support/ARMBuildAttributes.h"
23 #include "llvm/Support/Endian.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/MathExtras.h"
26 #include "llvm/Support/RISCVAttributeParser.h"
27 #include "llvm/Support/RISCVAttributes.h"
28 #include "llvm/Support/TargetRegistry.h"
34 #include <system_error>
38 using namespace object
;
40 const EnumEntry
<unsigned> llvm::object::ElfSymbolTypes
[NumElfSymbolTypes
] = {
41 {"None", "NOTYPE", ELF::STT_NOTYPE
},
42 {"Object", "OBJECT", ELF::STT_OBJECT
},
43 {"Function", "FUNC", ELF::STT_FUNC
},
44 {"Section", "SECTION", ELF::STT_SECTION
},
45 {"File", "FILE", ELF::STT_FILE
},
46 {"Common", "COMMON", ELF::STT_COMMON
},
47 {"TLS", "TLS", ELF::STT_TLS
},
48 {"Unknown", "<unknown>: 7", 7},
49 {"Unknown", "<unknown>: 8", 8},
50 {"Unknown", "<unknown>: 9", 9},
51 {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC
},
52 {"OS Specific", "<OS specific>: 11", 11},
53 {"OS Specific", "<OS specific>: 12", 12},
54 {"Proc Specific", "<processor specific>: 13", 13},
55 {"Proc Specific", "<processor specific>: 14", 14},
56 {"Proc Specific", "<processor specific>: 15", 15}
59 ELFObjectFileBase::ELFObjectFileBase(unsigned int Type
, MemoryBufferRef Source
)
60 : ObjectFile(Type
, Source
) {}
63 static Expected
<std::unique_ptr
<ELFObjectFile
<ELFT
>>>
64 createPtr(MemoryBufferRef Object
, bool InitContent
) {
65 auto Ret
= ELFObjectFile
<ELFT
>::create(Object
, InitContent
);
66 if (Error E
= Ret
.takeError())
68 return std::make_unique
<ELFObjectFile
<ELFT
>>(std::move(*Ret
));
71 Expected
<std::unique_ptr
<ObjectFile
>>
72 ObjectFile::createELFObjectFile(MemoryBufferRef Obj
, bool InitContent
) {
73 std::pair
<unsigned char, unsigned char> Ident
=
74 getElfArchType(Obj
.getBuffer());
75 std::size_t MaxAlignment
=
76 1ULL << countTrailingZeros(
77 reinterpret_cast<uintptr_t>(Obj
.getBufferStart()));
80 return createError("Insufficient alignment");
82 if (Ident
.first
== ELF::ELFCLASS32
) {
83 if (Ident
.second
== ELF::ELFDATA2LSB
)
84 return createPtr
<ELF32LE
>(Obj
, InitContent
);
85 else if (Ident
.second
== ELF::ELFDATA2MSB
)
86 return createPtr
<ELF32BE
>(Obj
, InitContent
);
88 return createError("Invalid ELF data");
89 } else if (Ident
.first
== ELF::ELFCLASS64
) {
90 if (Ident
.second
== ELF::ELFDATA2LSB
)
91 return createPtr
<ELF64LE
>(Obj
, InitContent
);
92 else if (Ident
.second
== ELF::ELFDATA2MSB
)
93 return createPtr
<ELF64BE
>(Obj
, InitContent
);
95 return createError("Invalid ELF data");
97 return createError("Invalid ELF class");
100 SubtargetFeatures
ELFObjectFileBase::getMIPSFeatures() const {
101 SubtargetFeatures Features
;
102 unsigned PlatformFlags
= getPlatformFlags();
104 switch (PlatformFlags
& ELF::EF_MIPS_ARCH
) {
105 case ELF::EF_MIPS_ARCH_1
:
107 case ELF::EF_MIPS_ARCH_2
:
108 Features
.AddFeature("mips2");
110 case ELF::EF_MIPS_ARCH_3
:
111 Features
.AddFeature("mips3");
113 case ELF::EF_MIPS_ARCH_4
:
114 Features
.AddFeature("mips4");
116 case ELF::EF_MIPS_ARCH_5
:
117 Features
.AddFeature("mips5");
119 case ELF::EF_MIPS_ARCH_32
:
120 Features
.AddFeature("mips32");
122 case ELF::EF_MIPS_ARCH_64
:
123 Features
.AddFeature("mips64");
125 case ELF::EF_MIPS_ARCH_32R2
:
126 Features
.AddFeature("mips32r2");
128 case ELF::EF_MIPS_ARCH_64R2
:
129 Features
.AddFeature("mips64r2");
131 case ELF::EF_MIPS_ARCH_32R6
:
132 Features
.AddFeature("mips32r6");
134 case ELF::EF_MIPS_ARCH_64R6
:
135 Features
.AddFeature("mips64r6");
138 llvm_unreachable("Unknown EF_MIPS_ARCH value");
141 switch (PlatformFlags
& ELF::EF_MIPS_MACH
) {
142 case ELF::EF_MIPS_MACH_NONE
:
143 // No feature associated with this value.
145 case ELF::EF_MIPS_MACH_OCTEON
:
146 Features
.AddFeature("cnmips");
149 llvm_unreachable("Unknown EF_MIPS_ARCH value");
152 if (PlatformFlags
& ELF::EF_MIPS_ARCH_ASE_M16
)
153 Features
.AddFeature("mips16");
154 if (PlatformFlags
& ELF::EF_MIPS_MICROMIPS
)
155 Features
.AddFeature("micromips");
160 SubtargetFeatures
ELFObjectFileBase::getARMFeatures() const {
161 SubtargetFeatures Features
;
162 ARMAttributeParser Attributes
;
163 if (Error E
= getBuildAttributes(Attributes
)) {
164 consumeError(std::move(E
));
165 return SubtargetFeatures();
168 // both ARMv7-M and R have to support thumb hardware div
170 Optional
<unsigned> Attr
=
171 Attributes
.getAttributeValue(ARMBuildAttrs::CPU_arch
);
173 isV7
= Attr
.getValue() == ARMBuildAttrs::v7
;
175 Attr
= Attributes
.getAttributeValue(ARMBuildAttrs::CPU_arch_profile
);
176 if (Attr
.hasValue()) {
177 switch (Attr
.getValue()) {
178 case ARMBuildAttrs::ApplicationProfile
:
179 Features
.AddFeature("aclass");
181 case ARMBuildAttrs::RealTimeProfile
:
182 Features
.AddFeature("rclass");
184 Features
.AddFeature("hwdiv");
186 case ARMBuildAttrs::MicroControllerProfile
:
187 Features
.AddFeature("mclass");
189 Features
.AddFeature("hwdiv");
194 Attr
= Attributes
.getAttributeValue(ARMBuildAttrs::THUMB_ISA_use
);
195 if (Attr
.hasValue()) {
196 switch (Attr
.getValue()) {
199 case ARMBuildAttrs::Not_Allowed
:
200 Features
.AddFeature("thumb", false);
201 Features
.AddFeature("thumb2", false);
203 case ARMBuildAttrs::AllowThumb32
:
204 Features
.AddFeature("thumb2");
209 Attr
= Attributes
.getAttributeValue(ARMBuildAttrs::FP_arch
);
210 if (Attr
.hasValue()) {
211 switch (Attr
.getValue()) {
214 case ARMBuildAttrs::Not_Allowed
:
215 Features
.AddFeature("vfp2sp", false);
216 Features
.AddFeature("vfp3d16sp", false);
217 Features
.AddFeature("vfp4d16sp", false);
219 case ARMBuildAttrs::AllowFPv2
:
220 Features
.AddFeature("vfp2");
222 case ARMBuildAttrs::AllowFPv3A
:
223 case ARMBuildAttrs::AllowFPv3B
:
224 Features
.AddFeature("vfp3");
226 case ARMBuildAttrs::AllowFPv4A
:
227 case ARMBuildAttrs::AllowFPv4B
:
228 Features
.AddFeature("vfp4");
233 Attr
= Attributes
.getAttributeValue(ARMBuildAttrs::Advanced_SIMD_arch
);
234 if (Attr
.hasValue()) {
235 switch (Attr
.getValue()) {
238 case ARMBuildAttrs::Not_Allowed
:
239 Features
.AddFeature("neon", false);
240 Features
.AddFeature("fp16", false);
242 case ARMBuildAttrs::AllowNeon
:
243 Features
.AddFeature("neon");
245 case ARMBuildAttrs::AllowNeon2
:
246 Features
.AddFeature("neon");
247 Features
.AddFeature("fp16");
252 Attr
= Attributes
.getAttributeValue(ARMBuildAttrs::MVE_arch
);
253 if (Attr
.hasValue()) {
254 switch (Attr
.getValue()) {
257 case ARMBuildAttrs::Not_Allowed
:
258 Features
.AddFeature("mve", false);
259 Features
.AddFeature("mve.fp", false);
261 case ARMBuildAttrs::AllowMVEInteger
:
262 Features
.AddFeature("mve.fp", false);
263 Features
.AddFeature("mve");
265 case ARMBuildAttrs::AllowMVEIntegerAndFloat
:
266 Features
.AddFeature("mve.fp");
271 Attr
= Attributes
.getAttributeValue(ARMBuildAttrs::DIV_use
);
272 if (Attr
.hasValue()) {
273 switch (Attr
.getValue()) {
276 case ARMBuildAttrs::DisallowDIV
:
277 Features
.AddFeature("hwdiv", false);
278 Features
.AddFeature("hwdiv-arm", false);
280 case ARMBuildAttrs::AllowDIVExt
:
281 Features
.AddFeature("hwdiv");
282 Features
.AddFeature("hwdiv-arm");
290 SubtargetFeatures
ELFObjectFileBase::getRISCVFeatures() const {
291 SubtargetFeatures Features
;
292 unsigned PlatformFlags
= getPlatformFlags();
294 if (PlatformFlags
& ELF::EF_RISCV_RVC
) {
295 Features
.AddFeature("c");
298 // Add features according to the ELF attribute section.
299 // If there are any unrecognized features, ignore them.
300 RISCVAttributeParser Attributes
;
301 if (Error E
= getBuildAttributes(Attributes
)) {
302 // TODO Propagate Error.
303 consumeError(std::move(E
));
304 return Features
; // Keep "c" feature if there is one in PlatformFlags.
307 Optional
<StringRef
> Attr
= Attributes
.getAttributeString(RISCVAttrs::ARCH
);
308 if (Attr
.hasValue()) {
309 // The Arch pattern is [rv32|rv64][i|e]version(_[m|a|f|d|c]version)*
310 // Version string pattern is (major)p(minor). Major and minor are optional.
311 // For example, a version number could be 2p0, 2, or p92.
312 StringRef Arch
= Attr
.getValue();
313 if (Arch
.consume_front("rv32"))
314 Features
.AddFeature("64bit", false);
315 else if (Arch
.consume_front("rv64"))
316 Features
.AddFeature("64bit");
318 while (!Arch
.empty()) {
321 break; // Ignore unexpected features.
323 Features
.AddFeature("e", false);
326 Features
.AddFeature("f"); // D-ext will imply F-ext.
333 Features
.AddFeature(Arch
.take_front());
337 // FIXME: Handle version numbers.
338 Arch
= Arch
.drop_until([](char c
) { return c
== '_' || c
== '\0'; });
339 Arch
= Arch
.drop_while([](char c
) { return c
== '_'; });
346 SubtargetFeatures
ELFObjectFileBase::getFeatures() const {
347 switch (getEMachine()) {
349 return getMIPSFeatures();
351 return getARMFeatures();
353 return getRISCVFeatures();
355 return SubtargetFeatures();
359 Optional
<StringRef
> ELFObjectFileBase::tryGetCPUName() const {
360 switch (getEMachine()) {
362 return getAMDGPUCPUName();
368 StringRef
ELFObjectFileBase::getAMDGPUCPUName() const {
369 assert(getEMachine() == ELF::EM_AMDGPU
);
370 unsigned CPU
= getPlatformFlags() & ELF::EF_AMDGPU_MACH
;
373 // Radeon HD 2000/3000 Series (R600).
374 case ELF::EF_AMDGPU_MACH_R600_R600
:
376 case ELF::EF_AMDGPU_MACH_R600_R630
:
378 case ELF::EF_AMDGPU_MACH_R600_RS880
:
380 case ELF::EF_AMDGPU_MACH_R600_RV670
:
383 // Radeon HD 4000 Series (R700).
384 case ELF::EF_AMDGPU_MACH_R600_RV710
:
386 case ELF::EF_AMDGPU_MACH_R600_RV730
:
388 case ELF::EF_AMDGPU_MACH_R600_RV770
:
391 // Radeon HD 5000 Series (Evergreen).
392 case ELF::EF_AMDGPU_MACH_R600_CEDAR
:
394 case ELF::EF_AMDGPU_MACH_R600_CYPRESS
:
396 case ELF::EF_AMDGPU_MACH_R600_JUNIPER
:
398 case ELF::EF_AMDGPU_MACH_R600_REDWOOD
:
400 case ELF::EF_AMDGPU_MACH_R600_SUMO
:
403 // Radeon HD 6000 Series (Northern Islands).
404 case ELF::EF_AMDGPU_MACH_R600_BARTS
:
406 case ELF::EF_AMDGPU_MACH_R600_CAICOS
:
408 case ELF::EF_AMDGPU_MACH_R600_CAYMAN
:
410 case ELF::EF_AMDGPU_MACH_R600_TURKS
:
414 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX600
:
416 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX601
:
418 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX602
:
422 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX700
:
424 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX701
:
426 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX702
:
428 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX703
:
430 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX704
:
432 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX705
:
436 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX801
:
438 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX802
:
440 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX803
:
442 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX805
:
444 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX810
:
448 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX900
:
450 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX902
:
452 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX904
:
454 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX906
:
456 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX908
:
458 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX909
:
460 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX90A
:
462 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX90C
:
466 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1010
:
468 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1011
:
470 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1012
:
472 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1013
:
474 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1030
:
476 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1031
:
478 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1032
:
480 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1033
:
482 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1034
:
484 case ELF::EF_AMDGPU_MACH_AMDGCN_GFX1035
:
487 llvm_unreachable("Unknown EF_AMDGPU_MACH value");
491 // FIXME Encode from a tablegen description or target parser.
492 void ELFObjectFileBase::setARMSubArch(Triple
&TheTriple
) const {
493 if (TheTriple
.getSubArch() != Triple::NoSubArch
)
496 ARMAttributeParser Attributes
;
497 if (Error E
= getBuildAttributes(Attributes
)) {
498 // TODO Propagate Error.
499 consumeError(std::move(E
));
504 // Default to ARM, but use the triple if it's been set.
505 if (TheTriple
.isThumb())
510 Optional
<unsigned> Attr
=
511 Attributes
.getAttributeValue(ARMBuildAttrs::CPU_arch
);
512 if (Attr
.hasValue()) {
513 switch (Attr
.getValue()) {
514 case ARMBuildAttrs::v4
:
517 case ARMBuildAttrs::v4T
:
520 case ARMBuildAttrs::v5T
:
523 case ARMBuildAttrs::v5TE
:
526 case ARMBuildAttrs::v5TEJ
:
529 case ARMBuildAttrs::v6
:
532 case ARMBuildAttrs::v6KZ
:
535 case ARMBuildAttrs::v6T2
:
538 case ARMBuildAttrs::v6K
:
541 case ARMBuildAttrs::v7
: {
542 Optional
<unsigned> ArchProfileAttr
=
543 Attributes
.getAttributeValue(ARMBuildAttrs::CPU_arch_profile
);
544 if (ArchProfileAttr
.hasValue() &&
545 ArchProfileAttr
.getValue() == ARMBuildAttrs::MicroControllerProfile
)
551 case ARMBuildAttrs::v6_M
:
554 case ARMBuildAttrs::v6S_M
:
557 case ARMBuildAttrs::v7E_M
:
560 case ARMBuildAttrs::v8_A
:
563 case ARMBuildAttrs::v8_R
:
566 case ARMBuildAttrs::v8_M_Base
:
567 Triple
+= "v8m.base";
569 case ARMBuildAttrs::v8_M_Main
:
570 Triple
+= "v8m.main";
572 case ARMBuildAttrs::v8_1_M_Main
:
573 Triple
+= "v8.1m.main";
577 if (!isLittleEndian())
580 TheTriple
.setArchName(Triple
);
583 std::vector
<std::pair
<Optional
<DataRefImpl
>, uint64_t>>
584 ELFObjectFileBase::getPltAddresses() const {
586 const auto Triple
= makeTriple();
587 const auto *T
= TargetRegistry::lookupTarget(Triple
.str(), Err
);
590 uint64_t JumpSlotReloc
= 0;
591 switch (Triple
.getArch()) {
593 JumpSlotReloc
= ELF::R_386_JUMP_SLOT
;
596 JumpSlotReloc
= ELF::R_X86_64_JUMP_SLOT
;
598 case Triple::aarch64
:
599 case Triple::aarch64_be
:
600 JumpSlotReloc
= ELF::R_AARCH64_JUMP_SLOT
;
605 std::unique_ptr
<const MCInstrInfo
> MII(T
->createMCInstrInfo());
606 std::unique_ptr
<const MCInstrAnalysis
> MIA(
607 T
->createMCInstrAnalysis(MII
.get()));
610 Optional
<SectionRef
> Plt
= None
, RelaPlt
= None
, GotPlt
= None
;
611 for (const SectionRef
&Section
: sections()) {
612 Expected
<StringRef
> NameOrErr
= Section
.getName();
614 consumeError(NameOrErr
.takeError());
617 StringRef Name
= *NameOrErr
;
621 else if (Name
== ".rela.plt" || Name
== ".rel.plt")
623 else if (Name
== ".got.plt")
626 if (!Plt
|| !RelaPlt
|| !GotPlt
)
628 Expected
<StringRef
> PltContents
= Plt
->getContents();
630 consumeError(PltContents
.takeError());
633 auto PltEntries
= MIA
->findPltEntries(Plt
->getAddress(),
634 arrayRefFromStringRef(*PltContents
),
635 GotPlt
->getAddress(), Triple
);
636 // Build a map from GOT entry virtual address to PLT entry virtual address.
637 DenseMap
<uint64_t, uint64_t> GotToPlt
;
638 for (const auto &Entry
: PltEntries
)
639 GotToPlt
.insert(std::make_pair(Entry
.second
, Entry
.first
));
640 // Find the relocations in the dynamic relocation table that point to
641 // locations in the GOT for which we know the corresponding PLT entry.
642 std::vector
<std::pair
<Optional
<DataRefImpl
>, uint64_t>> Result
;
643 for (const auto &Relocation
: RelaPlt
->relocations()) {
644 if (Relocation
.getType() != JumpSlotReloc
)
646 auto PltEntryIter
= GotToPlt
.find(Relocation
.getOffset());
647 if (PltEntryIter
!= GotToPlt
.end()) {
648 symbol_iterator Sym
= Relocation
.getSymbol();
649 if (Sym
== symbol_end())
650 Result
.emplace_back(None
, PltEntryIter
->second
);
652 Result
.emplace_back(Sym
->getRawDataRefImpl(), PltEntryIter
->second
);
658 template <class ELFT
>
659 static Expected
<std::vector
<VersionEntry
>>
660 readDynsymVersionsImpl(const ELFFile
<ELFT
> &EF
,
661 ELFObjectFileBase::elf_symbol_iterator_range Symbols
) {
662 using Elf_Shdr
= typename
ELFT::Shdr
;
663 const Elf_Shdr
*VerSec
= nullptr;
664 const Elf_Shdr
*VerNeedSec
= nullptr;
665 const Elf_Shdr
*VerDefSec
= nullptr;
666 // The user should ensure sections() can't fail here.
667 for (const Elf_Shdr
&Sec
: cantFail(EF
.sections())) {
668 if (Sec
.sh_type
== ELF::SHT_GNU_versym
)
670 else if (Sec
.sh_type
== ELF::SHT_GNU_verdef
)
672 else if (Sec
.sh_type
== ELF::SHT_GNU_verneed
)
676 return std::vector
<VersionEntry
>();
678 Expected
<SmallVector
<Optional
<VersionEntry
>, 0>> MapOrErr
=
679 EF
.loadVersionMap(VerNeedSec
, VerDefSec
);
681 return MapOrErr
.takeError();
683 std::vector
<VersionEntry
> Ret
;
685 for (auto It
= Symbols
.begin(), E
= Symbols
.end(); It
!= E
; ++It
) {
687 Expected
<const typename
ELFT::Versym
*> VerEntryOrErr
=
688 EF
.template getEntry
<typename
ELFT::Versym
>(*VerSec
, I
);
690 return createError("unable to read an entry with index " + Twine(I
) +
691 " from " + describe(EF
, *VerSec
) + ": " +
692 toString(VerEntryOrErr
.takeError()));
694 Expected
<uint32_t> FlagsOrErr
= It
->getFlags();
696 return createError("unable to read flags for symbol with index " +
697 Twine(I
) + ": " + toString(FlagsOrErr
.takeError()));
700 Expected
<StringRef
> VerOrErr
= EF
.getSymbolVersionByIndex(
701 (*VerEntryOrErr
)->vs_index
, IsDefault
, *MapOrErr
,
702 (*FlagsOrErr
) & SymbolRef::SF_Undefined
);
704 return createError("unable to get a version for entry " + Twine(I
) +
705 " of " + describe(EF
, *VerSec
) + ": " +
706 toString(VerOrErr
.takeError()));
708 Ret
.push_back({(*VerOrErr
).str(), IsDefault
});
714 Expected
<std::vector
<VersionEntry
>>
715 ELFObjectFileBase::readDynsymVersions() const {
716 elf_symbol_iterator_range Symbols
= getDynamicSymbolIterators();
717 if (const auto *Obj
= dyn_cast
<ELF32LEObjectFile
>(this))
718 return readDynsymVersionsImpl(Obj
->getELFFile(), Symbols
);
719 if (const auto *Obj
= dyn_cast
<ELF32BEObjectFile
>(this))
720 return readDynsymVersionsImpl(Obj
->getELFFile(), Symbols
);
721 if (const auto *Obj
= dyn_cast
<ELF64LEObjectFile
>(this))
722 return readDynsymVersionsImpl(Obj
->getELFFile(), Symbols
);
723 return readDynsymVersionsImpl(cast
<ELF64BEObjectFile
>(this)->getELFFile(),