[llvm-bugs] [Bug 36927] New: 16-bit relocation problem (ELF32)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 27 19:49:08 PDT 2018


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

            Bug ID: 36927
           Summary: 16-bit relocation problem (ELF32)
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: nruslan_devel at yahoo.com
                CC: llvm-bugs at lists.llvm.org

Consider the following example

test.S:

.code16
.global _start
_start:
    movw $_start+0x8300,%ax

Basically, it is 16-bit code inside ELF32. _start is 0x7C00. Therefore, the
instruction will use 0x7C00+0x8300=0xFF00 (i.e., still fits in a 16-bit
relocation).

1. Compile with clang:
clang -c -Wall -O2 -m32 test.S -o test.o

2. GNU linker works fine:
ld -melf_i386 -Ttext 0x7c00 -s --oformat binary test.o

and generates expected code: 0xB8 0x00 0xFF

3. However, ld.lld linker incorrectly calculates the relocation in this case
(it works with smaller offsets, though):

ld.lld -melf_i386 -Ttext 0x7c00 -s --oformat binary test.o
ld.lld: error: test.o:(.text+0x1): relocation R_386_16 out of range:
18446744073709551360 is not in [0, 65535]

-- 
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/20180328/ae21a48e/attachment.html>


More information about the llvm-bugs mailing list