Re: [PATCH] RISC-V: Check all referring LOs before relaxing the PC-relative HI
Luke Zhuang
luke.zhuang@linux.alibaba.com
Sat Nov 28 12:36:14 GMT 2026
> Hi Zhuang,
>
> Thanks for the new update, This fixes the mixed-marker case. However, I
> can still reproduce the same "missing matching %pcrel_hi"
>
> diagnostic with both relocations marked and both addends zero. The HI
> label can be a local function symbol with a nonzero st_size, for example:
>
> .type load_data,@function
> load_data:
> auipc t0,%pcrel_hi(target)
> lw a0,%pcrel_lo(load_data)(t0)
> ret
> .size load_data,.-load_data
>
> With a 4-byte target at 'gp + 0x7f4', the HI passes the GP range check
> using the target's size. The LO then uses the 12-byte size of
>
> 'load_data' and fails the same check after the HI has been selected for
> deletion.
>
> Could we restore the 'reserve_size' here as well, may like:
>
> hi_reloc = *hi;
> symval = hi_reloc.hi_addr;
> sym_sec = hi_reloc.sym_sec;
> reserve_size = hi_reloc.reserve_size;
>
> And I think we also check each LO's effective target before deleting the
> HI? Here 'symval' already includes the HI addend, so the address to check is
> 'symval + lo->rel->r_addend'.
> For example, with target = 0x7fc, a load at target fits an x0-relative
> immediate, but a store at target + 8 does not. If any LO cannot reach
> its effective
> target from either available base, please keep the original group.
>
> Thanks,
> Jiawei
Hi Jiawei,
Thank you for the comments! Yes I agree that we need to fix both issues.
For the reserve_size issue, we need to keep HI/LO checkes consistent.
For the other one, yes we need to check each referring LO can actually
be relaxed when handling HI, not only just checking the mark.
My first instinct is that we need to refactor the checking part out, which can be
reused both in the original check-LO-path and the new check-LO-before-HI path.
I'll work on it and submit improvements soon, if you agree with that :)
And again, thanks for catching those I've overlooked!
Best,
Luke Zhuang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20261128/831dfa0d/attachment.htm>
More information about the Binutils
mailing list