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

            Bug ID: 34222
           Summary: [RISC-V] GNU ld.bfd wrap after partial link keeps
                    stale foo value
           Product: binutils
           Version: 2.45
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: l784896635 at gmail dot com
  Target Milestone: ---

I ran into this while reducing a RISC-V linker testcase. The reproducer is
already quite small, and I have been seeing the same result consistently across
three reruns.

Summary
=======
After a.o and b.o are partially linked with ld -r, GNU ld.bfd leaves _start
calling foo directly in the final --wrap=foo link, while ld.lld on the same
ab.o + w.o input redirects _start to __wrap_foo.

Expected behavior
=================
A final link applies --wrap=foo after a prior ld -r step that combined the
caller and the original foo definition. The wrapped call from _start should
still be redirected to __wrap_foo.

Environment
===========
- product: binutils
- component: ld
- toolchain route: gas+ld.bfd with gas+ld.lld control
- march: rv64imac
- mabi: lp64
- first failing stage: link

Reduced testcase
================
--- a.s ---
.globl _start
_start:
  call foo

--- b.s ---
.globl foo
foo:
  call __wrap_foo

--- w.s ---
.globl __wrap_foo
__wrap_foo:
  call __real_foo

Reproduction notes
==================
- This packaged root does not have a single canonical `run.ps1` wrapper.
- Use the reduced inputs under `case/` and follow the commands documented in
`case/README.md`.
- Stable witness outputs, when present, are preserved under
`verify/run1..run3/`.

What I checked
==============
- Reduced inputs are preserved under case/.
- Stable witness outputs are preserved under verify/run1..run3/.
- The strict recheck says stable normalized run signatures across three runs:
True.
- Tracker guidance link:
https://sourceware.org/binutils/docs/ld/Bug-Reporting.html
- evidence summary: 3 clean reproductions under
hunt/verify/bfd_wrap_partial_link/run1..run3 show stable ld.bfd output with
_start: jal foo and ld.lld control output with _start: jal __wrap_foo from the
same partially linked ab.o input.

Notes
=====
upstream///llvm-project/lld/test/ELF/riscv-relax-wrap.s

Root key: bfd.riscv.wrap_after_partial_link_keeps_stale_foo_value
Case id: 20260525-bfd-wrap-partial-link

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

Reply via email to