summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-12-19 22:22:12 +0000
committerChris Bieneman <beanz@apple.com>2016-12-19 22:22:12 +0000
commitd9430944f4bb423a15785a0cea2bc6a76c50ecdb (patch)
tree4cd067bf8dfee0c956152c0f0f7202ada35a4fdb /llvm/tools
parent9b415be1bf1b86cce12689fbc684306a24956824 (diff)
downloadbcm5719-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')
-rw-r--r--llvm/tools/obj2yaml/dwarf2yaml.cpp33
-rw-r--r--llvm/tools/yaml2obj/yaml2dwarf.cpp14
-rw-r--r--llvm/tools/yaml2obj/yaml2macho.cpp4
-rw-r--r--llvm/tools/yaml2obj/yaml2obj.h3
4 files changed, 54 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;
}
diff --git a/llvm/tools/yaml2obj/yaml2dwarf.cpp b/llvm/tools/yaml2obj/yaml2dwarf.cpp
index fcc58330ee9..6096f4c5f19 100644
--- a/llvm/tools/yaml2obj/yaml2dwarf.cpp
+++ b/llvm/tools/yaml2obj/yaml2dwarf.cpp
@@ -66,3 +66,17 @@ void yaml2debug_aranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
ZeroFillBytes(OS, Range.AddrSize * 2);
}
}
+
+void yaml2pubsection(raw_ostream &OS, const DWARFYAML::PubSection &Sect) {
+ OS.write(reinterpret_cast<const char *>(&Sect.Length), 4);
+ OS.write(reinterpret_cast<const char *>(&Sect.Version), 2);
+ OS.write(reinterpret_cast<const char *>(&Sect.UnitOffset), 4);
+ OS.write(reinterpret_cast<const char *>(&Sect.UnitSize), 4);
+ for (auto Entry : Sect.Entries) {
+ OS.write(reinterpret_cast<const char *>(&Entry.DieOffset), 4);
+ if (Sect.IsGNUStyle)
+ OS.write(reinterpret_cast<const char *>(&Entry.Descriptor), 4);
+ OS.write(Entry.Name.data(), Entry.Name.size());
+ OS.write('\0');
+ }
+}
diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp
index 9d70f5888ac..3fdf3cf43bd 100644
--- a/llvm/tools/yaml2obj/yaml2macho.cpp
+++ b/llvm/tools/yaml2obj/yaml2macho.cpp
@@ -394,6 +394,10 @@ Error MachOWriter::writeDWARFData(raw_ostream &OS,
yaml2debug_abbrev(OS, Obj.DWARF);
} else if (0 == strncmp(&Section.sectname[0], "__debug_aranges", 16)) {
yaml2debug_aranges(OS, Obj.DWARF);
+ } else if (0 == strncmp(&Section.sectname[0], "__debug_pubnames", 16)) {
+ yaml2pubsection(OS, Obj.DWARF.PubNames);
+ } else if (0 == strncmp(&Section.sectname[0], "__debug_pubtypes", 16)) {
+ yaml2pubsection(OS, Obj.DWARF.PubTypes);
}
}
return Error::success();
diff --git a/llvm/tools/yaml2obj/yaml2obj.h b/llvm/tools/yaml2obj/yaml2obj.h
index cd481c0fd4e..f36166abfce 100644
--- a/llvm/tools/yaml2obj/yaml2obj.h
+++ b/llvm/tools/yaml2obj/yaml2obj.h
@@ -25,6 +25,7 @@ struct Object;
namespace DWARFYAML {
struct Data;
+struct PubSection;
}
namespace yaml {
@@ -43,5 +44,7 @@ void yaml2debug_str(llvm::raw_ostream &OS,
const llvm::DWARFYAML::Data &DI);
void yaml2debug_aranges(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
+void yaml2pubsection(llvm::raw_ostream &OS,
+ const llvm::DWARFYAML::PubSection &Sect);
#endif
OpenPOWER on IntegriCloud