From ff78bad23b13194866d7cea57c20eac281d20f9e Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Tue, 11 Jun 2019 16:07:03 -0400 Subject: [PATCH] kpatch-build: remove localentry data from ppc64le symtab commit f8213c87f64a ("lookup: Fix format string for symtab_read() on PPC64LE") fixed the symbol table lookup when readelf adds ppc64le "[: 8]" info for functions like so: 23: 0000000000000008 96 FUNC LOCAL DEFAULT [: 8] 4 cmdline_proc_show however, it seems that readelf 2.30-57.el8 displays this in a slightly different format: 24493: c000000000587970 96 FUNC LOCAL DEFAULT 2 cmdline_proc_show [: 8] Instead of adding more cases to kpatch-build's lookup.c scanf format, let's just delete this information from the symtab file with a quick and dirty sed regex. This allows us to handle both observed cases (and perhaps others) while removing the arch-specific scanf formatting in lookup.c Fixes: f8213c87f64a ("lookup: Fix format string for symtab_read() on PPC64LE") Signed-off-by: Joe Lawrence --- kpatch-build/kpatch-build | 3 +++ kpatch-build/lookup.c | 23 ++++------------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 327d40fd3..84d502b69 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -846,6 +846,9 @@ for i in $FILES; do fi readelf -s --wide "$KOBJFILE_PATH" > "$SYMTAB" + if [[ "$ARCH" = "ppc64le" ]]; then + sed -ri 's/\s+\[: 8\]//' "$SYMTAB" + fi # create-diff-object orig.o patched.o parent-name parent-symtab # Module.symvers patch-mod-name output.o diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c index 5c9cb9122..347064fa5 100644 --- a/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c @@ -209,18 +209,8 @@ static void symtab_read(struct lookup_table *table, char *path) ERROR("fopen"); while (fgets(line, 256, file)) { - if (strstr(line, "[: 8]")) { - /* - * 23: 0000000000000008 96 FUNC LOCAL DEFAULT [: 8] 4 cmdline_proc_show - * On Power, local func syms Ndx is preceded with "[: 8]" - * denoting local entry point offset of the function. - */ - matched = sscanf(line, "%*s %lx %s %s %s %*s [: 8] %s %s\n", - &value, size, type, bind, ndx, name); - } else { - matched = sscanf(line, "%*s %lx %s %s %s %*s %s %s\n", - &value, size, type, bind, ndx, name); - } + matched = sscanf(line, "%*s %lx %s %s %s %*s %s %s\n", + &value, size, type, bind, ndx, name); if (matched == 5) { name[0] = '\0'; @@ -243,13 +233,8 @@ static void symtab_read(struct lookup_table *table, char *path) rewind(file); while (fgets(line, 256, file)) { - if (strstr(line, "[: 8]")) { - matched = sscanf(line, "%*s %lx %s %s %s %*s [: 8] %s %s\n", - &value, size, type, bind, ndx, name); - } else { - matched = sscanf(line, "%*s %lx %s %s %s %*s %s %s\n", - &value, size, type, bind, ndx, name); - } + matched = sscanf(line, "%*s %lx %s %s %s %*s %s %s\n", + &value, size, type, bind, ndx, name); if (matched == 5) { name[0] = '\0';