libcareplus/0004-elf-strip-adapt-to-new-gcc-version-10.3.1.patch
yezengruan eda47481b9 update libcareplus to version 1.0.0-12
kpatch_process: fix possible double free.
ptrace: fix NULL pointer access problem
fix patched process crashing when acccess the global var
fix probably restore cc symbol link fail when kill patch building uncourteous
optimize: Remove unnecessary comparison code

Signed-off-by: yezengruan <yezengruan@huawei.com>
(cherry picked from commit f3d59711105eb667fa2f920958fcbdbb7068afd2)
2022-07-21 15:47:45 +08:00

59 lines
1.9 KiB
Diff

From abfc33435c25e1515e35768c9a2d684aa72dc780 Mon Sep 17 00:00:00 2001
From: jiang-dawei15 <jiangdawei15@huawei.com>
Date: Mon, 28 Feb 2022 15:34:11 +0800
Subject: [PATCH 1/3] elf/strip: adapt to new gcc version(10.3.1)
This patch fix the following problems:
1. new libc so use new naming method,such as: libc.6.so -> libc.so.6;
2. destroy .rela section sh_flags INFO property;
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
src/kpatch_elf.c | 9 +++------
src/kpatch_strip.c | 5 +++--
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/kpatch_elf.c b/src/kpatch_elf.c
index 5acf370..260209a 100644
--- a/src/kpatch_elf.c
+++ b/src/kpatch_elf.c
@@ -180,16 +180,13 @@ static int
elf_object_is_interp_exception(struct object_file *o)
{
/* libc */
- if (!strncmp(o->name, "libc", 4) &&
- !strncmp(o->name + strlen(o->name) - 3, ".so", 3))
+ if (!strncmp(o->name, "libc.", 5))
return 1;
/* libpthread */
- if (!strncmp(o->name, "libpthread", 10) &&
- !strncmp(o->name + strlen(o->name) - 3, ".so", 3))
+ if (!strncmp(o->name, "libpthread.", 11))
return 1;
/* libdl */
- if (!strncmp(o->name, "libdl", 5) &&
- !strncmp(o->name + strlen(o->name) - 3, ".so", 3))
+ if (!strncmp(o->name, "libdl.", 6))
return 1;
return 0;
}
diff --git a/src/kpatch_strip.c b/src/kpatch_strip.c
index 5717e5a..6420af9 100644
--- a/src/kpatch_strip.c
+++ b/src/kpatch_strip.c
@@ -220,8 +220,9 @@ static int kpatch_strip(Elf *elfin, Elf *elfout)
} else {
kpinfo("don't need it\n");
shout.sh_type = SHT_NOBITS;
- shout.sh_link = 0;
- shout.sh_info = 0;
+ /* destroy the .rela section sh_flags INFO property */
+ if (!strncmp(scnname, ".rela", 5))
+ shout.sh_flags = SHF_ALLOC;
}
if (!gelf_update_shdr(scnout, &shout)) {
kperr("Failed to do gelf_update_shdr need");
--
2.23.0.windows.1