[PATCH] D44373: Fix reading objects created with -fembed-bitcode-marker.
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 14:00:29 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356718: [Object] Fix reading objects created with -fembed-bitcode-marker (authored by steven_wu, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D44373/new/
https://reviews.llvm.org/D44373
Files:
llvm/trunk/lib/Object/IRObjectFile.cpp
llvm/trunk/test/Object/Inputs/macho-bitcode-marker-x86_64.o
llvm/trunk/test/Object/Inputs/macho-bitcode-x86_64.o
llvm/trunk/test/Object/nm-bitcode.test
Index: llvm/trunk/lib/Object/IRObjectFile.cpp
===================================================================
--- llvm/trunk/lib/Object/IRObjectFile.cpp
+++ llvm/trunk/lib/Object/IRObjectFile.cpp
@@ -78,6 +78,8 @@
StringRef SecContents;
if (std::error_code EC = Sec.getContents(SecContents))
return errorCodeToError(EC);
+ if (SecContents.size() <= 1)
+ return errorCodeToError(object_error::bitcode_section_not_found);
return MemoryBufferRef(SecContents, Obj.getFileName());
}
}
Index: llvm/trunk/test/Object/nm-bitcode.test
===================================================================
--- llvm/trunk/test/Object/nm-bitcode.test
+++ llvm/trunk/test/Object/nm-bitcode.test
@@ -0,0 +1,12 @@
+# Inputs generated with:
+# echo 'int hello() { return 5; }' > test.c
+# clang -O -fembed-bitcode -c -o macho-bitcode-x86_64.o test.c
+# clang -O -fembed-bitcode-marker -c -o macho-bitcode-marker-x86_64.o test.c
+
+RUN: llvm-nm -a %p/Inputs/macho-bitcode-x86_64.o \
+RUN: | FileCheck %s
+
+RUN: llvm-nm -a %p/Inputs/macho-bitcode-marker-x86_64.o \
+RUN: | FileCheck %s
+
+CHECK: T _hello
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44373.191777.patch
Type: text/x-patch
Size: 1156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190321/b018a702/attachment-0001.bin>
More information about the llvm-commits
mailing list