Clang, LTO and linking x86_64 with i386

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Clang, LTO and linking x86_64 with i386

Adam Cieszkiel via cfe-dev
Hi folks

I have an OS for x86_64. Intel hardware has a requirement that early
boot stage can use 32bit instructions only. So I have a boot.c file
that I compile with -m32. Now I want to link it with 64bit code that
the rest of the OS uses. Linkers (at least LD) does not allow to link
different architectures. Thus I have to use a trick with 'objcopy' to
convert elf32 object file into elf64 (objcopy -O elf64-x86-64). It
works with clang if I do not use LTO (I tested the output binary with
KVM/VmWare and bare metal).

Now I want to enable LTO for my project. Unfortunately object files
compiled with 'clang -flto' have different type:

 file arch/x86/start.o32
 arch/x86/start.o32: LLVM IR bitcode

And it confuses 'objcopy'

objcopy:start.o32: File format not recognized


So my question here: is there a way to enable LTO in a project that
tries to link 32bit and 64bit object files? Is there other way to
achieve it without using 'objcopy'?
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...