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

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