[cfe-dev] Patch: Make ccc generate native object files

Chris Lattner clattner at apple.com
Sat Feb 9 13:26:57 PST 2008


On Feb 9, 2008, at 1:22 PM, Shantonu Sen wrote:

> I'm not suggesting they do.
>
> I'm suggesting that llvm/lib/Bitcode/BitcodeReader.cpp know that if  
> the first few bytes don't look like a bitcode file, it should try to  
> analyze it as a Mach-O file and read enough of the load commands to  
> find a __LLVM,__llvm section, and then create a view into the memory  
> buffer of just that data. Same for ELF.
>
> All llvm tools layered on top of BitcodeReader would look at the  
> LLVM data for these hybrid objects. Native tools would look at the  
> native parts. The native linker would aggregate the __LLVM,__llvm  
> section into some useless blob, probably, but that's OK for these  
> purposes.

Right, I'm pretty sure I understand what you're suggesting.  This does  
require llvm to know enough of the native .o formats (macho, elf) to  
be able to find the bc section and its extents, that's all I'm  
saying :).  If someone was interested in adding support for this to  
LLVM, I wouldn't oppose it at all, but it should be in a different  
file than bitcodereader.cpp.  We want clients that don't need this  
functionality to be able to link in bc reader without linking in extra  
code.  Since bcreader is an archive, putting the code in a  
separate .cpp file is sufficient for this,

-Chris

> Sent from my MacBook
>
> On Feb 9, 2008, at 1:18 PM, Chris Lattner wrote:
>
>>
>> On Feb 9, 2008, at 12:49 PM, Shantonu Sen wrote:
>>> One approach that would probably make everyone happy is to teach  
>>> "llc"
>>> how to output the original bitcode stream in its own section/segment
>>> in the native assembly stream, and teach the LLVM libraries how to
>>> extract this encapsulated bitcode data for Mach-O, ELF, etc., in the
>>> event that the input file is not a bitcode file directly.
>>
>> It's pretty easy to get the .bc file encoded into the .s file in  
>> some magic section, however, it would be harder to teach all the  
>> llvm tools about native .o files etc,
>>
>> -Chris
>




More information about the cfe-dev mailing list