37 lines
1.3 KiB
Diff
37 lines
1.3 KiB
Diff
From ecaa5aa05434d47ce529b8cc2a1693a88bd6edb0 Mon Sep 17 00:00:00 2001
|
|
From: hubin <hubin73@huawei.com>
|
|
Date: Sun, 18 Feb 2024 19:42:53 +0800
|
|
Subject: [PATCH] fix function ptr relocation
|
|
|
|
When option CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS is enabled, each function
|
|
is added 5 NOP padding before function entry.
|
|
---
|
|
kpatch-build/create-diff-object.c | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
|
|
index cf5ff95..d5126f8 100644
|
|
--- a/kpatch-build/create-diff-object.c
|
|
+++ b/kpatch-build/create-diff-object.c
|
|
@@ -3271,10 +3271,15 @@ static int kpatch_is_core_module_symbol(char *name)
|
|
static int function_ptr_rela(const struct rela *rela)
|
|
{
|
|
const struct rela *rela_toc = toc_rela(rela);
|
|
+ int entry_offset = 0;
|
|
+
|
|
+ if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS"))
|
|
+ entry_offset = 20;
|
|
|
|
return (rela_toc && rela_toc->sym->type == STT_FUNC &&
|
|
!rela_toc->sym->parent &&
|
|
- rela_toc->addend == (int)rela_toc->sym->sym.st_value &&
|
|
+ (rela_toc->addend == (int)rela_toc->sym->sym.st_value ||
|
|
+ rela_toc->addend == (int)rela_toc->sym->sym.st_value - entry_offset) &&
|
|
(rela->type == R_X86_64_32S ||
|
|
rela->type == R_PPC64_TOC16_HA ||
|
|
rela->type == R_PPC64_TOC16_LO_DS ||
|
|
--
|
|
2.33.0
|
|
|
|
|