summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2017-01-24 08:32:59 +0000
committerpatrick <patrick@openbsd.org>2017-01-24 08:32:59 +0000
commit53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch)
tree7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp
parentIn preparation of compiling our kernels with -ffreestanding, explicitly map (diff)
downloadwireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz
wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp')
-rw-r--r--gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp b/gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp
index 7bd3d3f3f4d..7418c77bdec 100644
--- a/gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/gnu/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -112,8 +112,8 @@ struct CompileUnitIdentifiers {
};
static Expected<const char *>
-getIndexedString(uint32_t Form, DataExtractor InfoData, uint32_t &InfoOffset,
- StringRef StrOffsets, StringRef Str) {
+getIndexedString(dwarf::Form Form, DataExtractor InfoData,
+ uint32_t &InfoOffset, StringRef StrOffsets, StringRef Str) {
if (Form == dwarf::DW_FORM_string)
return InfoData.getCStr(&InfoOffset);
if (Form != dwarf::DW_FORM_GNU_str_index)
@@ -133,7 +133,14 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
StringRef Str) {
uint32_t Offset = 0;
DataExtractor InfoData(Info, true, 0);
- InfoData.getU32(&Offset); // Length
+ dwarf::DwarfFormat Format = dwarf::DwarfFormat::DWARF32;
+ uint64_t Length = InfoData.getU32(&Offset);
+ // If the length is 0xffffffff, then this indictes that this is a DWARF 64
+ // stream and the length is actually encoded into a 64 bit value that follows.
+ if (Length == 0xffffffffU) {
+ Format = dwarf::DwarfFormat::DWARF64;
+ Length = InfoData.getU64(&Offset);
+ }
uint16_t Version = InfoData.getU16(&Offset);
InfoData.getU32(&Offset); // Abbrev offset (should be zero)
uint8_t AddrSize = InfoData.getU8(&Offset);
@@ -142,16 +149,16 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
DataExtractor AbbrevData(Abbrev, true, 0);
uint32_t AbbrevOffset = getCUAbbrev(Abbrev, AbbrCode);
- uint64_t Tag = AbbrevData.getULEB128(&AbbrevOffset);
+ auto Tag = static_cast<dwarf::Tag>(AbbrevData.getULEB128(&AbbrevOffset));
if (Tag != dwarf::DW_TAG_compile_unit)
return make_error<DWPError>("top level DIE is not a compile unit");
// DW_CHILDREN
AbbrevData.getU8(&AbbrevOffset);
uint32_t Name;
- uint32_t Form;
+ dwarf::Form Form;
CompileUnitIdentifiers ID;
while ((Name = AbbrevData.getULEB128(&AbbrevOffset)) |
- (Form = AbbrevData.getULEB128(&AbbrevOffset)) &&
+ (Form = static_cast<dwarf::Form>(AbbrevData.getULEB128(&AbbrevOffset))) &&
(Name != 0 || Form != 0)) {
switch (Name) {
case dwarf::DW_AT_name: {
@@ -174,7 +181,8 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
ID.Signature = InfoData.getU64(&Offset);
break;
default:
- DWARFFormValue::skipValue(Form, InfoData, &Offset, Version, AddrSize);
+ DWARFFormValue::skipValue(Form, InfoData, &Offset, Version, AddrSize,
+ Format);
}
}
return ID;
@@ -364,7 +372,7 @@ static Error handleCompressedSection(
std::deque<SmallString<32>> &UncompressedSections, StringRef &Name,
StringRef &Contents) {
if (!Name.startswith("zdebug_"))
- return Error();
+ return Error::success();
UncompressedSections.emplace_back();
uint64_t OriginalSize;
if (!zlib::isAvailable())
@@ -377,7 +385,7 @@ static Error handleCompressedSection(
.str());
Name = Name.substr(1);
Contents = UncompressedSections.back();
- return Error();
+ return Error::success();
}
static Error handleSection(
@@ -392,10 +400,10 @@ static Error handleSection(
StringRef &AbbrevSection, StringRef &CurCUIndexSection,
StringRef &CurTUIndexSection) {
if (Section.isBSS())
- return Error();
+ return Error::success();
if (Section.isVirtual())
- return Error();
+ return Error::success();
StringRef Name;
if (std::error_code Err = Section.getName(Name))
@@ -412,7 +420,7 @@ static Error handleSection(
auto SectionPair = KnownSections.find(Name);
if (SectionPair == KnownSections.end())
- return Error();
+ return Error::success();
if (DWARFSectionKind Kind = SectionPair->second.second) {
auto Index = Kind - DW_SECT_INFO;
@@ -449,7 +457,7 @@ static Error handleSection(
Out.SwitchSection(OutSection);
Out.EmitBytes(Contents);
}
- return Error();
+ return Error::success();
}
static Error
@@ -600,7 +608,7 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
writeIndex(Out, MCOFI.getDwarfCUIndexSection(), ContributionOffsets,
IndexEntries);
- return Error();
+ return Error::success();
}
static int error(const Twine &Error, const Twine &Context) {
@@ -643,7 +651,8 @@ int main(int argc, char **argv) {
MCContext MC(MAI.get(), MRI.get(), &MOFI);
MOFI.InitMCObjectFileInfo(TheTriple, /*PIC*/ false, CodeModel::Default, MC);
- auto MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, "");
+ MCTargetOptions Options;
+ auto MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, "", Options);
if (!MAB)
return error("no asm backend for target " + TripleName, Context);