diff options
Diffstat (limited to 'tools/yaml2obj/yaml2macho.cpp')
-rw-r--r-- | tools/yaml2obj/yaml2macho.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/yaml2obj/yaml2macho.cpp b/tools/yaml2obj/yaml2macho.cpp index cbc4d7ff50d5e..92b736e5298e3 100644 --- a/tools/yaml2obj/yaml2macho.cpp +++ b/tools/yaml2obj/yaml2macho.cpp @@ -14,6 +14,7 @@ #include "yaml2obj.h" #include "llvm/ObjectYAML/ObjectYAML.h" +#include "llvm/ObjectYAML/DWARFEmitter.h" #include "llvm/Support/Error.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/MachO.h" @@ -179,6 +180,21 @@ size_t writeLoadCommandData<MachO::rpath_command>(MachOYAML::LoadCommand &LC, return writePayloadString(LC, OS); } +template <> +size_t writeLoadCommandData<MachO::build_version_command>( + MachOYAML::LoadCommand &LC, raw_ostream &OS, bool IsLittleEndian) { + size_t BytesWritten = 0; + for (const auto &T : LC.Tools) { + struct MachO::build_tool_version tool = T; + if (IsLittleEndian != sys::IsLittleEndianHost) + MachO::swapStruct(tool); + OS.write(reinterpret_cast<const char *>(&tool), + sizeof(MachO::build_tool_version)); + BytesWritten += sizeof(MachO::build_tool_version); + } + return BytesWritten; +} + void ZeroFillBytes(raw_ostream &OS, size_t Size) { std::vector<uint8_t> FillData; FillData.insert(FillData.begin(), Size, 0); @@ -269,19 +285,21 @@ Error MachOWriter::writeSectionData(raw_ostream &OS) { "Wrote too much data somewhere, section offsets don't line up."); if (0 == strncmp(&Sec.segname[0], "__DWARF", 16)) { if (0 == strncmp(&Sec.sectname[0], "__debug_str", 16)) { - yaml2debug_str(OS, Obj.DWARF); + DWARFYAML::EmitDebugStr(OS, Obj.DWARF); } else if (0 == strncmp(&Sec.sectname[0], "__debug_abbrev", 16)) { - yaml2debug_abbrev(OS, Obj.DWARF); + DWARFYAML::EmitDebugAbbrev(OS, Obj.DWARF); } else if (0 == strncmp(&Sec.sectname[0], "__debug_aranges", 16)) { - yaml2debug_aranges(OS, Obj.DWARF); + DWARFYAML::EmitDebugAranges(OS, Obj.DWARF); } else if (0 == strncmp(&Sec.sectname[0], "__debug_pubnames", 16)) { - yaml2pubsection(OS, Obj.DWARF.PubNames, Obj.IsLittleEndian); + DWARFYAML::EmitPubSection(OS, Obj.DWARF.PubNames, + Obj.IsLittleEndian); } else if (0 == strncmp(&Sec.sectname[0], "__debug_pubtypes", 16)) { - yaml2pubsection(OS, Obj.DWARF.PubTypes, Obj.IsLittleEndian); + DWARFYAML::EmitPubSection(OS, Obj.DWARF.PubTypes, + Obj.IsLittleEndian); } else if (0 == strncmp(&Sec.sectname[0], "__debug_info", 16)) { - yaml2debug_info(OS, Obj.DWARF); + DWARFYAML::EmitDebugInfo(OS, Obj.DWARF); } else if (0 == strncmp(&Sec.sectname[0], "__debug_line", 16)) { - yaml2debug_line(OS, Obj.DWARF); + DWARFYAML::EmitDebugLine(OS, Obj.DWARF); } } else { // Fills section data with 0xDEADBEEF |