[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tvf7obye6afduyyefjrgicut2ehtyy4dkabxzxudtb55njsoba@4bhwzl3ftxeo>
Date: Wed, 4 Jun 2025 16:53:05 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
Petr Mladek <pmladek@...e.com>, Miroslav Benes <mbenes@...e.cz>,
Joe Lawrence <joe.lawrence@...hat.com>, live-patching@...r.kernel.org, Song Liu <song@...nel.org>,
laokz <laokz@...mail.com>, Jiri Kosina <jikos@...nel.org>,
Marcos Paulo de Souza <mpdesouza@...e.com>, Weinan Liu <wnliu@...gle.com>,
Fazla Mehrab <a.mehrab@...edance.com>, Chen Zhongjin <chenzhongjin@...wei.com>,
Puranjay Mohan <puranjay@...nel.org>
Subject: Re: [PATCH v2 18/62] objtool: Fix x86 addend calculation
On Mon, May 26, 2025 at 12:23:15PM +0200, Peter Zijlstra wrote:
> On Fri, May 09, 2025 at 01:16:42PM -0700, Josh Poimboeuf wrote:
> > On x86, arch_dest_reloc_offset() hardcodes the addend adjustment to
> > four, but the actual adjustment depends on the relocation type. Fix
> > that.
>
> > +s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *reloc)
> > {
> > - return addend + 4;
> > + s64 addend = reloc_addend(reloc);
> > +
> > + switch (reloc_type(reloc)) {
> > + case R_X86_64_PC32:
> > + case R_X86_64_PLT32:
> > + addend += insn->offset + insn->len - reloc_offset(reloc);
> > + break;
> > + default:
> > + break;
> > + }
> > +
> > + return addend;
> > }
>
> Should this not be something like:
>
> s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *reloc)
> {
> s64 addend = reloc_addend(reloc);
>
> if (arch_pc_relative_reloc(reloc))
> addend += insn->offset + insn->len - reloc_offset(reloc);
>
> return addend;
> }
>
> instead?
>
> AFAIU arch_pc_relative_reloc() is the exact same set of relocations.
Yeah that's better, thanks.
--
Josh
Powered by blists - more mailing lists