Blame SOURCES/v0.9.2-backport-MR-1200-Make-sure-section-symbols-ex.patch

369dfe
From c1a07a5329c0b7db0ec54eea093e5d2d77735c06 Mon Sep 17 00:00:00 2001
369dfe
From: Joe Lawrence <joe.lawrence@redhat.com>
369dfe
Date: Fri, 9 Dec 2022 15:37:49 -0500
369dfe
Subject: [PATCH] v0.9.2 backport: MR!1200 ("Make sure section symbols exist")
369dfe
Content-type: text/plain
369dfe
369dfe
commit 5622e3cc3d393fd77866b9838d16cd064de6fba5
369dfe
Author: Artem Savkov <asavkov@redhat.com>
369dfe
Date:   Fri Jun 18 10:59:26 2021 +0200
369dfe
369dfe
    Make sure section symbols exist
369dfe
369dfe
    Binutils recently became much more aggressive about removing unused
369dfe
    section symbols. Since we can not rely on those being available anymore
369dfe
    add additional checks before using them.
369dfe
369dfe
    Fixes: #1193
369dfe
369dfe
    Signed-off-by: Artem Savkov <asavkov@redhat.com>
369dfe
369dfe
Fixes: KLP-216 ("Backport kpatch-build section symbol check")
369dfe
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
369dfe
---
369dfe
 kpatch-build/create-diff-object.c | 15 ++++++++++-----
369dfe
 1 file changed, 10 insertions(+), 5 deletions(-)
369dfe
369dfe
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
369dfe
index c9afe33bbdae..94879b5fce6a 100644
369dfe
--- a/kpatch-build/create-diff-object.c
369dfe
+++ b/kpatch-build/create-diff-object.c
369dfe
@@ -1241,7 +1241,8 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
369dfe
 		if (bundled && sym->sec->twin) {
369dfe
 			UNCORRELATE_ELEMENT(sym->sec);
369dfe
 
369dfe
-			UNCORRELATE_ELEMENT(sym->sec->secsym);
369dfe
+			if (sym->sec->secsym)
369dfe
+				UNCORRELATE_ELEMENT(sym->sec->secsym);
369dfe
 
369dfe
 			if (sym->sec->rela)
369dfe
 				UNCORRELATE_ELEMENT(sym->sec->rela);
369dfe
@@ -1744,7 +1745,7 @@ static int kpatch_include_callback_elements(struct kpatch_elf *kelf)
369dfe
 			sym = rela->sym;
369dfe
 			log_normal("found callback: %s\n",sym->name);
369dfe
 			kpatch_include_symbol(sym);
369dfe
-		} else {
369dfe
+		} else if (sec->secsym) {
369dfe
 			sec->secsym->include = 1;
369dfe
 		}
369dfe
 	}
369dfe
@@ -1772,7 +1773,8 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf)
369dfe
 			sec->include = 1;
369dfe
 			if (!is_rela_section(sec)) {
369dfe
 				/* .kpatch.force */
369dfe
-				sec->secsym->include = 1;
369dfe
+				if (sec->secsym)
369dfe
+					sec->secsym->include = 1;
369dfe
 				continue;
369dfe
 			}
369dfe
 			/* .rela.kpatch.force */
369dfe
@@ -2381,7 +2383,8 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
369dfe
 	sec->include = 1;
369dfe
 	sec->base->include = 1;
369dfe
 	/* include secsym so .kpatch.arch relas can point to section symbols */
369dfe
-	sec->base->secsym->include = 1;
369dfe
+	if (sec->base->secsym)
369dfe
+		sec->base->secsym->include = 1;
369dfe
 
369dfe
 	/*
369dfe
 	 * Update text section data buf and size.
369dfe
@@ -2564,7 +2567,9 @@ static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf)
369dfe
 		 * from the section data comparison, but this is a simpler way.
369dfe
 		 */
369dfe
 		strsec->include = 1;
369dfe
-		strsec->secsym->include = 1;
369dfe
+		if (strsec->secsym)
369dfe
+			strsec->secsym->include = 1;
369dfe
+
369dfe
 		name = strsec->data->d_buf + rela->addend;
369dfe
 		ignoresec = find_section_by_name(&kelf->sections, name);
369dfe
 		if (!ignoresec)
369dfe
-- 
369dfe
2.38.1
369dfe