diff options
author | Chris Bieneman <beanz@apple.com> | 2016-12-19 22:22:12 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-12-19 22:22:12 +0000 |
commit | d9430944f4bb423a15785a0cea2bc6a76c50ecdb (patch) | |
tree | 4cd067bf8dfee0c956152c0f0f7202ada35a4fdb /llvm/tools/obj2yaml/dwarf2yaml.cpp | |
parent | 9b415be1bf1b86cce12689fbc684306a24956824 (diff) | |
download | bcm5719-llvm-d9430944f4bb423a15785a0cea2bc6a76c50ecdb.tar.gz bcm5719-llvm-d9430944f4bb423a15785a0cea2bc6a76c50ecdb.zip |
[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
Diffstat (limited to 'llvm/tools/obj2yaml/dwarf2yaml.cpp')
-rw-r--r-- | llvm/tools/obj2yaml/dwarf2yaml.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
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; } |