Skip to content

Commit

Permalink
Revert "[obj2yaml] [yaml2obj] Support MachO section and section_64
Browse files Browse the repository at this point in the history
structs"

This reverts commits r269845, r269846, and r269850 as they
introduce a crash in obj2yaml when trying to do a roundtrip.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269865 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Zachary Turner committed May 17, 2016
1 parent 34ab13f commit 8e5ffc9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 424 deletions.
22 changes: 0 additions & 22 deletions include/llvm/ObjectYAML/MachOYAML.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@
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;
Expand All @@ -51,20 +36,17 @@ struct FileHeader {
struct LoadCommand {
virtual ~LoadCommand();
llvm::MachO::macho_load_command Data;
std::vector<Section> Sections;
};

struct Object {
FileHeader Header;
std::vector<LoadCommand> LoadCommands;
std::vector<Section> 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 {
Expand All @@ -81,10 +63,6 @@ template <> struct MappingTraits<MachOYAML::LoadCommand> {
static void mapping(IO &IO, MachOYAML::LoadCommand &LoadCommand);
};

template <> struct MappingTraits<MachOYAML::Section> {
static void mapping(IO &IO, MachOYAML::Section &Section);
};

#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
io.enumCase(value, #LCName, MachO::LCName);

Expand Down
26 changes: 2 additions & 24 deletions lib/ObjectYAML/MachOYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,42 +110,20 @@ void MappingTraits<MachOYAML::LoadCommand>::mapping(
switch (LoadCommand.Data.load_command_data.cmd) {
#include "llvm/Support/MachO.def"
}
if (LoadCommand.Data.load_command_data.cmd == MachO::LC_SEGMENT ||
LoadCommand.Data.load_command_data.cmd == MachO::LC_SEGMENT_64) {
IO.mapOptional("Sections", LoadCommand.Sections);
}
}

void MappingTraits<MachO::dyld_info_command>::mapping(
IO &IO, MachO::dyld_info_command &LoadCommand) {
IO.mapRequired("rebase_off", LoadCommand.rebase_off);
IO.mapRequired("rebase_size", LoadCommand.rebase_size);
IO.mapRequired("bind_off", LoadCommand.bind_off);
IO.mapRequired("bind_size", LoadCommand.bind_size);
IO.mapRequired("bind_off", LoadCommand.bind_size);
IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_size);
IO.mapRequired("export_off", LoadCommand.export_off);
IO.mapRequired("export_size", LoadCommand.export_size);
}

void MappingTraits<MachOYAML::Section>::mapping(IO &IO,
MachOYAML::Section &Section) {
IO.mapRequired("sectname", Section.sectname);
IO.mapRequired("segname", Section.segname);
IO.mapRequired("addr", Section.addr);
IO.mapRequired("size", Section.size);
IO.mapRequired("offset", Section.offset);
IO.mapRequired("align", Section.align);
IO.mapRequired("reloff", Section.reloff);
IO.mapRequired("nreloc", Section.nreloc);
IO.mapRequired("flags", Section.flags);
IO.mapRequired("reserved1", Section.reserved1);
IO.mapRequired("reserved2", Section.reserved2);
IO.mapOptional("reserved3", Section.reserved3);
}

void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {
IO.mapRequired("name", DylibStruct.name);
IO.mapRequired("timestamp", DylibStruct.timestamp);
Expand Down
12 changes: 4 additions & 8 deletions test/ObjectYAML/MachO/load_commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ LoadCommands:
cmdsize: 48
rebase_off: 12288
rebase_size: 8
bind_off: 12296
bind_size: 96
bind_off: 96
weak_bind_off: 0
weak_bind_size: 0
lazy_bind_off: 12392
lazy_bind_size: 624
lazy_bind_off: 624
export_off: 13016
export_size: 48
- cmd: LC_SYMTAB
Expand Down Expand Up @@ -186,12 +184,10 @@ LoadCommands:
#CHECK: cmdsize: 48
#CHECK: rebase_off: 12288
#CHECK: rebase_size: 8
#CHECK: bind_off: 12296
#CHECK: bind_size: 96
#CHECK: bind_off: 96
#CHECK: weak_bind_off: 0
#CHECK: weak_bind_size: 0
#CHECK: lazy_bind_off: 12392
#CHECK: lazy_bind_size: 624
#CHECK: lazy_bind_off: 624
#CHECK: export_off: 13016
#CHECK: export_size: 48
#CHECK: - cmd: LC_SYMTAB
Expand Down
Loading

0 comments on commit 8e5ffc9

Please sign in to comment.