From e444b2cbb84a4599855f891661132f389d90eb2b Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Fri, 25 Apr 2014 14:07:51 -0500 Subject: [PATCH] fix smp_lock support The initial commit had a bug where the offset field of the .rela.smp_locks entries was not updated to reflect the correct offset in the truncated .smp_locks section. Signed-off-by: Seth Jennings --- kpatch-build/create-diff-object.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 2bcf5a8..714b85a 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -1058,7 +1058,7 @@ void kpatch_regenerate_smp_locks_sections(struct kpatch_elf *kelf) struct section *sec; struct table table; struct rela *rela, *dstrela; - int i, nr = 0; + int i, nr = 0, offset = 0; sec = find_section_by_name(&kelf->sections, ".rela.smp_locks"); if (!sec) @@ -1072,7 +1072,11 @@ void kpatch_regenerate_smp_locks_sections(struct kpatch_elf *kelf) if (rela->sym->sec->status != SAME) { log_debug("new/changed symbol %s found in smp locks table\n", rela->sym->name); - *dstrela++ = *rela; + *dstrela = *rela; + dstrela->offset = offset; + dstrela->rela.r_offset = offset; + dstrela++; + offset += 4; nr++; } } @@ -1098,7 +1102,7 @@ void kpatch_regenerate_smp_locks_sections(struct kpatch_elf *kelf) sec->data->d_size = sec->sh.sh_entsize * nr; /* truncate smp_locks section */ - sec->base->data->d_size = 4 * nr; + sec->base->data->d_size = offset; } void kpatch_create_rela_section(struct section *sec, int link)