bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/32659] New: Bad PLT asm generated on ARM thumb with PIC and LTO


From: clyon at gcc dot gnu.org
Subject: [Bug ld/32659] New: Bad PLT asm generated on ARM thumb with PIC and LTO
Date: Fri, 07 Feb 2025 16:35:25 +0000

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

            Bug ID: 32659
           Summary: Bad PLT asm generated on ARM thumb with PIC and LTO
           Product: binutils
           Version: 2.45 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: clyon at gcc dot gnu.org
  Target Milestone: ---

As reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118715 we have a
case where the linker generates the PLT at the wrong offset.


$ cat pr118715.c
extern void foo(void);
void _start(void) {
    foo();
}

$ arm-eabi-gcc -O2 -Wall -Wextra -fPIC -ffreestanding -nostdlib -mthumb
-mcpu=cortex-m4 --entry=_start -shared pr118715.c -o pr118715.exe.lto  -flto 
-save-temps

$ arm-eabi-objdump -rdth ./pr118715.exe.lto
[...]
00000168 <foo@plt>:
 168:   0000            movs    r0, r0
 16a:   0000            movs    r0, r0
 16c:   f241 0c88       movw    ip, #4232       @ 0x1088
 170:   f2c0 0c00       movt    ip, #0
 174:   44fc            add     ip, pc
 176:   Address 0x176 is out of bounds.


The problem is that elf32_arm_create_dynamic_sections is called with a BFD
pointing to pr118715.exe.lto-pr118715.o, after plugin_object_p has called
bfd_make_readable (abfd);

pr118715.exe.lto-pr118715.o contains an attributes section, but
bfd_make_readable replaces it with an empty one.

So when elf32_arm_create_dynamic_sections calls using_thumb_only, there's no
profile info, so using_thumb_only returns false and htab->plt_header_size /
htab->plt_entry_size are not adjusted as they should.

Later calls to using_thumb_only correctly see that M profile is used, and
return true.

What's the best way to make sure the attributes section is kept?

-- 
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]