2017-06-29 08:05:44 +08:00
|
|
|
//===- DebugCrossExSubsection.cpp -----------------------------------------===//
|
2017-06-06 05:40:33 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
|
|
|
|
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
|
2017-06-29 08:05:44 +08:00
|
|
|
#include "llvm/Support/BinaryStreamWriter.h"
|
|
|
|
#include "llvm/Support/Error.h"
|
|
|
|
#include <cstdint>
|
2017-06-06 05:40:33 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::codeview;
|
|
|
|
|
|
|
|
Error DebugCrossModuleExportsSubsectionRef::initialize(
|
|
|
|
BinaryStreamReader Reader) {
|
|
|
|
if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0)
|
|
|
|
return make_error<CodeViewError>(
|
|
|
|
cv_error_code::corrupt_record,
|
|
|
|
"Cross Scope Exports section is an invalid size!");
|
|
|
|
|
|
|
|
uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport);
|
|
|
|
return Reader.readArray(References, Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
Error DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream) {
|
|
|
|
BinaryStreamReader Reader(Stream);
|
|
|
|
return initialize(Reader);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local,
|
|
|
|
uint32_t Global) {
|
|
|
|
Mappings[Local] = Global;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const {
|
|
|
|
return Mappings.size() * sizeof(CrossModuleExport);
|
|
|
|
}
|
|
|
|
|
|
|
|
Error DebugCrossModuleExportsSubsection::commit(
|
|
|
|
BinaryStreamWriter &Writer) const {
|
|
|
|
for (const auto &M : Mappings) {
|
2017-06-06 06:12:23 +08:00
|
|
|
if (auto EC = Writer.writeInteger(M.first))
|
|
|
|
return EC;
|
|
|
|
if (auto EC = Writer.writeInteger(M.second))
|
2017-06-06 05:40:33 +08:00
|
|
|
return EC;
|
|
|
|
}
|
|
|
|
return Error::success();
|
|
|
|
}
|