[llvm-commits] Code refactoring of MCELFStreamer.cpp and ELFObjectWriter.cpp

Jan Sjodin jan_sjodin at yahoo.com
Fri Feb 25 17:54:30 PST 2011


The JIT implementation I am working on (MCJIT which was renamed to JunkJIT) 
became a lot nicer when I decided to inherit MCELFStreamer and ELFObjectWriter. 
This was needed to make the debug information available to gdb since it expects 
ELF format. I basically reuse everything, the only thing that differs is that I 
use a mem_raw_outstream to emit code to memory and make sure that all sections 
are created before or during the post layout binding so that when 
RecordRelocation is called all symbol addresses are known. In the 
ELFObjectWriter, the code in WriteObject that creates sections is moved to the 
post layout binding, and the code that emits the object stays in place. This is 
perhaps not very clean, since it is not formalized in the interface, but it 
works okay and I only need to shuffle around the code a little. You could 
imagine that if section creation was restricted by the interface to only 
happenen before/during post layout, then a generic JunkJIT could be written for 
any object format. Each object writer would be required to compute offsets for 
the sections. I am currently not aiming to do this since the MCJIT proposal by 
Daniel separates the Streamer/ObjectWriter from figuring out relocations and 
external symbols. However, the code refactoring patches I have/will submit are 
fairly benign and enable a JIT (without lazy compilation) using the MC 
framework.

- Jan


----- Original Message ----
> From: Rafael Ávila de Espíndola <rafael.espindola at gmail.com>
> To: Jan Sjodin <jan_sjodin at yahoo.com>
> Cc: llvm-commits at cs.uiuc.edu
> Sent: Fri, February 25, 2011 7:15:27 PM
> Subject: Re: [llvm-commits] Code refactoring of MCELFStreamer.cpp and 
>ELFObjectWriter.cpp
> 
> On 2011-02-25 15:05, Jan Sjodin wrote:
> > Just to keep the code more  object-oriented. If a sub-class (I intend to 
>inherit 
>
> > from these  classes) needs the functions, they will not be available if they 
>are 
>
> >  hidden as static functions.
> 
> So you intent to move the ELFObjectWriter  class declaration to a header?
> I have the same question as Jason, what do you  want to do with it? :-)
> 
> > - Jan
> 
> Cheers,
> Rafael
> 




More information about the llvm-commits mailing list