mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[Object] Fix reading objects created with -fembed-bitcode-marker
Currently, this fails with many tools, e.g. $ clang -fembed-bitcode-marker -c -o test.o test.c $ nm test.o nm: test.o The file was not recognized as a valid object file -fembed-bitcode-marker creates a LLVM,bitcode section consisting of a single byte. When reading the object file, IRObjectFile::findBitcodeInObject succeeds, causing SymbolicFile::createSymbolicFile to try to read the "bitcode" rather than using the outer Mach-O data - when then fails. Fix this by making findBitcodeInObject return an error if the section size <= 1. Patched by: Nicholas Allegra Differential Revision: https://reviews.llvm.org/D44373 llvm-svn: 356718
This commit is contained in:
parent
8098d943bc
commit
81b4af3e73
@ -78,6 +78,8 @@ IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
BIN
test/Object/Inputs/macho-bitcode-marker-x86_64.o
Normal file
BIN
test/Object/Inputs/macho-bitcode-marker-x86_64.o
Normal file
Binary file not shown.
BIN
test/Object/Inputs/macho-bitcode-x86_64.o
Normal file
BIN
test/Object/Inputs/macho-bitcode-x86_64.o
Normal file
Binary file not shown.
12
test/Object/nm-bitcode.test
Normal file
12
test/Object/nm-bitcode.test
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user