Page MenuHomePhabricator

Fix reading objects created with -fembed-bitcode-marker.

Authored by comex on Mar 11 2018, 4:30 PM.



Currently, this fails with many tools, e.g.

$ clang -fembed-bitcode-marker -c -o test.o test.c
$ nm test.o
/Applications/ 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.

Diff Detail

Event Timeline

comex created this revision.Mar 11 2018, 4:30 PM

Thanks for fixing this. LGTM.

steven_wu accepted this revision.Mar 13 2018, 10:39 AM
This revision is now accepted and ready to land.Mar 13 2018, 10:39 AM

Additional comment, I didn't realize llvm-nm now prioritize to print bitcode symbol table, rather than the symbol table from the object file. There should be an option to choose which one to see and maybe also an option to see both.

@pcc, how is the symbol table designed for embedded bitcode for LTO? Does the native object side has a symbol table?