[PATCH] D69967: [llvm-xray] Add AArch64 to llvm-xray extract
Aditya Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 06:44:02 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d321434a202: [llvm-xray] Add AArch64 to llvm-xray extract (authored by hiraditya).
Changed prior to commit:
https://reviews.llvm.org/D69967?vs=228308&id=228435#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69967/new/
https://reviews.llvm.org/D69967
Files:
llvm/lib/XRay/InstrumentationMap.cpp
Index: llvm/lib/XRay/InstrumentationMap.cpp
===================================================================
--- llvm/lib/XRay/InstrumentationMap.cpp
+++ llvm/lib/XRay/InstrumentationMap.cpp
@@ -20,6 +20,7 @@
#include "llvm/Object/Binary.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/RelocationResolver.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
@@ -59,7 +60,8 @@
// Find the section named "xray_instr_map".
if ((!ObjFile.getBinary()->isELF() && !ObjFile.getBinary()->isMachO()) ||
!(ObjFile.getBinary()->getArch() == Triple::x86_64 ||
- ObjFile.getBinary()->getArch() == Triple::ppc64le))
+ ObjFile.getBinary()->getArch() == Triple::ppc64le ||
+ ObjFile.getBinary()->getArch() == Triple::aarch64))
return make_error<StringError>(
"File format not supported (only does ELF and Mach-O little endian 64-bit).",
std::make_error_code(std::errc::not_supported));
@@ -99,12 +101,22 @@
return static_cast<uint32_t>(0);
}(ObjFile.getBinary());
+ bool (*SupportsRelocation)(uint64_t);
+ object::RelocationResolver Resolver;
+ std::tie(SupportsRelocation, Resolver) =
+ object::getRelocationResolver(*ObjFile.getBinary());
+
for (const object::SectionRef &Section : Sections) {
for (const object::RelocationRef &Reloc : Section.relocations()) {
- if (Reloc.getType() != RelativeRelocation)
- continue;
- if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend())
- Relocs.insert({Reloc.getOffset(), *AddendOrErr});
+ if (SupportsRelocation && SupportsRelocation(Reloc.getType())) {
+ auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend();
+ auto A = AddendOrErr ? *AddendOrErr : 0;
+ uint64_t resolved = Resolver(Reloc, Reloc.getSymbol()->getValue(), A);
+ Relocs.insert({Reloc.getOffset(), resolved});
+ } else if (Reloc.getType() == RelativeRelocation) {
+ if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend())
+ Relocs.insert({Reloc.getOffset(), *AddendOrErr});
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69967.228435.patch
Type: text/x-patch
Size: 2255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191108/32f20f52/attachment.bin>
More information about the llvm-commits
mailing list