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> Signed-off-by: imxcc <xingchaochao@huawei.com> (cherry picked from commit 62ba2da90ad7989b71d9ca869afa8d5bfdbf8805)
This commit is contained in:
parent
698bba14c7
commit
693d5a27ab
58
elf-strip-adapt-to-new-gcc-version-10.3.1.patch
Normal file
58
elf-strip-adapt-to-new-gcc-version-10.3.1.patch
Normal file
@ -0,0 +1,58 @@
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user