[llvm-bugs] [Bug 32924] New: Unsupported SBREL32 relocation emitted by LLVM

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 4 09:06:27 PDT 2017


            Bug ID: 32924
           Summary: Unsupported SBREL32 relocation emitted by LLVM
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: amit at amitlevy.com
                CC: compnerd at compnerd.org, llvm-bugs at lists.llvm.org

Created attachment 18409
  --> https://bugs.llvm.org/attachment.cgi?id=18409&action=edit
C test file

I'm trying to compile bare-metal relocatable binaries for Thumb using
the RWPI/ROPI relocation models in the recently released version 4. The
code is coming out great from clang as well as Rust.

However, I'm unable to link this code since LLD seems to be
missing support for the ARM relocation type R_ARM_SBREL32 (relocation
type 9 in
which is emitted by LLVM for the RWPI relocation model.

I believe the relevant function in LLD is here:

I'm attaching a very simple file, `test.c`, which simply dereferences a
global volatile int in `_start`. The assembly equivalent with the failing
relocation is:

        .syntax unified
        .eabi_attribute 67, "2.09"      @ Tag_conformance
        .cpu    arm7tdmi
        .eabi_attribute 6, 2    @ Tag_CPU_arch
        .eabi_attribute 8, 1    @ Tag_ARM_ISA_use
        .eabi_attribute 15, 2   @ Tag_ABI_PCS_RW_data
        .eabi_attribute 16, 1   @ Tag_ABI_PCS_RO_data
        .eabi_attribute 17, 1   @ Tag_ABI_PCS_GOT_use
        .eabi_attribute 20, 1   @ Tag_ABI_FP_denormal
        .eabi_attribute 21, 1   @ Tag_ABI_FP_exceptions
        .eabi_attribute 23, 3   @ Tag_ABI_FP_number_model
        .eabi_attribute 34, 0   @ Tag_CPU_unaligned_access
        .eabi_attribute 24, 1   @ Tag_ABI_align_needed
        .eabi_attribute 25, 1   @ Tag_ABI_align_preserved
        .eabi_attribute 38, 1   @ Tag_ABI_FP_16bit_format
        .eabi_attribute 18, 4   @ Tag_ABI_PCS_wchar_t
        .eabi_attribute 26, 2   @ Tag_ABI_enum_size
        .eabi_attribute 14, 1   @ Tag_ABI_PCS_R9_use
        .file   "test.c"
        .globl  _start
        .p2align        2
        .type   _start,%function
        .code   32                      @ @_start
@ BB#0:
        ldr     r0, .LCPI0_0
        mov     r1, r9
        ldr     r0, [r1, r0]
        bx      lr
        .p2align        2
@ BB#4:
        .long   foo(sbrel)

Compiling it without RWPI relocations
works as expected:

$ clang --target=thumbv7-eabi -fropi -o test.o -c test.c
$ ld.lld -o test test.o

However, compiling with RWPI turned on errors with `unrecognized reloc
9` from LLD:

$ clang --target=thumbv7-eabi -fropi -frwpi -o test.o -c test.c
$ ld.lld -o test test.o
ld.lld: error: test.c:(function _start): unrecognized reloc 9

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/20170504/86e64add/attachment.html>

More information about the llvm-bugs mailing list