Re: [RFC 21/31] objtool: Fix x86 addend calcuation

laokz
2024-09-04T09:37:59Z

On Mon, 2024-09-02 at 21:00 -0700, Josh Poimboeuf wrote:
> arch_dest_reloc_offset() hard-codes the addend adjustment to 4, which
> isn't always true.  In fact it's dependent on the instruction itself.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
>  tools/objtool/arch/loongarch/decode.c |  4 ++--
>  tools/objtool/arch/powerpc/decode.c   |  4 ++--
>  tools/objtool/arch/x86/decode.c       | 15 +++++++++++++--
>  tools/objtool/check.c                 | 13 ++++---------
>  tools/objtool/include/objtool/arch.h  |  2 +-
>  5 files changed, 22 insertions(+), 16 deletions(-)
>
> diff --git a/tools/objtool/arch/loongarch/decode.c
> b/tools/objtool/arch/loongarch/decode.c
> index ef09996c772e..b5d44d7bce4e 100644
> --- a/tools/objtool/arch/loongarch/decode.c
> +++ b/tools/objtool/arch/loongarch/decode.c
> @@ -20,9 +20,9 @@ unsigned long arch_jump_destination(struct
> instruction *insn)
>         return insn->offset + (insn->immediate << 2);
>  }
>
> -unsigned long arch_dest_reloc_offset(int addend)
> +s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc
> *reloc)
>  {
> -       return addend;
> +       return reloc_addend(addend);

reloc_addend(reloc) ?