From 693d5a27abc3629b64beeae190dc5e9214dee8d1 Mon Sep 17 00:00:00 2001 From: imxcc Date: Mon, 28 Feb 2022 21:45:59 +0800 Subject: [PATCH] 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 Signed-off-by: imxcc (cherry picked from commit 62ba2da90ad7989b71d9ca869afa8d5bfdbf8805) --- ...trip-adapt-to-new-gcc-version-10.3.1.patch | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 elf-strip-adapt-to-new-gcc-version-10.3.1.patch diff --git a/elf-strip-adapt-to-new-gcc-version-10.3.1.patch b/elf-strip-adapt-to-new-gcc-version-10.3.1.patch new file mode 100644 index 0000000..9e18e79 --- /dev/null +++ b/elf-strip-adapt-to-new-gcc-version-10.3.1.patch @@ -0,0 +1,58 @@ +From abfc33435c25e1515e35768c9a2d684aa72dc780 Mon Sep 17 00:00:00 2001 +From: jiang-dawei15 +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 +--- + 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 +