From d9430944f4bb423a15785a0cea2bc6a76c50ecdb Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Mon, 19 Dec 2016 22:22:12 +0000 Subject: [ObjectYAML] Support for DWARF Pub Sections This patch adds support for YAML<->DWARF round tripping for pub* section data. The patch supports both GNU and non-GNU style entries. llvm-svn: 290139 --- llvm/tools/obj2yaml/dwarf2yaml.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'llvm/tools/obj2yaml/dwarf2yaml.cpp') diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp index ca55702be96..0fd646e23b9 100644 --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -67,11 +67,44 @@ void dumpDebugARanges(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { } } +void dumpPubSection(DWARFContextInMemory &DCtx, DWARFYAML::PubSection &Y, + StringRef Section) { + DataExtractor PubSectionData(Section, DCtx.isLittleEndian(), 0); + uint32_t Offset = 0; + Y.Length = PubSectionData.getU32(&Offset); + Y.Version = PubSectionData.getU16(&Offset); + Y.UnitOffset = PubSectionData.getU32(&Offset); + Y.UnitSize = PubSectionData.getU32(&Offset); + while (Offset < Y.Length) { + DWARFYAML::PubEntry NewEntry; + NewEntry.DieOffset = PubSectionData.getU32(&Offset); + if (Y.IsGNUStyle) + NewEntry.Descriptor = PubSectionData.getU8(&Offset); + NewEntry.Name = PubSectionData.getCStr(&Offset); + Y.Entries.push_back(NewEntry); + } +} + +void dumpDebugPubSections(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { + Y.PubNames.IsGNUStyle = false; + dumpPubSection(DCtx, Y.PubNames, DCtx.getPubNamesSection()); + + Y.PubTypes.IsGNUStyle = false; + dumpPubSection(DCtx, Y.PubTypes, DCtx.getPubTypesSection()); + + Y.GNUPubNames.IsGNUStyle = true; + dumpPubSection(DCtx, Y.GNUPubNames, DCtx.getGnuPubNamesSection()); + + Y.GNUPubTypes.IsGNUStyle = true; + dumpPubSection(DCtx, Y.GNUPubTypes, DCtx.getGnuPubTypesSection()); +} + std::error_code dwarf2yaml(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { dumpDebugAbbrev(DCtx, Y); dumpDebugStrings(DCtx, Y); dumpDebugARanges(DCtx, Y); + dumpDebugPubSections(DCtx, Y); return obj2yaml_error::success; } -- cgit v1.2.3