bool UseSymbolTable = true;
bool Demangle = true;
bool RelativeAddresses = false;
+ bool UntagAddresses = false;
std::string DefaultArch;
std::vector<std::string> DsymHints;
std::string FallbackDebugPath;
ErrorOr<std::unique_ptr<SymbolizableObjectFile>>
SymbolizableObjectFile::create(const object::ObjectFile *Obj,
- std::unique_ptr<DIContext> DICtx) {
+ std::unique_ptr<DIContext> DICtx,
+ bool UntagAddresses) {
assert(DICtx);
std::unique_ptr<SymbolizableObjectFile> res(
- new SymbolizableObjectFile(Obj, std::move(DICtx)));
+ new SymbolizableObjectFile(Obj, std::move(DICtx), UntagAddresses));
std::unique_ptr<DataExtractor> OpdExtractor;
uint64_t OpdAddress = 0;
// Find the .opd (function descriptor) section if any, for big-endian
}
SymbolizableObjectFile::SymbolizableObjectFile(const ObjectFile *Obj,
- std::unique_ptr<DIContext> DICtx)
- : Module(Obj), DebugInfoContext(std::move(DICtx)) {}
+ std::unique_ptr<DIContext> DICtx,
+ bool UntagAddresses)
+ : Module(Obj), DebugInfoContext(std::move(DICtx)),
+ UntagAddresses(UntagAddresses) {}
namespace {
if (!SymbolAddressOrErr)
return errorToErrorCode(SymbolAddressOrErr.takeError());
uint64_t SymbolAddress = *SymbolAddressOrErr;
+ if (UntagAddresses) {
+ // For kernel addresses, bits 56-63 need to be set, so we sign extend bit 55
+ // into bits 56-63 instead of masking them out.
+ SymbolAddress = (int64_t(SymbolAddress) << 8) >> 8;
+ }
if (OpdExtractor) {
// For big-endian PowerPC64 ELF, symbols in the .opd section refer to
// function descriptors. The first word of the descriptor is a pointer to
class SymbolizableObjectFile : public SymbolizableModule {
public:
static ErrorOr<std::unique_ptr<SymbolizableObjectFile>>
- create(const object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx);
+ create(const object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx,
+ bool UntagAddresses);
DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,
FunctionNameKind FNKind,
const object::ObjectFile *Module;
std::unique_ptr<DIContext> DebugInfoContext;
+ bool UntagAddresses;
struct SymbolDesc {
uint64_t Addr;
std::vector<std::pair<SymbolDesc, StringRef>> Objects;
SymbolizableObjectFile(const object::ObjectFile *Obj,
- std::unique_ptr<DIContext> DICtx);
+ std::unique_ptr<DIContext> DICtx,
+ bool UntagAddresses);
};
} // end namespace symbolize
LLVMSymbolizer::createModuleInfo(const ObjectFile *Obj,
std::unique_ptr<DIContext> Context,
StringRef ModuleName) {
- auto InfoOrErr =
- SymbolizableObjectFile::create(Obj, std::move(Context));
+ auto InfoOrErr = SymbolizableObjectFile::create(Obj, std::move(Context),
+ Opts.UntagAddresses);
std::unique_ptr<SymbolizableModule> SymMod;
if (InfoOrErr)
SymMod = std::move(*InfoOrErr);
--- /dev/null
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo DATA %t.o 0 | llvm-symbolizer | FileCheck --check-prefix=UNTAG %s
+# RUN: echo DATA %t.o 0 | llvm-symbolizer -untag-addresses=0 | FileCheck --check-prefix=NOUNTAG %s
+# RUN: echo DATA %t.o 0 | llvm-addr2line | FileCheck --check-prefix=NOUNTAG %s
+
+# UNTAG: foo
+# UNTAG: 0 4
+# NOUNTAG: ??
+# NOUNTAG: 0 0
+
+.data
+.globl foo
+.type foo, @object
+.size foo, 4
+foo = . + 0x1100000000000000
+.4byte 1
cl::desc("Interpret addresses as relative addresses"),
cl::ReallyHidden);
+static cl::opt<bool> ClUntagAddresses(
+ "untag-addresses", cl::init(true),
+ cl::desc("Remove memory tags from addresses before symbolization"));
+
static cl::opt<bool>
ClPrintInlining("inlining", cl::init(true),
cl::desc("Print all inlined frames for a given address"));
ClDemangle.setInitialValue(false);
ClPrintFunctions.setInitialValue(FunctionNameKind::None);
ClPrintInlining.setInitialValue(false);
+ ClUntagAddresses.setInitialValue(false);
ClOutputStyle.setInitialValue(DIPrinter::OutputStyle::GNU);
}
Opts.UseSymbolTable = ClUseSymbolTable;
Opts.Demangle = ClDemangle;
Opts.RelativeAddresses = ClUseRelativeAddress;
+ Opts.UntagAddresses = ClUntagAddresses;
Opts.DefaultArch = ClDefaultArch;
Opts.FallbackDebugPath = ClFallbackDebugPath;
Opts.DWPName = ClDwpName;