summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4521019)
raw | patch | inline | side by side (parent: 4521019)
author | Rafael Espindola <rafael.espindola@gmail.com> | |
Fri, 19 Apr 2013 11:36:47 +0000 (11:36 +0000) | ||
committer | Rafael Espindola <rafael.espindola@gmail.com> | |
Fri, 19 Apr 2013 11:36:47 +0000 (11:36 +0000) |
Thanks to Evgeniy Stepanov for reporting this.
It might be a good idea to add a command iterator abstraction to MachO.h, but
this fixes the bug for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179848 91177308-0d34-0410-b5e6-96231b3b80d8
It might be a good idea to add a command iterator abstraction to MachO.h, but
this fixes the bug for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179848 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Object/MachOObjectFile.cpp | patch | blob | history | |
test/Object/ARM/objdump-thumb.test | [new file with mode: 0644] | patch | blob |
test/Object/Inputs/macho-text.thumb | [new file with mode: 0644] | patch | blob |
tools/llvm-objdump/MachODump.cpp | patch | blob | history |
index f5910dd95d794866174db2c8451732da5dc0fa44..d26eb2ce6112a6b7cfa61facceb988c8c23cd72a 100644 (file)
macho::LCT_Segment64 : macho::LCT_Segment;
MachOObjectFile::LoadCommandInfo Load = getFirstLoadCommandInfo();
- for (unsigned I = 0; I < LoadCommandCount; ++I) {
+ for (unsigned I = 0; ; ++I) {
if (Load.C.Type == macho::LCT_Symtab) {
assert(!SymtabLoadCmd && "Multiple symbol tables");
SymtabLoadCmd = Load.Ptr;
Sections.push_back(reinterpret_cast<const char*>(Sec));
}
}
- Load = getNextLoadCommandInfo(Load);
+
+ if (I == LoadCommandCount - 1)
+ break;
+ else
+ Load = getNextLoadCommandInfo(Load);
}
}
diff --git a/test/Object/ARM/objdump-thumb.test b/test/Object/ARM/objdump-thumb.test
--- /dev/null
@@ -0,0 +1,4 @@
+RUN: llvm-objdump -d -macho -triple=thumbv7-apple-ios \
+RUN: %p/../Inputs/macho-text.thumb | FileCheck %s
+
+CHECK: 0: 00 bf nop
diff --git a/test/Object/Inputs/macho-text.thumb b/test/Object/Inputs/macho-text.thumb
new file mode 100644 (file)
index 0000000..b29428a
Binary files /dev/null and b/test/Object/Inputs/macho-text.thumb differ
index 0000000..b29428a
Binary files /dev/null and b/test/Object/Inputs/macho-text.thumb differ
index e4d9ce2498560411fdae5148a4d665a26468a050..d78d7f31a6cac9bce10aaa9ffa2e4caeb03eb763 100644 (file)
MachOObjectFile::LoadCommandInfo Command =
MachOObj->getFirstLoadCommandInfo();
- for (unsigned i = 0; i != Header.NumLoadCommands; ++i) {
+ for (unsigned i = 0; ; ++i) {
if (Command.C.Type == macho::LCT_FunctionStarts) {
// We found a function starts segment, parse the addresses for later
// consumption.
MachOObj->ReadULEB128s(LLC.DataOffset, FoundFns);
}
- Command = MachOObj->getNextLoadCommandInfo(Command);
+
+ if (i == Header.NumLoadCommands - 1)
+ break;
+ else
+ Command = MachOObj->getNextLoadCommandInfo(Command);
}
}