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

            Bug ID: 34225
           Summary: [RISC-V] GNU ld.bfd absolute no relative PIE rewrites
                    required none placeholders to relative
           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
=======
Current GNU ld.bfd 2.45 links the legal PIE successfully but rewrites the two
required `R_RISCV_NONE` placeholders into two `R_RISCV_RELATIVE` dynamic
relocations with addends `0x1234` and `0x100`.

Expected behavior
=================
Link the official GNU `absolute-no-relative` PIE sample, which materializes two
link-time absolute symbols with `lga` inside ordinary startup code. The program
is meaningful and the upstream control treats the link as legal.

Environment
===========
- product: binutils
- component: ld
- toolchain route: GNU as plus current GNU ld.bfd 2.45 with official GNU ld
legality control
- march: rv64i
- mabi: lp64
- first failing stage: link

Reduced testcase
================
--- absolute-no-relative.d ---
#source: absolute-no-relative.s
#as:
#ld: -Tabsolute-no-relative.ld -pie
#readelf: -Wr

Relocation section '.rela.dyn' at .*
[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
0+[     ]+0+[   ]+R_RISCV_NONE[         ]+0
0+[     ]+0+[   ]+R_RISCV_NONE[         ]+0

--- absolute-no-relative.ld ---
ENTRY(_start)
SECTIONS {
        __symbol_abs__ = 0x1234;
        .text 0x10000 : { *(.text*)}
        .got  0x20000 : { *(.got*) }
}

--- absolute-no-relative.s ---
.text
.global _start
_start:
lga     x1, symbol_abs
lga     x1, __symbol_abs__

.global symbol_abs
.set symbol_abs, 0x100

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_absolute_no_relative_pie_rewrites_none_to_relative/run1..run3
are stable by hash. In every run, `asm.rc.txt` is 0, `bfd.pie.rc.txt` is 0, and
`out.pie.relocs.txt` contains exactly the same two `R_RISCV_RELATIVE` entries
instead of the two `R_RISCV_NONE` placeholders required by the upstream GNU
control `absolute-no-relative.d`. This root is distinct from the existing
ld.lld omission bug because current ld.bfd does emit dynamic relocations here,
but rewrites their required type incorrectly.

Notes
=====
upstream/binutils-gdb/ld/testsuite/ld-riscv-elf/absolute-no-relative.s;
D:/search_ascii/upstream/binutils-gdb/ld/testsuite/ld-riscv-elf/absolute-no-relative.ld;
D:/search_ascii/upstream/binutils-gdb/ld/testsuite/ld-riscv-elf/absolute-no-relative.d

Root key:
bfd.riscv.absolute_no_relative_pie_rewrites_required_none_placeholders_to_relative
Case id: 20260528-bfd-absolute-no-relative-wrong-success

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

Reply via email to