OSDN Git Service

[Object] Fix reading objects created with -fembed-bitcode-marker
authorSteven Wu <stevenwu@apple.com>
Thu, 21 Mar 2019 21:01:31 +0000 (21:01 +0000)
committerSteven Wu <stevenwu@apple.com>
Thu, 21 Mar 2019 21:01:31 +0000 (21:01 +0000)
commitb79b3c8160501d3ead3c2a9262a62801d428d730
tree7381ac4f00db30165cad69252a2b864534b28a8e
parent5bb6fe119091ac7fc9ba12cd04af7b9b6c537a9e
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356718 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Object/IRObjectFile.cpp
test/Object/Inputs/macho-bitcode-marker-x86_64.o [new file with mode: 0644]
test/Object/Inputs/macho-bitcode-x86_64.o [new file with mode: 0644]
test/Object/nm-bitcode.test [new file with mode: 0644]