https://sourceware.org/bugzilla/show_bug.cgi?id=33565
Bug ID: 33565
Summary: [RISC-V] Misleading info in relocation error message
after relaxation
Product: binutils
Version: 2.45
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: davidegrayson at gmail dot com
Target Milestone: ---
The GNU linker can display misleading error messages when a relocation
is moved due to RISC-V relaxations that happened before it.
In the example below, we have an invalid JAL relocation at label2, but
the linker incorrectly tells us the error is "in function _label1"
instead of "_label2". This seems to be happening because the address
of the invalid relocation was decreased by 4 due to a relaxation that
happened before it, and the code generating the error message is
probably looking at old symbol offsets that haven't been updated.
I think that errors like this should *only* use the offsets that were
present in the input file. This is similar to how a compiler works:
it reports code errors using the original line numbering of the input
file, not some processed version of the file.
This bug caused me to waste quite a bit of time trying to debug
some assembly code the other day. It was confusing because I
trused the "in function _label1" and then was surprised when
the error went away because I edited code outside of _label1.
I don't know if this bug applies to architectures other than RISC-V.
== err.asm ==
.text
.global _start
.type _start, @function
_start:
.option norelax
la gp, __global_pointer$
.option relax
call _label2
_label1:
nop
_label2:
jal 0x40000000 # THIS relocation is truncated to fit
== build.sh ==
riscv64-unknown-elf-as -mabi=ilp32 -march=rv32i err.asm -o err.o
riscv64-unknown-elf-ld -melf32lriscv --relax err.o -o err.elf
== error output ==
err.o: in function `_label1':
(.text+0x10): relocation truncated to fit: R_RISCV_JAL against `*UND*'
== expected error output ==
The correct output should include err.o, .text+0x14, and _label2.
--
You are receiving this mail because:
You are on the CC list for the bug.