[LLVMdev] Compiling user mode linux with LLVM

Andrew Lenharth andrewl at lenharth.org
Mon May 11 13:33:00 PDT 2009


On Thu, May 7, 2009 at 11:54 AM, Matt Renzelmann <mjr at cs.wisc.edu> wrote:
> I've recently started working on compiling UML with LLVM:  the goal is to
> produce a bitcode version of vmlinux.

I haven't tried UML, but I've produced (and run) native kernels with LVLM.

> As an experiment, I've tried using llc to convert the vmlinux.bc output into
> native assembly, then use "as" and "ld" to produce a native vmlinux, but the
> ld step fails with:
>
> ld: ./vmlinux_native.o: bad reloc symbol index (0x9c113c >= 0x4af6) for
> offset 0x18585 in section `.text'
> ./vmlinux_native.o: could not read symbols: Bad value

I'm not sure what this is about.

> I've not pursued this specific issue further since my goal is to run the
> bitcode directly, e.g. via lli.

You might contact Will Dietz (CC'ed) who has JITed the kernel.

> I'm also aware of the clever tricks the kernel uses that need to be
> addressed, mentioned in the second paragraph of Andrew's above reply.  As an
> example, the symbol __initcall_start is defined in a linker script
> (vmlinux.lds) and is used in the kernel as part of the initialization.
>
> Has anyone successfully modified the kernel initialization code to get UML
> working with LLVM?  If so, I'm interested in the approach taken so as to
> avoid wasting time.

You can easily write a script that walks the init sections and creates
a global array of function points that would normally be constructed
by the linker script.

Andrew




More information about the llvm-dev mailing list