bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/16017] LD creates invalid PLT instructions on CORTEX-M3


From: cvs-commit at gcc dot gnu.org
Subject: [Bug ld/16017] LD creates invalid PLT instructions on CORTEX-M3
Date: Wed, 01 Apr 2020 09:53:52 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=16017

--- Comment #29 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot 
gnu.org> ---
The master branch has been updated by Tamar Christina
<address@hidden>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a7618269b727da9cf56727c22cb538ff5f0e4d25

commit a7618269b727da9cf56727c22cb538ff5f0e4d25
Author: Tamar Christina <address@hidden>
Date:   Wed Apr 1 10:47:18 2020 +0100

    Arm: Fix LSB of GOT for Thumb2 only PLT.

    When you have a Thumb only PLT then the address in the GOT for PLT0 needs
to
    have the Thumb bit set since the instruction used in PLTn to get there is
    `ldr.w  pc` which is an inter-working instruction:

    the PLT sequence in question is

    00000120 <foo@plt>:
     120:   f240 0c98       movw    ip, #152        ; 0x98
     124:   f2c0 0c01       movt    ip, #1
     128:   44fc            add     ip, pc
     12a:   f8dc f000       ldr.w   pc, [ip]
     12e:   e7fc            b.n     12a <foo@plt+0xa>

    Disassembly of section .text:

    00000130 <bar>:
     130:   b580            push    {r7, lr}
     132:   af00            add     r7, sp, #0
     134:   f7ff fff4       bl      120 <foo@plt>

    and previously the linker would generate

    Hex dump of section '.got':
     ...
      0x000101b8 40010100 00000000 00000000 10010000 @...............

    Which would make it jump and transition out of thumb mode and crash since
you
    only have thumb mode on such cores.

    Now it correctly generates

    Hex dump of section '.got':
     ...
      0x000101b8 40010100 00000000 00000000 11010000 @...............

    Thanks to Amol for testing patch and to rgujju for reporting it.

    bfd/ChangeLog:

            PR ld/16017
            * elf32-arm.c (elf32_arm_populate_plt_entry): Set LSB of the PLT0
            address in the GOT if in thumb only mode.

    ld/ChangeLog:

            PR ld/16017
            * testsuite/ld-arm/arm-elf.exp (thumb-plt-got): New.
            * testsuite/ld-arm/thumb-plt-got.d: New test.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]