mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-18 02:16:43 +00:00
[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
This commit is contained in:
parent
9744bb48e4
commit
506857f427
@ -100,6 +100,8 @@ struct LinkEditData {
|
||||
MachOYAML::ExportEntry ExportTrie;
|
||||
std::vector<NListEntry> NameList;
|
||||
std::vector<StringRef> StringTable;
|
||||
|
||||
bool isEmpty() const;
|
||||
};
|
||||
|
||||
struct Object {
|
||||
|
@ -22,6 +22,10 @@ namespace llvm {
|
||||
|
||||
MachOYAML::LoadCommand::~LoadCommand() {}
|
||||
|
||||
bool MachOYAML::LinkEditData::isEmpty() const {
|
||||
return 0 == RebaseOpcodes.size() + BindOpcodes.size() + WeakBindOpcodes.size() + LazyBindOpcodes.size() + ExportTrie.Children.size() + NameList.size() + StringTable.size();
|
||||
}
|
||||
|
||||
namespace yaml {
|
||||
|
||||
void ScalarTraits<char_16>::output(const char_16 &Val, void *,
|
||||
@ -95,7 +99,8 @@ void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
|
||||
IO.mapTag("!mach-o", true);
|
||||
IO.mapRequired("FileHeader", Object.Header);
|
||||
IO.mapOptional("LoadCommands", Object.LoadCommands);
|
||||
IO.mapOptional("LinkEditData", Object.LinkEdit);
|
||||
if(!Object.LinkEdit.isEmpty() || !IO.outputting())
|
||||
IO.mapOptional("LinkEditData", Object.LinkEdit);
|
||||
|
||||
if (IO.getContext() == &Object)
|
||||
IO.setContext(nullptr);
|
||||
|
@ -49,3 +49,4 @@ LoadCommands:
|
||||
#CHECK: - 0x0A
|
||||
#CHECK: - 0x0B
|
||||
#CHECK: - 0x0C
|
||||
#CHECK-NOT: LinkEditData:
|
||||
|
Loading…
x
Reference in New Issue
Block a user