diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-22 20:31:01 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-22 20:31:01 +0000 | 
| commit | 8bcb0991864975618c09697b1aca10683346d9f0 (patch) | |
| tree | 0afab28faa50e5f27698f8dd6c1921fff8d25e39 /contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp | |
| parent | b14637d118e110006a149a79b649c5695e7f419a (diff) | |
| parent | 1d5ae1026e831016fc29fd927877c86af904481f (diff) | |
Notes
Diffstat (limited to 'contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp | 32 | 
1 files changed, 20 insertions, 12 deletions
diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp index 2765bf44d504..b4d49d9ff958 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp @@ -43,20 +43,22 @@ getDILineInfoSpecifier(FunctionNameKind FNKind) {  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    // PowerPC64 ELF.    if (Obj->getArch() == Triple::ppc64) {      for (section_iterator Section : Obj->sections()) { -      StringRef Name; -      if (auto EC = Section->getName(Name)) -        return EC; -      if (Name == ".opd") { +      Expected<StringRef> NameOrErr = Section->getName(); +      if (!NameOrErr) +        return errorToErrorCode(NameOrErr.takeError()); + +      if (*NameOrErr == ".opd") {          Expected<StringRef> E = Section->getContents();          if (!E)            return errorToErrorCode(E.takeError()); @@ -103,8 +105,10 @@ SymbolizableObjectFile::create(const object::ObjectFile *Obj,  }  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 { @@ -172,6 +176,12 @@ std::error_code SymbolizableObjectFile::addSymbol(const SymbolRef &Symbol,    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 &= (1ull << 56) - 1; +    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 @@ -179,10 +189,8 @@ std::error_code SymbolizableObjectFile::addSymbol(const SymbolRef &Symbol,      // For the purposes of symbolization, pretend the symbol's address is that      // of the function's code, not the descriptor.      uint64_t OpdOffset = SymbolAddress - OpdAddress; -    uint32_t OpdOffset32 = OpdOffset; -    if (OpdOffset == OpdOffset32 && -        OpdExtractor->isValidOffsetForAddress(OpdOffset32)) -      SymbolAddress = OpdExtractor->getAddress(&OpdOffset32); +    if (OpdExtractor->isValidOffsetForAddress(OpdOffset)) +      SymbolAddress = OpdExtractor->getAddress(&OpdOffset);    }    Expected<StringRef> SymbolNameOrErr = Symbol.getName();    if (!SymbolNameOrErr)  | 
