diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
| commit | b60736ec1405bb0a8dd40989f67ef4c93da068ab (patch) | |
| tree | 5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /llvm/lib/XRay | |
| parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) | |
Diffstat (limited to 'llvm/lib/XRay')
| -rw-r--r-- | llvm/lib/XRay/InstrumentationMap.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/llvm/lib/XRay/InstrumentationMap.cpp b/llvm/lib/XRay/InstrumentationMap.cpp index de0a9e60a511..e6534e5a7be7 100644 --- a/llvm/lib/XRay/InstrumentationMap.cpp +++ b/llvm/lib/XRay/InstrumentationMap.cpp @@ -95,42 +95,46 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile, if (ObjFile.getBinary()->isELF()) { uint32_t RelativeRelocation = [](object::ObjectFile *ObjFile) { if (const auto *ELFObj = dyn_cast<object::ELF32LEObjectFile>(ObjFile)) - return ELFObj->getELFFile()->getRelativeRelocationType(); + return ELFObj->getELFFile().getRelativeRelocationType(); else if (const auto *ELFObj = dyn_cast<object::ELF32BEObjectFile>(ObjFile)) - return ELFObj->getELFFile()->getRelativeRelocationType(); + return ELFObj->getELFFile().getRelativeRelocationType(); else if (const auto *ELFObj = dyn_cast<object::ELF64LEObjectFile>(ObjFile)) - return ELFObj->getELFFile()->getRelativeRelocationType(); + return ELFObj->getELFFile().getRelativeRelocationType(); else if (const auto *ELFObj = dyn_cast<object::ELF64BEObjectFile>(ObjFile)) - return ELFObj->getELFFile()->getRelativeRelocationType(); + return ELFObj->getELFFile().getRelativeRelocationType(); else return static_cast<uint32_t>(0); }(ObjFile.getBinary()); - bool (*SupportsRelocation)(uint64_t); + object::SupportsRelocation Supports; object::RelocationResolver Resolver; - std::tie(SupportsRelocation, Resolver) = + std::tie(Supports, Resolver) = object::getRelocationResolver(*ObjFile.getBinary()); for (const object::SectionRef &Section : Sections) { for (const object::RelocationRef &Reloc : Section.relocations()) { if (ObjFile.getBinary()->getArch() == Triple::arm) { - if (SupportsRelocation && SupportsRelocation(Reloc.getType())) { + if (Supports && Supports(Reloc.getType())) { Expected<uint64_t> ValueOrErr = Reloc.getSymbol()->getValue(); if (!ValueOrErr) return ValueOrErr.takeError(); - Relocs.insert({Reloc.getOffset(), Resolver(Reloc, *ValueOrErr, 0)}); + Relocs.insert( + {Reloc.getOffset(), + object::resolveRelocation(Resolver, Reloc, *ValueOrErr, 0)}); } - } else if (SupportsRelocation && SupportsRelocation(Reloc.getType())) { + } else if (Supports && Supports(Reloc.getType())) { auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend(); auto A = AddendOrErr ? *AddendOrErr : 0; Expected<uint64_t> ValueOrErr = Reloc.getSymbol()->getValue(); if (!ValueOrErr) // TODO: Test this error. return ValueOrErr.takeError(); - Relocs.insert({Reloc.getOffset(), Resolver(Reloc, *ValueOrErr, A)}); + Relocs.insert( + {Reloc.getOffset(), + object::resolveRelocation(Resolver, Reloc, *ValueOrErr, A)}); } else if (Reloc.getType() == RelativeRelocation) { if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend()) Relocs.insert({Reloc.getOffset(), *AddendOrErr}); |
