From 7ec0ea16b76a61c5f773fa3abd96335647190229 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 18 May 2016 16:17:23 +0000 Subject: Re-apply: [obj2yaml] [yaml2obj] Support MachO section and section_64 This re-applies r269845, r269846, and r269850 with an included fix for a crash reported by zturner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269953 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ObjectYAML/MachOYAML.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include') diff --git a/include/llvm/ObjectYAML/MachOYAML.h b/include/llvm/ObjectYAML/MachOYAML.h index 21558f00cc0..3c79a20c55a 100644 --- a/include/llvm/ObjectYAML/MachOYAML.h +++ b/include/llvm/ObjectYAML/MachOYAML.h @@ -22,6 +22,21 @@ namespace llvm { namespace MachOYAML { +struct Section { + char sectname[16]; + char segname[16]; + llvm::yaml::Hex64 addr; + uint64_t size; + llvm::yaml::Hex32 offset; + uint32_t align; + llvm::yaml::Hex32 reloff; + uint32_t nreloc; + llvm::yaml::Hex32 flags; + llvm::yaml::Hex32 reserved1; + llvm::yaml::Hex32 reserved2; + llvm::yaml::Hex32 reserved3; +}; + struct FileHeader { llvm::yaml::Hex32 magic; llvm::yaml::Hex32 cputype; @@ -36,17 +51,20 @@ struct FileHeader { struct LoadCommand { virtual ~LoadCommand(); llvm::MachO::macho_load_command Data; + std::vector
Sections; }; struct Object { FileHeader Header; std::vector LoadCommands; + std::vector
Sections; }; } // namespace llvm::MachOYAML } // namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::LoadCommand) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::Section) namespace llvm { namespace yaml { @@ -63,6 +81,10 @@ template <> struct MappingTraits { static void mapping(IO &IO, MachOYAML::LoadCommand &LoadCommand); }; +template <> struct MappingTraits { + static void mapping(IO &IO, MachOYAML::Section &Section); +}; + #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ io.enumCase(value, #LCName, MachO::LCName); -- cgit v1.2.3