https://sourceware.org/bugzilla/show_bug.cgi?id=34221
Bug ID: 34221
Summary: [RISC-V] GNU ld.bfd weaker align reloc suppresses
stronger norelax balign
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 links valid input where align_e.o itself has e0 at offset 0x8, but
final output moves e0 to 0x1000e in one-stage links and 0x1000a after -r plus
final link because only the weak ALIGN 2 survives and the later norelax balign
8 is not preserved.
Expected behavior
=================
An input object starts with a legacy-style explicit R_RISCV_ALIGN addend 2 and
later contains a stronger .option norelax .balign 8 before local symbol e0. The
linker must not let the weaker ALIGN consume padding in a way that breaks the
later 8-byte alignment requirement.
Environment
===========
- product: binutils
- component: ld
- toolchain route: gas+ld.bfd
- march: rv64imac
- mabi: lp64
- first failing stage: link
Reduced testcase
================
--- align_a.s ---
.globl _start
_start:
call foo
.section .text1,"ax"
.globl foo
foo:
call foo
--- align_e.s ---
.reloc ., R_RISCV_ALIGN, 2
c.nop
.option push
.option norelax
.balign 8
e0:
.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/align_weaker_explicit_suppresses_stronger_balign/run1..run3 show
stable input offset e0=0x8, bfd one-stage output e0=0x1000e, bfd two-stage
output e0=0x1000a, and bfd partial-link relocations containing only the weak
R_RISCV_ALIGN 2.
Notes
=====
upstream///llvm-project/lld/test/ELF/riscv-relocatable-align.s (CHECK3-inspired
reduction)
Root key: bfd.riscv.weaker_align_reloc_suppresses_stronger_norelax_balign
Case id: 20260525-bfd-weaker-align-suppresses-stronger-balign
--
You are receiving this mail because:
You are on the CC list for the bug.