diff options
author | Kevin Enderby <enderby@apple.com> | 2015-10-08 16:56:35 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2015-10-08 16:56:35 +0000 |
commit | aac75382160bb19e7d58c8d3af15ee629eaa860d (patch) | |
tree | 3b68852560f0ee99df20cc37c789b688337dbb0c /llvm/tools/llvm-objdump/MachODump.cpp | |
parent | e84b000ccb296424483c06a6305eb8744dfd054c (diff) | |
download | bcm5719-llvm-aac75382160bb19e7d58c8d3af15ee629eaa860d.tar.gz bcm5719-llvm-aac75382160bb19e7d58c8d3af15ee629eaa860d.zip |
Fix a bug in llvm-objdump’s printing of Objective-C meta data
from malformed Mach-O files that caused a crash because of loops
in the class meta data.
llvm-svn: 249700
Diffstat (limited to 'llvm/tools/llvm-objdump/MachODump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 0e9bf3695d8..b6b910f55dc 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -1667,6 +1667,7 @@ struct DisassembleInfo { uint64_t adrp_addr; uint32_t adrp_inst; BindTable *bindtable; + uint32_t depth; }; // SymbolizerGetOpInfo() is the operand information call back function. @@ -4463,9 +4464,13 @@ static void print_class64_t(uint64_t p, struct DisassembleInfo *info) { bool is_meta_class; print_class_ro64_t((c.data + n_value) & ~0x7, info, is_meta_class); - if (!is_meta_class) { - outs() << "Meta Class\n"; - print_class64_t(c.isa + isa_n_value, info); + if (!is_meta_class && + c.isa + isa_n_value != p && + c.isa + isa_n_value != 0 && + info->depth < 100) { + info->depth++; + outs() << "Meta Class\n"; + print_class64_t(c.isa + isa_n_value, info); } } @@ -5113,6 +5118,7 @@ static void printObjc2_64bit_MetaData(MachOObjectFile *O, bool verbose) { info.adrp_addr = 0; info.adrp_inst = 0; + info.depth = 0; const SectionRef CL = get_section(O, "__OBJC2", "__class_list"); if (CL != SectionRef()) { info.S = CL; |