This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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

$ clang -fembed-bitcode-marker -c -o test.o test.c
$ nm test.o
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/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.

Diff Detail

Repository
rL LLVM

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?

Thanks for fixing this. LGTM.

Looks like this never actually got committed?

Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2019, 7:26 AM

Thanks for fixing this. LGTM.

Looks like this never actually got committed?

Thanks for catching this. Looks like @comex doesn't have commit right. I will do that.

This revision was automatically updated to reflect the committed changes.