[llvm] r307713 - [ARM, ELF] Don't shift movt relocation offsets

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 18:42:59 PDT 2017


Sorry, just noticed that it's fixed with r307728

On Tue, Jul 11, 2017 at 6:38 PM, Vitaly Buka <vitalybuka at google.com> wrote:

> Revert conflicts with r307730
> maybe update of arm-mov-relocs.s is enough?
>
> On Tue, Jul 11, 2017 at 5:32 PM, Vitaly Buka <vitalybuka at google.com>
> wrote:
>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6341/steps/check-lld%20asan/logs/stdio
>>
>> FAIL: lld :: ELF/arm-mov-relocs.s (207 of 1213)
>> ******************** TEST 'lld :: ELF/arm-mov-relocs.s' FAILED ********************
>> Script:
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llvm-mc -filetype=obj -triple=armv7a-unknown-linux-gnueabi /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/arm-mov-relocs.s -o /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/ld.lld --full-shutdown /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp -o /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp2
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llvm-objdump -d /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp2 -triple=armv7a-unknown-linux-gnueabi | /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/arm-mov-relocs.s
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llvm-mc -filetype=obj -triple=thumbv7a-unknown-linux-gnueabi /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/arm-mov-relocs.s -o /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp3
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/ld.lld --full-shutdown /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp3 -o /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp4
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llvm-objdump -d /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/lld/test/ELF/Output/arm-mov-relocs.s.tmp4 -triple=thumbv7a-unknown-linux-gnueabi | /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/arm-mov-relocs.s
>> --
>> Exit Code: 1
>>
>> Command Output (stderr):
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/lld/test/ELF/arm-mov-relocs.s:42:11: error: expected string not found in input
>> // CHECK: movt r4, #3
>>           ^
>> <stdin>:17:2: note: scanning from here
>>  11024: 02 40 40 e3 movt r4, #2
>>  ^
>> <stdin>:17:21: note: possible intended match here
>>  11024: 02 40 40 e3 movt r4, #2
>>                     ^
>>
>>
>> On Tue, Jul 11, 2017 at 2:07 PM, Martin Storsjo via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: mstorsjo
>>> Date: Tue Jul 11 14:07:10 2017
>>> New Revision: 307713
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=307713&view=rev
>>> Log:
>>> [ARM, ELF] Don't shift movt relocation offsets
>>>
>>> For ELF, a movw+movt pair is handled as two separate relocations.
>>> If an offset should be applied to the symbol address, this offset is
>>> stored as an immediate in the instruction (as opposed to stored as an
>>> offset in the relocation itself).
>>>
>>> Even though the actual value stored in the movt immediate after linking
>>> is the top half of the value, we need to store the unshifted offset
>>> prior to linking. When the relocation is made during linking, the offset
>>> gets added to the target symbol value, and the upper half of the value
>>> is stored in the instruction.
>>>
>>> This makes sure that movw+movt with offset symbols get properly
>>> handled, in case the offset addition in the lower half should be
>>> carried over to the upper half.
>>>
>>> This makes the output from the additions to the test case match
>>> the output from GNU binutils.
>>>
>>> For COFF and MachO, the movw/movt relocations are handled as a pair,
>>> and the overflow from the lower half gets carried over to the movt,
>>> so they should keep the shifted offset just as before.
>>>
>>> Differential Revision: https://reviews.llvm.org/D35242
>>>
>>> Modified:
>>>     llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
>>>     llvm/trunk/test/MC/ARM/elf-movt.s
>>>
>>> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AR
>>> M/MCTargetDesc/ARMAsmBackend.cpp?rev=307713&r1=307712&r2=307
>>> 713&view=diff
>>> ============================================================
>>> ==================
>>> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (original)
>>> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp Tue Jul 11
>>> 14:07:10 2017
>>> @@ -392,7 +392,7 @@ unsigned ARMAsmBackend::adjustFixupValue
>>>    case FK_SecRel_4:
>>>      return Value;
>>>    case ARM::fixup_arm_movt_hi16:
>>> -    if (!IsPCRel)
>>> +    if (!IsPCRel && !STI->getTargetTriple().isOSBinFormatELF())
>>>        Value >>= 16;
>>>      LLVM_FALLTHROUGH;
>>>    case ARM::fixup_arm_movw_lo16: {
>>> @@ -404,7 +404,7 @@ unsigned ARMAsmBackend::adjustFixupValue
>>>      return Value;
>>>    }
>>>    case ARM::fixup_t2_movt_hi16:
>>> -    if (!IsPCRel)
>>> +    if (!IsPCRel && !STI->getTargetTriple().isOSBinFormatELF())
>>>        Value >>= 16;
>>>      LLVM_FALLTHROUGH;
>>>    case ARM::fixup_t2_movw_lo16: {
>>>
>>> Modified: llvm/trunk/test/MC/ARM/elf-movt.s
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/e
>>> lf-movt.s?rev=307713&r1=307712&r2=307713&view=diff
>>> ============================================================
>>> ==================
>>> --- llvm/trunk/test/MC/ARM/elf-movt.s (original)
>>> +++ llvm/trunk/test/MC/ARM/elf-movt.s Tue Jul 11 14:07:10 2017
>>> @@ -14,8 +14,12 @@ barf:
>>>         movw    r0, :lower16:GOT-(.LPC0_2+8)
>>>         movt    r0, :upper16:GOT-(.LPC0_2+8)
>>>  .LPC0_2:
>>> +       movw    r0, :lower16:extern_symbol+1234
>>> +       movt    r0, :upper16:extern_symbol+1234
>>>  @ ASM:          movw    r0, :lower16:(GOT-(.LPC0_2+8))
>>>  @ ASM-NEXT:     movt    r0, :upper16:(GOT-(.LPC0_2+8))
>>> +@ ASM:          movw    r0, :lower16:(extern_symbol+1234)
>>> +@ ASM-NEXT:     movt    r0, :upper16:(extern_symbol+1234)
>>>
>>>  @OBJ:      Disassembly of section .text:
>>>  @OBJ-NEXT: barf:
>>> @@ -23,6 +27,10 @@ barf:
>>>  @OBJ-NEXT: 00000000:         R_ARM_MOVW_PREL_NC   GOT
>>>  @OBJ-NEXT: 4:             f4 0f 4f e3     movt    r0, #65524
>>>  @OBJ-NEXT: 00000004:         R_ARM_MOVT_PREL      GOT
>>> + at OBJ-NEXT: 8:             d2 04 00 e3     movw    r0, #1234
>>> + at OBJ-NEXT: 00000008:         R_ARM_MOVW_ABS_NC    extern_symbol
>>> + at OBJ-NEXT: c:             d2 04 40 e3     movt    r0, #1234
>>> + at OBJ-NEXT: 0000000c:         R_ARM_MOVT_ABS       extern_symbol
>>>
>>>  @THUMB:      Disassembly of section .text:
>>>  @THUMB-NEXT: barf:
>>> @@ -30,3 +38,7 @@ barf:
>>>  @THUMB-NEXT: 00000000:         R_ARM_THM_MOVW_PREL_NC GOT
>>>  @THUMB-NEXT: 4:             cf f6 f4 70     movt    r0, #65524
>>>  @THUMB-NEXT: 00000004:         R_ARM_THM_MOVT_PREL    GOT
>>> + at THUMB-NEXT: 8:             40 f2 d2 40     movw    r0, #1234
>>> + at THUMB-NEXT: 00000008:         R_ARM_THM_MOVW_ABS_NC  extern_symbol
>>> + at THUMB-NEXT: c:             c0 f2 d2 40     movt    r0, #1234
>>> + at THUMB-NEXT: 0000000c:         R_ARM_THM_MOVT_ABS     extern_symbol
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170711/45d390fe/attachment.html>


More information about the llvm-commits mailing list