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

            Bug ID: 34750
           Summary: ld: ARM attributes lost from LTO dummy objects during
                    bfd_make_readable
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: torbjorn.svensson at foss dot st.com
  Target Milestone: ---

This is a follow-up to the ARM PLT sizing issue discussed here:
https://sourceware.org/pipermail/binutils/2026-October/152119.html

While debugging that problem, I noticed that the dummy objects created by ld
for LTO inputs lose their ARM attributes.

I set breakpoints in LLDB with:

(lldb) breakpoint set --name plugin_get_ir_dummy_bfd
(lldb) breakpoint set --name bfd_make_readable

At entry to plugin_get_ir_dummy_bfd for the input in question, I checked its
name and attributes:

(lldb) expression -- int $Tag_CPU_arch = 6
(lldb) expression -- int $Tag_CPU_arch_profile = 7
(lldb) p srctemplate->filename
(const char *) 0x0000621000012d10 "cp_lto_pr87906_0.o"
(lldb) p (void *) bfd_get_section_by_name(srctemplate, ".ARM.attributes")
(void *) 0x000062100001b0b8
(lldb) p (int) bfd_elf_get_obj_attr_int(srctemplate, 0, $Tag_CPU_arch)
(int) 10
(lldb) p (int) bfd_elf_get_obj_attr_int(srctemplate, 0, $Tag_CPU_arch_profile)
(int) 77
(lldb) continue

At the stop in bfd_make_readable for the corresponding plugin dummy object, I
saved its pointer and checked its name and attributes before and after stepping
out:

(lldb) expression -- struct bfd *$lto_dummy = abfd
(lldb) p $lto_dummy->filename
(const char *) 0x000062100001cd10 "cp_lto_pr87906_0.o (symbol from plugin)"
(lldb) p (void *) bfd_get_section_by_name($lto_dummy, ".ARM.attributes")
(void *) 0x0000000000000000
(lldb) p (int) bfd_elf_get_obj_attr_int($lto_dummy, 0, $Tag_CPU_arch)
(int) 10
(lldb) p (int) bfd_elf_get_obj_attr_int($lto_dummy, 0, $Tag_CPU_arch_profile)
(int) 77
(lldb) thread step-out
(lldb) p (int) bfd_elf_get_obj_attr_int($lto_dummy, 0, $Tag_CPU_arch)
(int) 0
(lldb) p (int) bfd_elf_get_obj_attr_int($lto_dummy, 0, $Tag_CPU_arch_profile)
(int) 0

This seems to account for the missing attributes seen by the ARM backend.
Applying the PLT sizing fix does not prevent the attributes from being lost.

I have only checked ARM, but I think the dummy-object handling is shared with
other ELF targets, so they may lose their attributes in the same way.

I observed this while debugging on macOS/AArch64, targeting arm-none-eabi.

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

Reply via email to