[llvm-bugs] [Bug 33612] New: ARM: Add range thunk support to avoid relocation R_ARM_THM_CALL out of range

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 27 08:34:23 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33612

            Bug ID: 33612
           Summary: ARM: Add range thunk support to avoid relocation
                    R_ARM_THM_CALL out of range
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: peter.smith at linaro.org
                CC: llvm-bugs at lists.llvm.org

The range of ARM branch instructions is limited. The ABI allows object
producers to assume that a linker can extend the range of branches via the use
of range extension thunks/stubs/veneers. These are pieces of code that are
inserted between branches that turn a range limited direct call into (usually)
an indirect call via the register r12 (ABI reserved).

lld does not currently implement range extension thunks so we can quite easily
write a program that has a relocation out of range error.

        .syntax unified
        .thumb
        .section .text.1 ,"ax", %progbits
        .global low
        .type low, %function
low:
        bl high
        bx lr
        // Thumb2 branch range is 16Mb
        .space 20 * 1024 * 1024

        .section .text.2 ,"ax", %progbits
        .global high
        .type high, %function
high:
        bl low
        bx lr

llvm-mc -triple=armv7a-linux-gnueabihf long.s -filetype=obj -o long.o
ld.lld long.o -o long.axf
error: long.o:(.text.2+0x0): relocation R_ARM_THM_CALL out of range
error: long.o:(.text.1+0x0): relocation R_ARM_THM_CALL out of range


Range thunks are currently in review, this pr is here so that if people run
into the relocation R_ARM_THM_CALL they know that work is in progress to
support it.

Initial set of upstream Reviews:
D34035 [LLD][ELF] Introduce Thunk reuse compatibility (1/11).
D34037 [LLD][ELF] Allow multiple thunks to be added for a symbol. (2/11)
D34344 [LLD][ELF] Extract allocateHeaders() from assignAddresses() (3/11)
D34345 [LLD][ELF] Reset any accumulated state before calculating addresses
(4/11)
D34688 [LLD][ELF] Add call to assignAddresses() before createThunks() [NFC]
(5/11)
D34689 [LLD][ELF] Pre-create ThunkSections at Target specific intervals (6/11)
D34690 [LLD][ELF] Introduce target specific inBranchRange() function (7/11)
D34691 [LLD][ELF] Introduce range extension thunks for ARM (8/11)
D34692 [LLD][ELF] Add support for multiple passes to createThunks() (9/11)
D31666 [LLD][ELF] Add test cases for range extension thunks using linker
scripts (10/11)
D31665 [LLD][ELF] Add test cases for range extension thunks (no linkerscripts)
(11/11)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170627/490b3bde/attachment.html>


More information about the llvm-bugs mailing list