summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp5
-rwxr-xr-xllvm/test/Object/Inputs/macho-no-exports.dylibbin0 -> 4208 bytes
-rw-r--r--llvm/test/Object/objdump-export-list.test4
3 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index fd086af6d52..92981fe6b7e 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -1640,7 +1640,10 @@ void ExportEntry::moveNext() {
iterator_range<export_iterator>
MachOObjectFile::exports(ArrayRef<uint8_t> Trie) {
ExportEntry Start(Trie);
- Start.moveToFirst();
+ if (Trie.size() == 0)
+ Start.moveToEnd();
+ else
+ Start.moveToFirst();
ExportEntry Finish(Trie);
Finish.moveToEnd();
diff --git a/llvm/test/Object/Inputs/macho-no-exports.dylib b/llvm/test/Object/Inputs/macho-no-exports.dylib
new file mode 100755
index 00000000000..6e1be6ca97e
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-no-exports.dylib
Binary files differ
diff --git a/llvm/test/Object/objdump-export-list.test b/llvm/test/Object/objdump-export-list.test
new file mode 100644
index 00000000000..74344c1c2e2
--- /dev/null
+++ b/llvm/test/Object/objdump-export-list.test
@@ -0,0 +1,4 @@
+RUN: llvm-objdump -exports-trie %p/Inputs/macho-no-exports.dylib | FileCheck %s
+
+; Test that we don't crash with an empty export list.
+CHECK: macho-no-exports.dylib: file format Mach-O 64-bit x86-64
OpenPOWER on IntegriCloud