You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
Analysis
AsmParser
BinaryFormat
Bitcode
CodeGen
DebugInfo
CodeView
DWARF
MSF
PDB
DIA
Native
DbiModuleDescriptor.cpp
DbiModuleDescriptorBuilder.cpp
DbiModuleList.cpp
DbiStream.cpp
DbiStreamBuilder.cpp
EnumTables.cpp
GSIStreamBuilder.cpp
GlobalsStream.cpp
Hash.cpp
HashTable.cpp
InfoStream.cpp
InfoStreamBuilder.cpp
ModuleDebugStream.cpp
NamedStreamMap.cpp
NativeBuiltinSymbol.cpp
NativeCompilandSymbol.cpp
NativeEnumModules.cpp
NativeEnumSymbol.cpp
NativeEnumTypes.cpp
NativeExeSymbol.cpp
NativeRawSymbol.cpp
NativeSession.cpp
PDBFile.cpp
PDBFileBuilder.cpp
PDBStringTable.cpp
PDBStringTableBuilder.cpp
PublicsStream.cpp
RawError.cpp
SymbolStream.cpp
TpiHashing.cpp
TpiStream.cpp
TpiStreamBuilder.cpp
CMakeLists.txt
GenericError.cpp
IPDBSourceFile.cpp
LLVMBuild.txt
PDB.cpp
PDBContext.cpp
PDBExtras.cpp
PDBInterfaceAnchors.cpp
PDBSymDumper.cpp
PDBSymbol.cpp
PDBSymbolAnnotation.cpp
PDBSymbolBlock.cpp
PDBSymbolCompiland.cpp
PDBSymbolCompilandDetails.cpp
PDBSymbolCompilandEnv.cpp
PDBSymbolCustom.cpp
PDBSymbolData.cpp
PDBSymbolExe.cpp
PDBSymbolFunc.cpp
PDBSymbolFuncDebugEnd.cpp
PDBSymbolFuncDebugStart.cpp
PDBSymbolLabel.cpp
PDBSymbolPublicSymbol.cpp
PDBSymbolThunk.cpp
PDBSymbolTypeArray.cpp
PDBSymbolTypeBaseClass.cpp
PDBSymbolTypeBuiltin.cpp
PDBSymbolTypeCustom.cpp
PDBSymbolTypeDimension.cpp
PDBSymbolTypeEnum.cpp
PDBSymbolTypeFriend.cpp
PDBSymbolTypeFunctionArg.cpp
PDBSymbolTypeFunctionSig.cpp
PDBSymbolTypeManaged.cpp
PDBSymbolTypePointer.cpp
PDBSymbolTypeTypedef.cpp
PDBSymbolTypeUDT.cpp
PDBSymbolTypeVTable.cpp
PDBSymbolTypeVTableShape.cpp
PDBSymbolUnknown.cpp
PDBSymbolUsingNamespace.cpp
UDTLayout.cpp
Symbolize
CMakeLists.txt
LLVMBuild.txt
Demangle
ExecutionEngine
FuzzMutate
Fuzzer
IR
IRReader
LTO
LineEditor
Linker
MC
Object
ObjectYAML
Option
Passes
ProfileData
Support
TableGen
Target
Testing
ToolDrivers
Transforms
WindowsManifest
XRay
CMakeLists.txt
LLVMBuild.txt
projects
resources
runtimes
scripts
test
tools
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
125 lines
4.5 KiB
C++
125 lines
4.5 KiB
C++
//===- GlobalsStream.cpp - PDB Index of Symbols by Name ---------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The on-disk structores used in this file are based on the reference
|
|
// implementation which is available at
|
|
// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
|
|
//
|
|
// When you are reading the reference source code, you'd find the
|
|
// information below useful.
|
|
//
|
|
// - ppdb1->m_fMinimalDbgInfo seems to be always true.
|
|
// - SMALLBUCKETS macro is defined.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
|
|
#include "llvm/DebugInfo/PDB/Native/RawError.h"
|
|
#include "llvm/Support/BinaryStreamReader.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include <algorithm>
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::msf;
|
|
using namespace llvm::pdb;
|
|
|
|
GlobalsStream::GlobalsStream(std::unique_ptr<MappedBlockStream> Stream)
|
|
: Stream(std::move(Stream)) {}
|
|
|
|
GlobalsStream::~GlobalsStream() = default;
|
|
|
|
Error GlobalsStream::reload() {
|
|
BinaryStreamReader Reader(*Stream);
|
|
if (auto E = GlobalsTable.read(Reader))
|
|
return E;
|
|
return Error::success();
|
|
}
|
|
|
|
static Error checkHashHdrVersion(const GSIHashHeader *HashHdr) {
|
|
if (HashHdr->VerHdr != GSIHashHeader::HdrVersion)
|
|
return make_error<RawError>(
|
|
raw_error_code::feature_unsupported,
|
|
"Encountered unsupported globals stream version.");
|
|
|
|
return Error::success();
|
|
}
|
|
|
|
static Error readGSIHashHeader(const GSIHashHeader *&HashHdr,
|
|
BinaryStreamReader &Reader) {
|
|
if (Reader.readObject(HashHdr))
|
|
return make_error<RawError>(raw_error_code::corrupt_file,
|
|
"Stream does not contain a GSIHashHeader.");
|
|
|
|
if (HashHdr->VerSignature != GSIHashHeader::HdrSignature)
|
|
return make_error<RawError>(
|
|
raw_error_code::feature_unsupported,
|
|
"GSIHashHeader signature (0xffffffff) not found.");
|
|
|
|
return Error::success();
|
|
}
|
|
|
|
static Error readGSIHashRecords(FixedStreamArray<PSHashRecord> &HashRecords,
|
|
const GSIHashHeader *HashHdr,
|
|
BinaryStreamReader &Reader) {
|
|
if (auto EC = checkHashHdrVersion(HashHdr))
|
|
return EC;
|
|
|
|
// HashHdr->HrSize specifies the number of bytes of PSHashRecords we have.
|
|
// Verify that we can read them all.
|
|
if (HashHdr->HrSize % sizeof(PSHashRecord))
|
|
return make_error<RawError>(raw_error_code::corrupt_file,
|
|
"Invalid HR array size.");
|
|
uint32_t NumHashRecords = HashHdr->HrSize / sizeof(PSHashRecord);
|
|
if (auto EC = Reader.readArray(HashRecords, NumHashRecords))
|
|
return joinErrors(std::move(EC),
|
|
make_error<RawError>(raw_error_code::corrupt_file,
|
|
"Error reading hash records."));
|
|
|
|
return Error::success();
|
|
}
|
|
|
|
static Error
|
|
readGSIHashBuckets(FixedStreamArray<support::ulittle32_t> &HashBuckets,
|
|
ArrayRef<uint8_t> &HashBitmap, const GSIHashHeader *HashHdr,
|
|
BinaryStreamReader &Reader) {
|
|
if (auto EC = checkHashHdrVersion(HashHdr))
|
|
return EC;
|
|
|
|
// Before the actual hash buckets, there is a bitmap of length determined by
|
|
// IPHR_HASH.
|
|
size_t BitmapSizeInBits = alignTo(IPHR_HASH + 1, 32);
|
|
uint32_t NumBitmapEntries = BitmapSizeInBits / 8;
|
|
if (auto EC = Reader.readBytes(HashBitmap, NumBitmapEntries))
|
|
return joinErrors(std::move(EC),
|
|
make_error<RawError>(raw_error_code::corrupt_file,
|
|
"Could not read a bitmap."));
|
|
uint32_t NumBuckets = 0;
|
|
for (uint8_t B : HashBitmap)
|
|
NumBuckets += countPopulation(B);
|
|
|
|
// Hash buckets follow.
|
|
if (auto EC = Reader.readArray(HashBuckets, NumBuckets))
|
|
return joinErrors(std::move(EC),
|
|
make_error<RawError>(raw_error_code::corrupt_file,
|
|
"Hash buckets corrupted."));
|
|
|
|
return Error::success();
|
|
}
|
|
|
|
Error GSIHashTable::read(BinaryStreamReader &Reader) {
|
|
if (auto EC = readGSIHashHeader(HashHdr, Reader))
|
|
return EC;
|
|
if (auto EC = readGSIHashRecords(HashRecords, HashHdr, Reader))
|
|
return EC;
|
|
if (HashHdr->HrSize > 0)
|
|
if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap, HashHdr, Reader))
|
|
return EC;
|
|
return Error::success();
|
|
}
|