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