kvx bfd signed calculations and _bfd_kvx_elf_resolve_relocation
authorAlan Modra <amodra@gmail.com>
Tue, 22 Aug 2023 06:36:32 +0000 (16:06 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 23 Aug 2023 01:24:33 +0000 (10:54 +0930)
commitc5ed8c6376e755e0a138be4a30469caa6611a5f7
treea6e8056ce1fc561fca6cdb29a43f85b3c3aef6a9
parentd530ba0af9b7ffd41d93ce948af5e90c8610cf66
kvx bfd signed calculations and _bfd_kvx_elf_resolve_relocation

It is generally a good idea to avoid signed arithmetic on values
extracted from object files, to avoid ubsan warnings on overflow.
This patch replaces some uses of bfd_signed_vma in the kvx backend
with bfd_vma, and removes _bfd_kvx_elf_resolve_relocation, a
do-nothing function.  In the process of making this patch I noticed
some dead code in the GOT entry handling, setting value to
got_entry_addr but using "off" in the _bfd_final_link_relocate call.
Since kvx_calculate_got_entry_vma also returns the GOT offset, I
presume the code is correct, but I've left the dead code and comment
there.

* elfxx-kvx.h (_bfd_kvx_elf_resolve_relocation): Delete.
* elfxx-kvx.c (kvx_signed_overflow): Rewrite using unsigned
arithmetic.
(_bfd_kvx_elf_resolve_relocation): Delete.
* elfnn-kvx.c (kvx_relocate): Update for
_bfd_kvx_elf_resolve_relocation removal.
(elfNN_kvx_final_link_relocate): Likewise.  Don't use a signed
addend.
bfd/elfnn-kvx.c
bfd/elfxx-kvx.c
bfd/elfxx-kvx.h