mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
powerpc: Prepare func_desc_t for refactorisation
In preparation of making func_desc_t generic, change the ELFv2 version to a struct containing 'addr' element. This allows using single helpers common to ELFv1 and ELFv2 and reduces the amount of #ifdef's Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/5c36105e08b27b98450535bff48d71b690c19739.1644928018.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
0a9c5ae279
commit
2fd986377d
1 changed files with 18 additions and 18 deletions
|
@ -33,19 +33,17 @@
|
||||||
#ifdef PPC64_ELF_ABI_v2
|
#ifdef PPC64_ELF_ABI_v2
|
||||||
|
|
||||||
/* An address is simply the address of the function. */
|
/* An address is simply the address of the function. */
|
||||||
typedef unsigned long func_desc_t;
|
typedef struct {
|
||||||
|
unsigned long addr;
|
||||||
|
} func_desc_t;
|
||||||
|
|
||||||
static func_desc_t func_desc(unsigned long addr)
|
static func_desc_t func_desc(unsigned long addr)
|
||||||
{
|
{
|
||||||
return addr;
|
func_desc_t desc = {
|
||||||
}
|
.addr = addr,
|
||||||
static unsigned long func_addr(unsigned long addr)
|
};
|
||||||
{
|
|
||||||
return addr;
|
return desc;
|
||||||
}
|
|
||||||
static unsigned long stub_func_addr(func_desc_t func)
|
|
||||||
{
|
|
||||||
return func;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PowerPC64 specific values for the Elf64_Sym st_other field. */
|
/* PowerPC64 specific values for the Elf64_Sym st_other field. */
|
||||||
|
@ -70,14 +68,6 @@ static func_desc_t func_desc(unsigned long addr)
|
||||||
{
|
{
|
||||||
return *(struct func_desc *)addr;
|
return *(struct func_desc *)addr;
|
||||||
}
|
}
|
||||||
static unsigned long func_addr(unsigned long addr)
|
|
||||||
{
|
|
||||||
return func_desc(addr).addr;
|
|
||||||
}
|
|
||||||
static unsigned long stub_func_addr(func_desc_t func)
|
|
||||||
{
|
|
||||||
return func.addr;
|
|
||||||
}
|
|
||||||
static unsigned int local_entry_offset(const Elf64_Sym *sym)
|
static unsigned int local_entry_offset(const Elf64_Sym *sym)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -93,6 +83,16 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static unsigned long func_addr(unsigned long addr)
|
||||||
|
{
|
||||||
|
return func_desc(addr).addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long stub_func_addr(func_desc_t func)
|
||||||
|
{
|
||||||
|
return func.addr;
|
||||||
|
}
|
||||||
|
|
||||||
#define STUB_MAGIC 0x73747562 /* stub */
|
#define STUB_MAGIC 0x73747562 /* stub */
|
||||||
|
|
||||||
/* Like PPC32, we need little trampolines to do > 24-bit jumps (into
|
/* Like PPC32, we need little trampolines to do > 24-bit jumps (into
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue