[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241127005806.3w7se42s5nqx4ss3@jpoimboe>
Date: Tue, 26 Nov 2024 16:58:06 -0800
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Huacai Chen <chenhuacai@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 04/10] objtool: Handle PC relative relocation type
On Tue, Nov 26, 2024 at 09:24:59PM +0800, Tiezhu Yang wrote:
> On 11/26/2024 07:00 PM, Tiezhu Yang wrote:
> > > Maybe there should be an arch-specific function arch_adjusted_addend().
>
> Add adjust_offset() in
> tools/objtool/include/objtool/elf.h,
> like this:
>
> static inline unsigned long adjust_offset(struct elf *elf, struct reloc
> *reloc,
> unsigned long offset)
> {
> if (elf->ehdr.e_machine == EM_LOONGARCH && reloc_type(reloc) ==
> R_LARCH_32_PCREL)
> offset = reloc->sym->offset + reloc_addend(reloc) -
> (reloc_offset(reloc) - reloc_offset(table));
>
> return offset;
> }
>
> then call it in check.c, like this:
>
> offset = reloc->sym->offset + reloc_addend(reloc);
> offset = adjust_offset(file->elf, reloc, offset);
>
> What do you think?
Similar to reloc_size() I'm thinking this should also be in
arch-specific decode.c.
--
Josh
Powered by blists - more mailing lists