]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
LoongArch: Fix symbol size after relaxation
authorXi Ruoyao <xry111@xry111.site>
Wed, 6 Aug 2025 04:19:22 +0000 (12:19 +0800)
committercailulu <cailulu@loongson.cn>
Thu, 7 Aug 2025 01:21:38 +0000 (09:21 +0800)
commit3eede6b04a30243fdc4acece156be95b17c16f83
treec0da5f315d3bcf6e91065847c84b4a789d8dd482
parent081bf6a3a18da20293693bf30617c5736ef270bc
LoongArch: Fix symbol size after relaxation

There's a logic error in loongarch_relax_perform_deletes: when there's
not any delete operation of which the start address is strictly smaller
than the symbol address, splay_tree_predecessor() will return nullptr
and the symbol size will be unchanged even if some bytes of it are
removed.

Make the logic more complete to fix this issue.  Also factor out the
symbol size adjustment logic into a function to avoid code bloating.

Tested-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
bfd/elfnn-loongarch.c
ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
ld/testsuite/ld-loongarch-elf/relax-sym-size-1.d [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax-sym-size-1.s [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax-sym-size-2.d [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax-sym-size-2.s [new file with mode: 0644]