https://sourceware.org/bugzilla/show_bug.cgi?id=34218
Bug ID: 34218
Summary: [RISC-V] GNU ld.bfd partial link loses start align
after relax
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
=======
GNU ld.bfd produces a final executable where symbol b0 moves from an
8-byte-aligned address in the single-stage link to a 4-byte-misaligned address
after the -r two-stage link.
Expected behavior
=================
A two-stage firmware link uses GNU ld -r before the final link; a non-relax
section starting with .balign 8 must stay aligned even when a preceding call is
relaxed.
Environment
===========
- product: binutils
- component: ld
- toolchain route: gas+ld.bfd single-stage vs gas+ld.bfd -r two-stage control
- march: rv64imac
- mabi: lp64
- first failing stage: link
Reduced testcase
================
--- a.S ---
.globl _start
_start:
call foo
.section .text1,"ax"
.globl foo
foo:
--- b.S ---
.option push
.option norelax
.balign 8
b0:
.word 0x3a393837
.option pop
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/two_stage_align_loss/run1..run3 show bfd-single placing b0 at
0x...b8 while bfd-two-stage places b0 at 0x...b4; the only semantic difference
is the introduction of a GNU ld -r stage before the final link.
Notes
=====
https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation
Root key: bfd.riscv.partial_link_loses_start_align_after_relax
Case id: 20260525-bfd-rv64-two-stage-align-loss
--
You are receiving this mail because:
You are on the CC list for the bug.