diff mbox series

[7/9] create-diff-object: don't account for changes to .bug_frame.? sections

Message ID 20240429145654.71669-8-roger.pau@citrix.com (mailing list archive)
State New
Headers show
Series livepatch-build-tools: some bug fixes and improvements | expand

Commit Message

Roger Pau Monne April 29, 2024, 2:56 p.m. UTC
bug_frame related sections exclusively contain addresses that reference back to
the address where the BUG_INSTR is executed.  As such, any change to the
contents of bug_frame sections (or it's relocations) will necessarily require a
change in the caller function, as the placement of the BUG_INSTR must have
changed.

Take advantage of this relocation, and unconditionally mark the bug_frame
sections themselves as not having changed, the logic in
kpatch_regenerate_special_section() will already take care of including any
bug_frame element group that references a function that has changed.

This should be a non functional change in the payload generated by
create-diff-object, but needs doing so that we can take into account changes to
.altinstructions and .ex_table sections themselves without unnecessarily also
pulling .bug_frame sections.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 create-diff-object.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/create-diff-object.c b/create-diff-object.c
index f4e4da063d0a..d1b1477be1cd 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1284,6 +1284,17 @@  static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
 		}
 	}
 
+	/*
+	 * For bug_frame sections don't care if the section itself or the
+	 * relocations have changed, as any change in the bug_frames will be
+	 * accompanied by a change in the caller function text, as the
+	 * BUG_INSTR will have a different placement in the caller.
+	 */
+	if (!strncmp(special->name, ".bug_frames.", strlen(".bug_frames."))) {
+		sec->status = SAME;
+		sec->base->status = SAME;
+	}
+
 	for ( ; src_offset < sec->base->sh.sh_size; src_offset += group_size) {
 
 		group_size = special->group_size(kelf, src_offset);