[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/25181] RISC-V: Linker relaxation may fail if there are R_R

From: wilson at gcc dot gnu.org
Subject: [Bug binutils/25181] RISC-V: Linker relaxation may fail if there are R_RISCV_ALIGN type relocations
Date: Tue, 12 Nov 2019 00:03:59 +0000


Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-11-12
                 CC|                            |wilson at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #4 from Jim Wilson <wilson at gcc dot gnu.org> ---
The way that this should work is that if the call crosses section boundaries,
then we need to use the max alignment of any section between the call
instruction and the target, including the call and target sections.  Except we
don't have code to compute that yet, so we just use the maximum alignment of
all sections in the output.  If the call does not cross section boundaries,
then it should only use the alignment of the section it is in.  This alignment
value is added in to the offset to make sure that we don't relax something that
might not fit after alignment is handled.  This has the downside that sometimes
we refuse to relax something that might be relaxable because of a section with
large alignment constraint.  But it is safe, in that we never accidentally
relax something that should not be relaxed.

This is how _bfd_riscv_relax_lui and _bfd_riscv_relax_pc work.  They use
max_alignment unconditionally, and set max_alignment to the section alignment
if the lui and gp are in the same section and it isn't the abs section.

This is unfortunately not how _bfd_riscv_relax_call works.  It only adds in the
alignment if the call and target are not in the same section.  I'd call this a
bug and that it needs to work the same as the other two functions.

I attached a proposed patch that fixes _bfd_riscv_relax_call and adds your
example as a testcase.

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]