From b4b0f76e4cfb0be1fba210039ee2493e7585f596 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Thu, 31 Jul 2014 23:48:22 -0500 Subject: [PATCH] compare __func__ references by value Fixes the following error: kpatch_correlate_static_local_variables: 850: found another static local variable matching __func__.49968 in patched .rela__verbose --- kpatch-build/create-diff-object.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 42f7e20..ab452c8 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -319,10 +319,13 @@ void kpatch_create_rela_list(struct kpatch_elf *kelf, struct section *sec) rela->sym = find_symbol_by_index(&kelf->symbols, symndx); if (!rela->sym) ERROR("could not find rela entry symbol\n"); - if (rela->sym->sec && (rela->sym->sec->sh.sh_flags & SHF_STRINGS)) { + if (rela->sym->sec && + ((rela->sym->sec->sh.sh_flags & SHF_STRINGS) || + !strncmp(rela->sym->name, ".rodata.__func__.", 17))) { rela->string = rela->sym->sec->data->d_buf + rela->addend; if (!rela->string) - ERROR("could not lookup rela string\n"); + ERROR("could not lookup rela string for %s+%d", + rela->sym->name, rela->addend); } if (skip) @@ -823,6 +826,15 @@ void kpatch_correlate_static_local_variables(struct kpatch_elf *base, sym->name[prefixlen+1] > '9') continue; + /* + * __func__'s are special gcc static variables which contain + * the function name. There's no need to correlate them + * because they're read-only and their comparison is done in + * rela_equal() by comparing the literal strings. + */ + if (!strncmp(sym->name, "__func__", prefixlen)) + continue; + /* find the patched function which uses the static variable */ sec = NULL; list_for_each_entry(tmpsec, &patched->sections, list) {