[LLVMdev] [Patch] Let MC/ELF generate Thumb/Thumb-2 are properly

Koan-Sin Tan koansin.tan at gmail.com
Thu May 12 22:42:40 PDT 2011


Hi,

We are trying to use clang as a drop-in replacement for the gcc come with
Android NDK. I found that MC/ELF doesn't not handle Thumb functions properly,
e.g., bit 0 of the function name in the .symtab is not set to 1, and some thumb
instructions are not generated correctly, e.g., the addresses for tBL/tBLX are
not calculated right.

With that attached patch, we can compile and run some (not all) Android
NDK samples without problem.

The attached initial patch
1. sets bit 0 of the function address of thumb function in .symtab
   ("T is 1 if the target symbol S has type STT_FUNC and the
   symbol addresses a Thumb instruction ;it is 0 otherwise."
   from "ELF for the ARM Architecture" 4.7.1.2)

2. fixes target address tBL and tBLX
3. sets relocation type of tBL/tBLX to R_ARM_THM_CALL
    (4.7.1.6)
4. adds some attributes to attribute section when cpu is "xscale"
   (this is what used in Android NDK, when architecture is ARMv5)

--
// koan-sin tan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-thumb-elf-hack.diff3
Type: application/octet-stream
Size: 6025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110513/81a8e782/attachment.obj>


More information about the llvm-dev mailing list