!148 修复kpatch制作热补丁时报错symbol xxx at offset 20 within section xxx, expected 0
From: @pshysimon Reviewed-by: @hubin95 Signed-off-by: @hubin95
This commit is contained in:
commit
e847e265f8
@ -0,0 +1,75 @@
|
|||||||
|
From 717db96e56118b4a457f7bf6988cb7c3d1af6b12 Mon Sep 17 00:00:00 2001
|
||||||
|
From: rpm-build <rpm-build>
|
||||||
|
Date: Fri, 8 Nov 2024 11:52:51 +0800
|
||||||
|
Subject: [PATCH] adapt kpatch_bundle_symbols to kernel change and fix function
|
||||||
|
ptr relocation
|
||||||
|
|
||||||
|
---
|
||||||
|
kpatch-build/create-diff-object.c | 10 ++++++++--
|
||||||
|
kpatch-build/kpatch-build | 1 +
|
||||||
|
kpatch-build/lookup.c | 5 +++++
|
||||||
|
3 files changed, 14 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
|
||||||
|
index 6f3937f..fc756f3 100644
|
||||||
|
--- a/kpatch-build/create-diff-object.c
|
||||||
|
+++ b/kpatch-build/create-diff-object.c
|
||||||
|
@@ -229,7 +229,8 @@ static void kpatch_bundle_symbols(struct kpatch_elf *kelf)
|
||||||
|
list_for_each_entry(sym, &kelf->symbols, list) {
|
||||||
|
if (is_bundleable(sym)) {
|
||||||
|
if (sym->sym.st_value != 0 &&
|
||||||
|
- !is_gcc6_localentry_bundled_sym(sym)) {
|
||||||
|
+ !is_gcc6_localentry_bundled_sym(sym) &&
|
||||||
|
+ !(getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS") && sym->sym.st_value == 20)) {
|
||||||
|
ERROR("symbol %s at offset %lu within section %s, expected 0",
|
||||||
|
sym->name, sym->sym.st_value,
|
||||||
|
sym->sec->name);
|
||||||
|
@@ -3228,10 +3229,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 ||
|
||||||
|
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
||||||
|
index 6a0645a..782007e 100755
|
||||||
|
--- a/kpatch-build/kpatch-build
|
||||||
|
+++ b/kpatch-build/kpatch-build
|
||||||
|
@@ -930,6 +930,7 @@ grep -q "CONFIG_JUMP_LABEL=y" "" && CONFIG_JUMP_LABEL=1
|
||||||
|
grep -q "CONFIG_MODVERSIONS=y" "$CONFIGFILE" && CONFIG_MODVERSIONS=1
|
||||||
|
grep -q "CONFIG_CC_IS_CLANG=y" "$CONFIGFILE" && CONFIG_CC_IS_CLANG=1
|
||||||
|
grep -q "CONFIG_LD_IS_LLD=y" "$CONFIGFILE" && CONFIG_LD_IS_LLD=1
|
||||||
|
+grep -q "CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y" "$CONFIGFILE" && export CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=1
|
||||||
|
|
||||||
|
# unsupported kernel option checking
|
||||||
|
grep -q "CONFIG_DEBUG_INFO_SPLIT=y" "$CONFIGFILE" && die "kernel option 'CONFIG_DEBUG_INFO_SPLIT' not supported"
|
||||||
|
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
|
||||||
|
index 458b447..2fe1fd0 100644
|
||||||
|
--- a/kpatch-build/lookup.c
|
||||||
|
+++ b/kpatch-build/lookup.c
|
||||||
|
@@ -107,6 +107,11 @@ static bool locals_match(struct lookup_table *table, int idx,
|
||||||
|
continue;
|
||||||
|
if (table_sym->type != STT_FUNC && table_sym->type != STT_OBJECT)
|
||||||
|
continue;
|
||||||
|
+ /*
|
||||||
|
+ * BTF info may not be enabled when compiling kernel, but exists in vmlinux symtab
|
||||||
|
+ */
|
||||||
|
+ if (!strncmp(table_sym->name, "__BTF_ID__", 10))
|
||||||
|
+ continue;
|
||||||
|
|
||||||
|
found = 0;
|
||||||
|
sym = file_sym;
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Name: kpatch
|
Name: kpatch
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 0.9.5
|
Version: 0.9.5
|
||||||
Release: 10
|
Release: 11
|
||||||
Summary: A Linux dynamic kernel patching infrastructure
|
Summary: A Linux dynamic kernel patching infrastructure
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
@ -61,6 +61,7 @@ Patch0045:0045-backport-create-diff-object-add-support-for-.return_sites-sec.pat
|
|||||||
Patch0046:0046-create-diff-object-ignore-entsize-change-of-.return_.patch
|
Patch0046:0046-create-diff-object-ignore-entsize-change-of-.return_.patch
|
||||||
Patch0047:0047-lookup-skip-duplicate-local-symbol-table-check-for-f.patch
|
Patch0047:0047-lookup-skip-duplicate-local-symbol-table-check-for-f.patch
|
||||||
Patch0048:0048-fix-sssnic-module-always-changes-kpatch-relying-on-s.patch
|
Patch0048:0048-fix-sssnic-module-always-changes-kpatch-relying-on-s.patch
|
||||||
|
Patch0049:0049-adapt-kpatch_bundle_symbols-to-kernel-change-and-fix.patch
|
||||||
|
|
||||||
BuildRequires: gcc elfutils-libelf-devel kernel-devel git
|
BuildRequires: gcc elfutils-libelf-devel kernel-devel git
|
||||||
%ifarch ppc64le
|
%ifarch ppc64le
|
||||||
@ -124,6 +125,12 @@ popd
|
|||||||
%{_mandir}/man1/*.1.gz
|
%{_mandir}/man1/*.1.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Nov 8 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-11
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:adapt kpatch bundle symbols to kernel change
|
||||||
|
|
||||||
* Sat Jul 13 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-10
|
* Sat Jul 13 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-10
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user