[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230622114811.GL4253@hirez.programming.kicks-ass.net>
Date: Thu, 22 Jun 2023 13:48:11 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Christophe Leroy <christophe.leroy@...roup.eu>
Cc: Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Sathvika Vasireddy <sv@...ux.ibm.com>,
Naveen N Rao <naveen@...nel.org>,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v2 10/14] objtool: Add support for relative switch tables
On Thu, Jun 22, 2023 at 12:54:32PM +0200, Christophe Leroy wrote:
> On powerpc, switch tables are relative, than means the address of the
> table is added to the value of the entry in order to get the pointed
> address: (r10 is the table address, r4 the index in the table)
>
> lis r10,0 <== Load r10 with upper part of .rodata address
> R_PPC_ADDR16_HA .rodata
> addi r10,r10,0 <== Add lower part of .rodata address
> R_PPC_ADDR16_LO .rodata
> lwzx r8,r10,r4 <== Read table entry at r10 + r4 into r8
> add r10,r8,r10 <== Add table address to read value
> mtctr r10 <== Save calculated address in CTR
> bctr <== Branch to address in CTR
>
> But for c_jump_tables it is not the case, they contain the
> pointed address directly:
>
> lis r28,0 <== Load r28 with upper .rodata..c_jump_table
> R_PPC_ADDR16_HA .rodata..c_jump_table
> addi r28,r28,0 <== Add lower part of .rodata..c_jump_table
> R_PPC_ADDR16_LO .rodata..c_jump_table
> lwzx r10,r28,r10 <== Read table entry at r10 + r28 into r10
> mtctr r10 <== Save read value in CTR
> bctr <== Branch to address in CTR
>
> Add support to objtool for relative tables, with a flag in order to
> tell table by table if that table uses relative or absolute addressing.
>
> And use correct size for 'long' instead of hard coding a size of '8'.
Again, see tip/objtool/core...
This one is going to be a little hard. It would be very good if you can
avoid growing struct reloc; Josh went through a ton of effort to shrink
it.
Would it work to use reloc->sym->is_rel_jumptable ? That still has a few
spare bits in it's bitfield.
> diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
> index e1ca588eb69d..64aac87a4825 100644
> --- a/tools/objtool/include/objtool/elf.h
> +++ b/tools/objtool/include/objtool/elf.h
> @@ -80,6 +80,7 @@ struct reloc {
> s64 addend;
> int idx;
> bool jump_table_start;
> + bool jump_table_is_rel;
> };
Powered by blists - more mailing lists