llvm.org GIT mirror llvm / 506857f
[macho2yaml] Don't write empty linkedit data Since I stopped writing empty export tries it causes LinkEdit to potentially be completely empty which results in invalid yaml being generated. To prevent this we skip linkedit data if it is empty. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278985 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 3 years ago
3 changed file(s) with 9 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
9999 MachOYAML::ExportEntry ExportTrie;
100100 std::vector NameList;
101101 std::vector StringTable;
102
103 bool isEmpty() const;
102104 };
103105
104106 struct Object {
2020 namespace llvm {
2121
2222 MachOYAML::LoadCommand::~LoadCommand() {}
23
24 bool MachOYAML::LinkEditData::isEmpty() const {
25 return 0 == RebaseOpcodes.size() + BindOpcodes.size() + WeakBindOpcodes.size() + LazyBindOpcodes.size() + ExportTrie.Children.size() + NameList.size() + StringTable.size();
26 }
2327
2428 namespace yaml {
2529
9498 IO.mapTag("!mach-o", true);
9599 IO.mapRequired("FileHeader", Object.Header);
96100 IO.mapOptional("LoadCommands", Object.LoadCommands);
97 IO.mapOptional("LinkEditData", Object.LinkEdit);
101 if(!Object.LinkEdit.isEmpty() || !IO.outputting())
102 IO.mapOptional("LinkEditData", Object.LinkEdit);
98103
99104 if (IO.getContext() == &Object)
100105 IO.setContext(nullptr);
4848 #CHECK: - 0x0A
4949 #CHECK: - 0x0B
5050 #CHECK: - 0x0C
51 #CHECK-NOT: LinkEditData: