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

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