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

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