<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 19, 2016 at 2:32 PM Chris Bieneman via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: cbieneman<br class="gmail_msg">
Date: Mon Dec 19 16:22:12 2016<br class="gmail_msg">
New Revision: 290139<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=290139&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=290139&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
[ObjectYAML] Support for DWARF Pub Sections<br class="gmail_msg">
<br class="gmail_msg">
This patch adds support for YAML<->DWARF round tripping for pub* section data. The patch supports both GNU and non-GNU style entries.<br class="gmail_msg">
<br class="gmail_msg">
Added:<br class="gmail_msg">
llvm/trunk/test/ObjectYAML/MachO/DWARF-pubsections.yaml<br class="gmail_msg">
Modified:<br class="gmail_msg">
llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h<br class="gmail_msg">
llvm/trunk/lib/ObjectYAML/DWARFYAML.cpp<br class="gmail_msg">
llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp<br class="gmail_msg">
llvm/trunk/tools/yaml2obj/yaml2dwarf.cpp<br class="gmail_msg">
llvm/trunk/tools/yaml2obj/yaml2macho.cpp<br class="gmail_msg">
llvm/trunk/tools/yaml2obj/yaml2obj.h<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h?rev=290139&r1=290138&r2=290139&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h?rev=290139&r1=290138&r2=290139&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h (original)<br class="gmail_msg">
+++ llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -49,10 +49,32 @@ struct ARange {<br class="gmail_msg">
std::vector<ARangeDescriptor> Descriptors;<br class="gmail_msg">
};<br class="gmail_msg">
<br class="gmail_msg">
+struct PubEntry {<br class="gmail_msg">
+ llvm::yaml::Hex32 DieOffset;<br class="gmail_msg">
+ llvm::yaml::Hex8 Descriptor;<br class="gmail_msg">
+ StringRef Name;<br class="gmail_msg">
+};<br class="gmail_msg">
+<br class="gmail_msg">
+struct PubSection {<br class="gmail_msg">
+ PubSection() : IsGNUStyle(false) {}<br class="gmail_msg">
+<br class="gmail_msg">
+ uint32_t Length;<br class="gmail_msg">
+ uint16_t Version;<br class="gmail_msg">
+ uint32_t UnitOffset;<br class="gmail_msg">
+ uint32_t UnitSize;<br class="gmail_msg">
+ bool IsGNUStyle;<br class="gmail_msg">
+ std::vector<PubEntry> Entries;<br class="gmail_msg">
+};<br class="gmail_msg">
+<br class="gmail_msg">
struct Data {<br class="gmail_msg">
std::vector<Abbrev> AbbrevDecls;<br class="gmail_msg">
std::vector<StringRef> DebugStrings;<br class="gmail_msg">
std::vector<ARange> ARanges;<br class="gmail_msg">
+ PubSection PubNames;<br class="gmail_msg">
+ PubSection PubTypes;<br class="gmail_msg">
+<br class="gmail_msg">
+ PubSection GNUPubNames;<br class="gmail_msg">
+ PubSection GNUPubTypes;<br class="gmail_msg">
<br class="gmail_msg">
bool isEmpty() const;<br class="gmail_msg">
};<br class="gmail_msg">
@@ -65,6 +87,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARF<br class="gmail_msg">
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)<br class="gmail_msg">
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)<br class="gmail_msg">
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)<br class="gmail_msg">
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::PubEntry)<br class="gmail_msg">
<br class="gmail_msg">
namespace llvm {<br class="gmail_msg">
namespace yaml {<br class="gmail_msg">
@@ -89,6 +112,14 @@ template <> struct MappingTraits<DWARFYA<br class="gmail_msg">
static void mapping(IO &IO, DWARFYAML::ARange &Range);<br class="gmail_msg">
};<br class="gmail_msg">
<br class="gmail_msg">
+template <> struct MappingTraits<DWARFYAML::PubEntry> {<br class="gmail_msg">
+ static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);<br class="gmail_msg">
+};<br class="gmail_msg">
+<br class="gmail_msg">
+template <> struct MappingTraits<DWARFYAML::PubSection> {<br class="gmail_msg">
+ static void mapping(IO &IO, DWARFYAML::PubSection &Section);<br class="gmail_msg">
+};<br class="gmail_msg">
+<br class="gmail_msg">
#define HANDLE_DW_TAG(unused, name) \<br class="gmail_msg">
io.enumCase(value, "DW_TAG_" #name, dwarf::DW_TAG_##name);<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/ObjectYAML/DWARFYAML.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/DWARFYAML.cpp?rev=290139&r1=290138&r2=290139&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/DWARFYAML.cpp?rev=290139&r1=290138&r2=290139&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/ObjectYAML/DWARFYAML.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/ObjectYAML/DWARFYAML.cpp Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -28,6 +28,14 @@ void MappingTraits<DWARFYAML::Data>::map<br class="gmail_msg">
IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls);<br class="gmail_msg">
if(!DWARF.ARanges.empty() || !IO.outputting())<br class="gmail_msg">
IO.mapOptional("debug_aranges", DWARF.ARanges);<br class="gmail_msg">
+ if(!DWARF.PubNames.Entries.empty() || !IO.outputting())<br class="gmail_msg">
+ IO.mapOptional("debug_pubnames", DWARF.PubNames);<br class="gmail_msg">
+ if(!DWARF.PubTypes.Entries.empty() || !IO.outputting())<br class="gmail_msg">
+ IO.mapOptional("debug_pubtypes", DWARF.PubTypes);<br class="gmail_msg">
+ if(!DWARF.GNUPubNames.Entries.empty() || !IO.outputting())<br class="gmail_msg">
+ IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);<br class="gmail_msg">
+ if(!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting())<br class="gmail_msg">
+ IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
void MappingTraits<DWARFYAML::Abbrev>::mapping(<br class="gmail_msg">
@@ -60,6 +68,28 @@ void MappingTraits<DWARFYAML::ARange>::m<br class="gmail_msg">
IO.mapRequired("Descriptors", Range.Descriptors);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO,<br class="gmail_msg">
+ DWARFYAML::PubEntry &Entry) {<br class="gmail_msg">
+ IO.mapRequired("DieOffset", Entry.DieOffset);<br class="gmail_msg">
+ if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)<br class="gmail_msg">
+ IO.mapRequired("Descriptor", Entry.Descriptor);<br class="gmail_msg">
+ IO.mapRequired("Name", Entry.Name);<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+void MappingTraits<DWARFYAML::PubSection>::mapping(<br class="gmail_msg">
+ IO &IO, DWARFYAML::PubSection &Section) {<br class="gmail_msg">
+ auto OldContext = IO.getContext();<br class="gmail_msg">
+ IO.setContext(&Section);<br class="gmail_msg">
+<br class="gmail_msg">
+ IO.mapRequired("Length", Section.Length);<br class="gmail_msg">
+ IO.mapRequired("Version", Section.Version);<br class="gmail_msg">
+ IO.mapRequired("UnitOffset", Section.UnitOffset);<br class="gmail_msg">
+ IO.mapRequired("UnitSize", Section.UnitSize);<br class="gmail_msg">
+ IO.mapRequired("Entries", Section.Entries);<br class="gmail_msg">
+<br class="gmail_msg">
+ IO.setContext(OldContext);<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
} // namespace llvm::yaml<br class="gmail_msg">
<br class="gmail_msg">
} // namespace llvm<br class="gmail_msg">
<br class="gmail_msg">
Added: llvm/trunk/test/ObjectYAML/MachO/DWARF-pubsections.yaml<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/MachO/DWARF-pubsections.yaml?rev=290139&view=auto" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/MachO/DWARF-pubsections.yaml?rev=290139&view=auto</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/test/ObjectYAML/MachO/DWARF-pubsections.yaml (added)<br class="gmail_msg">
+++ llvm/trunk/test/ObjectYAML/MachO/DWARF-pubsections.yaml Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -0,0 +1,355 @@<br class="gmail_msg">
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s<br class="gmail_msg">
+<br class="gmail_msg">
+--- !mach-o<br class="gmail_msg">
+FileHeader:<br class="gmail_msg">
+ magic: 0xFEEDFACF<br class="gmail_msg">
+ cputype: 0x01000007<br class="gmail_msg">
+ cpusubtype: 0x00000003<br class="gmail_msg">
+ filetype: 0x0000000A<br class="gmail_msg">
+ ncmds: 5<br class="gmail_msg">
+ sizeofcmds: 1800<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved: 0x00000000<br class="gmail_msg">
+LoadCommands:<br class="gmail_msg">
+ - cmd: LC_SEGMENT_64<br class="gmail_msg">
+ cmdsize: 72<br class="gmail_msg">
+ segname: __PAGEZERO<br class="gmail_msg">
+ vmaddr: 0<br class="gmail_msg">
+ vmsize: 4294967296<br class="gmail_msg">
+ fileoff: 0<br class="gmail_msg">
+ filesize: 0<br class="gmail_msg">
+ maxprot: 0<br class="gmail_msg">
+ initprot: 0<br class="gmail_msg">
+ nsects: 0<br class="gmail_msg">
+ flags: 0<br class="gmail_msg">
+ - cmd: LC_SEGMENT_64<br class="gmail_msg">
+ cmdsize: 472<br class="gmail_msg">
+ segname: __TEXT<br class="gmail_msg">
+ vmaddr: 4294967296<br class="gmail_msg">
+ vmsize: 4096<br class="gmail_msg">
+ fileoff: 0<br class="gmail_msg">
+ filesize: 0<br class="gmail_msg">
+ maxprot: 7<br class="gmail_msg">
+ initprot: 5<br class="gmail_msg">
+ nsects: 5<br class="gmail_msg">
+ flags: 0<br class="gmail_msg">
+ Sections:<br class="gmail_msg">
+ - sectname: __text<br class="gmail_msg">
+ segname: __TEXT<br class="gmail_msg">
+ addr: 0x0000000100000F50<br class="gmail_msg">
+ size: 52<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 4<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x80000400<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __stubs<br class="gmail_msg">
+ segname: __TEXT<br class="gmail_msg">
+ addr: 0x0000000100000F84<br class="gmail_msg">
+ size: 6<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 1<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x80000408<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000006<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __stub_helper<br class="gmail_msg">
+ segname: __TEXT<br class="gmail_msg">
+ addr: 0x0000000100000F8C<br class="gmail_msg">
+ size: 26<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 2<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x80000400<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __cstring<br class="gmail_msg">
+ segname: __TEXT<br class="gmail_msg">
+ addr: 0x0000000100000FA6<br class="gmail_msg">
+ size: 14<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000002<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __unwind_info<br class="gmail_msg">
+ segname: __TEXT<br class="gmail_msg">
+ addr: 0x0000000100000FB4<br class="gmail_msg">
+ size: 72<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 2<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - cmd: LC_SEGMENT_64<br class="gmail_msg">
+ cmdsize: 232<br class="gmail_msg">
+ segname: __DATA<br class="gmail_msg">
+ vmaddr: 4294971392<br class="gmail_msg">
+ vmsize: 4096<br class="gmail_msg">
+ fileoff: 0<br class="gmail_msg">
+ filesize: 0<br class="gmail_msg">
+ maxprot: 7<br class="gmail_msg">
+ initprot: 3<br class="gmail_msg">
+ nsects: 2<br class="gmail_msg">
+ flags: 0<br class="gmail_msg">
+ Sections:<br class="gmail_msg">
+ - sectname: __nl_symbol_ptr<br class="gmail_msg">
+ segname: __DATA<br class="gmail_msg">
+ addr: 0x0000000100001000<br class="gmail_msg">
+ size: 16<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 3<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000006<br class="gmail_msg">
+ reserved1: 0x00000001<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __la_symbol_ptr<br class="gmail_msg">
+ segname: __DATA<br class="gmail_msg">
+ addr: 0x0000000100001010<br class="gmail_msg">
+ size: 8<br class="gmail_msg">
+ offset: 0x00000000<br class="gmail_msg">
+ align: 3<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000007<br class="gmail_msg">
+ reserved1: 0x00000003<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - cmd: LC_SEGMENT_64<br class="gmail_msg">
+ cmdsize: 72<br class="gmail_msg">
+ segname: __LINKEDIT<br class="gmail_msg">
+ vmaddr: 4294975488<br class="gmail_msg">
+ vmsize: 4096<br class="gmail_msg">
+ fileoff: 4096<br class="gmail_msg">
+ filesize: 60<br class="gmail_msg">
+ maxprot: 7<br class="gmail_msg">
+ initprot: 1<br class="gmail_msg">
+ nsects: 0<br class="gmail_msg">
+ flags: 0<br class="gmail_msg">
+ - cmd: LC_SEGMENT_64<br class="gmail_msg">
+ cmdsize: 952<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ vmaddr: 4294979584<br class="gmail_msg">
+ vmsize: 4096<br class="gmail_msg">
+ fileoff: 8192<br class="gmail_msg">
+ filesize: 764<br class="gmail_msg">
+ maxprot: 7<br class="gmail_msg">
+ initprot: 3<br class="gmail_msg">
+ nsects: 11<br class="gmail_msg">
+ flags: 0<br class="gmail_msg">
+ Sections:<br class="gmail_msg">
+ - sectname: __debug_line<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003000<br class="gmail_msg">
+ size: 69<br class="gmail_msg">
+ offset: 0x00002000<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __debug_pubnames<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003045<br class="gmail_msg">
+ size: 27<br class="gmail_msg">
+ offset: 0x00002045<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __debug_pubtypes<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003060<br class="gmail_msg">
+ size: 35<br class="gmail_msg">
+ offset: 0x00002060<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __debug_aranges<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003083<br class="gmail_msg">
+ size: 48<br class="gmail_msg">
+ offset: 0x00002083<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __debug_info<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x00000001000030B3<br class="gmail_msg">
+ size: 121<br class="gmail_msg">
+ offset: 0x000020B3<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __debug_abbrev<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x000000010000312C<br class="gmail_msg">
+ size: 76<br class="gmail_msg">
+ offset: 0x0000212C<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __debug_str<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003178<br class="gmail_msg">
+ size: 142<br class="gmail_msg">
+ offset: 0x00002178<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __apple_names<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003206<br class="gmail_msg">
+ size: 60<br class="gmail_msg">
+ offset: 0x00002206<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __apple_namespac<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003242<br class="gmail_msg">
+ size: 36<br class="gmail_msg">
+ offset: 0x00002242<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __apple_types<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x0000000100003266<br class="gmail_msg">
+ size: 114<br class="gmail_msg">
+ offset: 0x00002266<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+ - sectname: __apple_objc<br class="gmail_msg">
+ segname: __DWARF<br class="gmail_msg">
+ addr: 0x00000001000032D8<br class="gmail_msg">
+ size: 36<br class="gmail_msg">
+ offset: 0x000022D8<br class="gmail_msg">
+ align: 0<br class="gmail_msg">
+ reloff: 0x00000000<br class="gmail_msg">
+ nreloc: 0<br class="gmail_msg">
+ flags: 0x00000000<br class="gmail_msg">
+ reserved1: 0x00000000<br class="gmail_msg">
+ reserved2: 0x00000000<br class="gmail_msg">
+ reserved3: 0x00000000<br class="gmail_msg">
+LinkEditData:<br class="gmail_msg">
+ NameList:<br class="gmail_msg">
+ - n_strx: 2<br class="gmail_msg">
+ n_type: 0x0F<br class="gmail_msg">
+ n_sect: 1<br class="gmail_msg">
+ n_desc: 16<br class="gmail_msg">
+ n_value: 4294967296<br class="gmail_msg">
+ - n_strx: 22<br class="gmail_msg">
+ n_type: 0x0F<br class="gmail_msg">
+ n_sect: 1<br class="gmail_msg">
+ n_desc: 0<br class="gmail_msg">
+ n_value: 4294971216<br class="gmail_msg">
+ StringTable:<br class="gmail_msg">
+ - ''<br class="gmail_msg">
+ - ''<br class="gmail_msg">
+ - __mh_execute_header<br class="gmail_msg">
+ - _main<br class="gmail_msg">
+DWARF:<br class="gmail_msg">
+ debug_str:<br class="gmail_msg">
+ - ''<br class="gmail_msg">
+ - 'clang version 4.0.0 (trunk 288923) (llvm/trunk 288991)'<br class="gmail_msg">
+ - hello_world.c<br class="gmail_msg">
+ - /Users/cbieneman/dev/open-source/llvm-build-rel<br class="gmail_msg">
+ - main<br class="gmail_msg">
+ - argc<br class="gmail_msg">
+ - argv<br class="gmail_msg">
+ - int<br class="gmail_msg">
+ - char<br class="gmail_msg">
+ debug_pubnames:<br class="gmail_msg">
+ Length: 23<br class="gmail_msg">
+ Version: 2<br class="gmail_msg">
+ UnitOffset: 0<br class="gmail_msg">
+ UnitSize: 121<br class="gmail_msg">
+ Entries:<br class="gmail_msg">
+ - DieOffset: 0x0000002A<br class="gmail_msg">
+ Name: main<br class="gmail_msg">
+ debug_pubtypes:<br class="gmail_msg">
+ Length: 31<br class="gmail_msg">
+ Version: 2<br class="gmail_msg">
+ UnitOffset: 0<br class="gmail_msg">
+ UnitSize: 121<br class="gmail_msg">
+ Entries:<br class="gmail_msg">
+ - DieOffset: 0x00000060<br class="gmail_msg">
+ Name: int<br class="gmail_msg">
+ - DieOffset: 0x00000071<br class="gmail_msg">
+ Name: char<br class="gmail_msg">
+...<br class="gmail_msg">
+<br class="gmail_msg">
+#CHECK: DWARF:<br class="gmail_msg">
+#CHECK: debug_pubnames:<br class="gmail_msg">
+#CHECK: Length: 23<br class="gmail_msg">
+#CHECK: Version: 2<br class="gmail_msg">
+#CHECK: UnitOffset: 0<br class="gmail_msg">
+#CHECK: UnitSize: 121<br class="gmail_msg">
+#CHECK: Entries:<br class="gmail_msg">
+#CHECK: - DieOffset: 0x0000002A<br class="gmail_msg">
+#CHECK: Name: main<br class="gmail_msg">
+#CHECK: debug_pubtypes:<br class="gmail_msg">
+#CHECK: Length: 31<br class="gmail_msg">
+#CHECK: Version: 2<br class="gmail_msg">
+#CHECK: UnitOffset: 0<br class="gmail_msg">
+#CHECK: UnitSize: 121<br class="gmail_msg">
+#CHECK: Entries:<br class="gmail_msg">
+#CHECK: - DieOffset: 0x00000060<br class="gmail_msg">
+#CHECK: Name: int<br class="gmail_msg">
+#CHECK: - DieOffset: 0x00000071<br class="gmail_msg">
+#CHECK: Name: char<br class="gmail_msg">
+#CHECK: ...<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp?rev=290139&r1=290138&r2=290139&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp?rev=290139&r1=290138&r2=290139&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -67,11 +67,44 @@ void dumpDebugARanges(DWARFContextInMemo<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+void dumpPubSection(DWARFContextInMemory &DCtx, DWARFYAML::PubSection &Y,<br class="gmail_msg">
+ StringRef Section) {<br class="gmail_msg">
+ DataExtractor PubSectionData(Section, DCtx.isLittleEndian(), 0);<br class="gmail_msg">
+ uint32_t Offset = 0;<br class="gmail_msg">
+ Y.Length = PubSectionData.getU32(&Offset);<br class="gmail_msg">
+ Y.Version = PubSectionData.getU16(&Offset);<br class="gmail_msg">
+ Y.UnitOffset = PubSectionData.getU32(&Offset);<br class="gmail_msg">
+ Y.UnitSize = PubSectionData.getU32(&Offset);<br class="gmail_msg">
+ while (Offset < Y.Length) {<br class="gmail_msg">
+ DWARFYAML::PubEntry NewEntry;<br class="gmail_msg">
+ NewEntry.DieOffset = PubSectionData.getU32(&Offset);<br class="gmail_msg">
+ if (Y.IsGNUStyle)<br class="gmail_msg">
+ NewEntry.Descriptor = PubSectionData.getU8(&Offset);<br class="gmail_msg">
+ NewEntry.Name = PubSectionData.getCStr(&Offset);<br class="gmail_msg">
+ Y.Entries.push_back(NewEntry);<br class="gmail_msg">
+ }<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+void dumpDebugPubSections(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) {<br class="gmail_msg">
+ Y.PubNames.IsGNUStyle = false;<br class="gmail_msg">
+ dumpPubSection(DCtx, Y.PubNames, DCtx.getPubNamesSection());<br class="gmail_msg">
+<br class="gmail_msg">
+ Y.PubTypes.IsGNUStyle = false;<br class="gmail_msg">
+ dumpPubSection(DCtx, Y.PubTypes, DCtx.getPubTypesSection());<br class="gmail_msg">
+<br class="gmail_msg">
+ Y.GNUPubNames.IsGNUStyle = true;<br class="gmail_msg">
+ dumpPubSection(DCtx, Y.GNUPubNames, DCtx.getGnuPubNamesSection());<br class="gmail_msg">
+<br class="gmail_msg">
+ Y.GNUPubTypes.IsGNUStyle = true;<br class="gmail_msg">
+ dumpPubSection(DCtx, Y.GNUPubTypes, DCtx.getGnuPubTypesSection());<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
std::error_code dwarf2yaml(DWARFContextInMemory &DCtx,<br class="gmail_msg">
DWARFYAML::Data &Y) {<br class="gmail_msg">
dumpDebugAbbrev(DCtx, Y);<br class="gmail_msg">
dumpDebugStrings(DCtx, Y);<br class="gmail_msg">
dumpDebugARanges(DCtx, Y);<br class="gmail_msg">
+ dumpDebugPubSections(DCtx, Y);<br class="gmail_msg">
<br class="gmail_msg">
return obj2yaml_error::success;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/tools/yaml2obj/yaml2dwarf.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2dwarf.cpp?rev=290139&r1=290138&r2=290139&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2dwarf.cpp?rev=290139&r1=290138&r2=290139&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/tools/yaml2obj/yaml2dwarf.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/tools/yaml2obj/yaml2dwarf.cpp Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -66,3 +66,17 @@ void yaml2debug_aranges(raw_ostream &OS,<br class="gmail_msg">
ZeroFillBytes(OS, Range.AddrSize * 2);<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
+<br class="gmail_msg">
+void yaml2pubsection(raw_ostream &OS, const DWARFYAML::PubSection &Sect) {<br class="gmail_msg">
+ OS.write(reinterpret_cast<const char *>(&Sect.Length), 4);<br class="gmail_msg"></blockquote><div><br>What's the deal with endianness, etc in code like this (seems to be idiomatic in this yaml obj code - but on first blush looks like it'd be broken (not write the expected bytes to the output stream) if the values weren't stored in the desired alignment))?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ OS.write(reinterpret_cast<const char *>(&Sect.Version), 2);<br class="gmail_msg">
+ OS.write(reinterpret_cast<const char *>(&Sect.UnitOffset), 4);<br class="gmail_msg">
+ OS.write(reinterpret_cast<const char *>(&Sect.UnitSize), 4);<br class="gmail_msg">
+ for (auto Entry : Sect.Entries) {<br class="gmail_msg">
+ OS.write(reinterpret_cast<const char *>(&Entry.DieOffset), 4);<br class="gmail_msg">
+ if (Sect.IsGNUStyle)<br class="gmail_msg">
+ OS.write(reinterpret_cast<const char *>(&Entry.Descriptor), 4);<br class="gmail_msg">
+ OS.write(Entry.Name.data(), Entry.Name.size());<br class="gmail_msg">
+ OS.write('\0');<br class="gmail_msg">
+ }<br class="gmail_msg">
+}<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/tools/yaml2obj/yaml2macho.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2macho.cpp?rev=290139&r1=290138&r2=290139&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2macho.cpp?rev=290139&r1=290138&r2=290139&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/tools/yaml2obj/yaml2macho.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/tools/yaml2obj/yaml2macho.cpp Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -394,6 +394,10 @@ Error MachOWriter::writeDWARFData(raw_os<br class="gmail_msg">
yaml2debug_abbrev(OS, Obj.DWARF);<br class="gmail_msg">
} else if (0 == strncmp(&Section.sectname[0], "__debug_aranges", 16)) {<br class="gmail_msg">
yaml2debug_aranges(OS, Obj.DWARF);<br class="gmail_msg">
+ } else if (0 == strncmp(&Section.sectname[0], "__debug_pubnames", 16)) {<br class="gmail_msg">
+ yaml2pubsection(OS, Obj.DWARF.PubNames);<br class="gmail_msg">
+ } else if (0 == strncmp(&Section.sectname[0], "__debug_pubtypes", 16)) {<br class="gmail_msg">
+ yaml2pubsection(OS, Obj.DWARF.PubTypes);<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
return Error::success();<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/tools/yaml2obj/yaml2obj.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2obj.h?rev=290139&r1=290138&r2=290139&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2obj.h?rev=290139&r1=290138&r2=290139&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/tools/yaml2obj/yaml2obj.h (original)<br class="gmail_msg">
+++ llvm/trunk/tools/yaml2obj/yaml2obj.h Mon Dec 19 16:22:12 2016<br class="gmail_msg">
@@ -25,6 +25,7 @@ struct Object;<br class="gmail_msg">
<br class="gmail_msg">
namespace DWARFYAML {<br class="gmail_msg">
struct Data;<br class="gmail_msg">
+struct PubSection;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
namespace yaml {<br class="gmail_msg">
@@ -43,5 +44,7 @@ void yaml2debug_str(llvm::raw_ostream &O<br class="gmail_msg">
const llvm::DWARFYAML::Data &DI);<br class="gmail_msg">
<br class="gmail_msg">
void yaml2debug_aranges(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);<br class="gmail_msg">
+void yaml2pubsection(llvm::raw_ostream &OS,<br class="gmail_msg">
+ const llvm::DWARFYAML::PubSection &Sect);<br class="gmail_msg">
<br class="gmail_msg">
#endif<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-commits mailing list<br class="gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
</blockquote></div></div>