mirror of
https://github.com/dynup/kpatch
synced 2025-05-06 09:57:56 +00:00
create-diff-object: don't mangle .rela.__patchable_function_entries
kpatch_replace_sections_syms() substitutes the object/function symbols for the section symbol in the relocation sections. But relocations in .rela.__patchable_function_entries can point to an instruction ouside the function. This is because with CALL_OPS enabled, two NOPs are added before the function entry. __patchable_function_entries needs the address of the first NOP above the function. We anyway generate __patchable_function_entries again in kpatch_create_ftrace_callsite_sections() so we can skip mangling these relocations Signed-off-by: Puranjay Mohan <pjy@amazon.com>
This commit is contained in:
parent
2dc6690892
commit
ce8ca2cf68
@ -1639,6 +1639,13 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||
if (!is_rela_section(relasec) || is_debug_section(relasec))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* We regenerate __patchable_function_entries from scratch so
|
||||
* don't bother replacing section symbols in its relasec.
|
||||
*/
|
||||
if (is_patchable_function_entries_section(relasec))
|
||||
continue;
|
||||
|
||||
list_for_each_entry(rela, &relasec->relas, list) {
|
||||
|
||||
if (rela->sym->type != STT_SECTION || !rela->sym->sec)
|
||||
|
@ -65,6 +65,18 @@ bool is_text_section(struct section *sec)
|
||||
(sec->sh.sh_flags & SHF_EXECINSTR));
|
||||
}
|
||||
|
||||
bool is_patchable_function_entries_section(struct section *sec)
|
||||
{
|
||||
char *name;
|
||||
|
||||
if (is_rela_section(sec))
|
||||
name = sec->base->name;
|
||||
else
|
||||
name = sec->name;
|
||||
|
||||
return !strncmp(name, "__patchable_function_entries", 28);
|
||||
}
|
||||
|
||||
bool is_debug_section(struct section *sec)
|
||||
{
|
||||
char *name;
|
||||
|
@ -136,6 +136,7 @@ struct kpatch_elf {
|
||||
char *status_str(enum status status);
|
||||
bool is_rela_section(struct section *sec);
|
||||
bool is_text_section(struct section *sec);
|
||||
bool is_patchable_function_entries_section(struct section *sec);
|
||||
bool is_debug_section(struct section *sec);
|
||||
|
||||
struct section *find_section_by_index(struct list_head *list, unsigned int index);
|
||||
|
Loading…
Reference in New Issue
Block a user