Comment 8 for bug 513735

Revision history for this message
Dave Martin (dave-martin-arm) wrote :

From http://llvm.org/bugs/show_bug.cgi?id=6223

Xerxes Rånby wrote:

> I am considering implementing the missing parts to make the
> thumb backend work with the ExecutionEngine JIT in order for
> the llvm JIT to be used on Ubuntu Lucid ARM that targets
> thumb2.
>
> see: llvm needs porting to thumb2
> https://bugs.launchpad.net/ubuntu/+source/llvm/+bug/513735
>
> Any pointers to how to implement the missing parts for the
> thumb JIT would be mosty welcome.
>
> I will start trying to add the missing machinecode fields for
> the JIT to use to the ARMInstrThumb.tb and ARMInstrThumb2.tb
> tablegen files.

Adding Thumb-2 JIT support is not necessarily required.

The real requirement is to implement ARM/Thumb interworking - for Ubuntu it sounds like this will be needed even if the JIT generates Thumb-2 code.

The reason for this is that direct symbol reference resolves to a PLT veneer generated at link time (always in ARM), whereas dlsym() will resolve directly to the target symbol in the containing shared library (which may be Thumb), as shown by the example below --- and it sounds like the llvm JIT output may need to handle both.

I documented some more detailed info on the porting requirements for ARM/Thumb interworking on https://wiki.ubuntu.com/ARM/Thumb2PortingHowto, which may help explain the implications and what porting is likely to be needed.

$ cat <<EOF | gcc -o dlsym-test -xc - -ldl && ./dlsym-test
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
int main(void)
{
    printf("printf = %p\ndlsym("printf") = %p\n", printf, dlsym(RTLD_NEXT, "printf"));
    return 0;
}
EOF

printf = 0x83a8
dlsym("printf") = 0x4006e1cd