[llvm-dev] Generating completely position agnostic code

Jonathan Smith via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 1 03:45:18 PDT 2019


I'd definitely like to throw my vote behind this. I've managed to
write what are effectively bare-metal BIOS bootloaders for dedicated
tasks on x86 using LLVM, but I did have to modify the x86 backend to
achieve it, and it isn't complete. Most of the work came down to
modifying the functions that handle reference classification.
Combining this with building via lld and code extraction via objcopy
allows me to do most of what I need. That said, this is from C code,
not C++; I'd be really interested to see it working with C++, but
complex static initialization seems to be a difficult problem in that
regard.

On Mon, Jul 1, 2019 at 12:08 AM Hayden Livingston via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> I'm on a mission to generate code that can be loaded from disk without
> any modifications. This means no relocations can occur.
>
> Trying to see if this can be done for C++ code that uses STL but has
> no global variables, and a single function, but of course Clang will
> generate more functions for STL code.
>
> I want to provide an array of function pointers so that for all
> interactions STL needs to do with LIBC that I'm able to just provide
> it via indirect calls.
>
> Has anyone had success with such a thing in LLVM?
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list