mirror of https://github.com/dynup/kpatch
create-diff-object: error on symbol conversion failure
If a section reference can't be converted to a symbol reference, error out to try to prevent unexpected behavior later on. There are a few sections for which a symbol is optional: .rodata and string literal sections. Don't warn about those. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
parent
325bccd89d
commit
86d5208b46
|
@ -302,6 +302,12 @@ static bool is_dynamic_debug_symbol(struct symbol *sym)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_string_literal_section(struct section *sec)
|
||||||
|
{
|
||||||
|
return !strncmp(sec->name, ".rodata.", 8) &&
|
||||||
|
strstr(sec->name, ".str1.");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function detects whether the given symbol is a "special" static local
|
* This function detects whether the given symbol is a "special" static local
|
||||||
* variable (for lack of a better term).
|
* variable (for lack of a better term).
|
||||||
|
@ -1478,6 +1484,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||||
struct rela *rela;
|
struct rela *rela;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
long target_off;
|
long target_off;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
log_debug("\n");
|
log_debug("\n");
|
||||||
|
|
||||||
|
@ -1589,11 +1596,18 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||||
relasec->name,
|
relasec->name,
|
||||||
rela->sym->name, rela->addend,
|
rela->sym->name, rela->addend,
|
||||||
sym->name, rela->addend - start);
|
sym->name, rela->addend - start);
|
||||||
|
found = true;
|
||||||
|
|
||||||
rela->sym = sym;
|
rela->sym = sym;
|
||||||
rela->addend -= start;
|
rela->addend -= start;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found && !is_string_literal_section(rela->sym->sec) &&
|
||||||
|
strncmp(rela->sym->name, ".rodata", 7)) {
|
||||||
|
ERROR("%s+0x%x: can't find replacement symbol for %s+%ld reference",
|
||||||
|
relasec->base->name, rela->offset, rela->sym->name, rela->addend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_debug("\n");
|
log_debug("\n");
|
||||||
|
@ -1711,12 +1725,6 @@ static void kpatch_include_symbol(struct symbol *sym)
|
||||||
kpatch_include_section(sym->sec);
|
kpatch_include_section(sym->sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_string_literal_section(struct section *sec)
|
|
||||||
{
|
|
||||||
return !strncmp(sec->name, ".rodata.", 8) &&
|
|
||||||
strstr(sec->name, ".str1.");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
|
static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
|
||||||
{
|
{
|
||||||
struct section *sec;
|
struct section *sec;
|
||||||
|
|
Loading…
Reference in New Issue