thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-dump-Remove-the-section-if-when-calculating-the-memo.patch

bf143f
From a8eeab6936a2bd27b33b63aed7e2ef96034f7772 Mon Sep 17 00:00:00 2001
bf143f
From: Janosch Frank <frankja@linux.ibm.com>
bf143f
Date: Wed, 30 Mar 2022 12:35:58 +0000
bf143f
Subject: [PATCH 16/42] dump: Remove the section if when calculating the memory
bf143f
 offset
bf143f
MIME-Version: 1.0
bf143f
Content-Type: text/plain; charset=UTF-8
bf143f
Content-Transfer-Encoding: 8bit
bf143f
bf143f
RH-Author: Cédric Le Goater <clg@redhat.com>
bf143f
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
bf143f
RH-Bugzilla: 1664378 2043909
bf143f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
bf143f
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
bf143f
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
bf143f
RH-Commit: [16/41] ff214d2c23b9cb16fd49d22d976829267df43133
bf143f
bf143f
When s->shdr_num is 0 we'll add 0 bytes of section headers which is
bf143f
equivalent to not adding section headers but with the multiplication
bf143f
we can remove a if/else.
bf143f
bf143f
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
bf143f
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
bf143f
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
bf143f
Message-Id: <20220330123603.107120-5-frankja@linux.ibm.com>
bf143f
(cherry picked from commit 344107e07bd81546474a54ab83800158ca953059)
bf143f
Signed-off-by: Cédric Le Goater <clg@redhat.com>
bf143f
---
bf143f
 dump/dump.c | 24 ++++++++----------------
bf143f
 1 file changed, 8 insertions(+), 16 deletions(-)
bf143f
bf143f
diff --git a/dump/dump.c b/dump/dump.c
bf143f
index 972e28b089..5cc2322325 100644
bf143f
--- a/dump/dump.c
bf143f
+++ b/dump/dump.c
bf143f
@@ -1826,23 +1826,15 @@ static void dump_init(DumpState *s, int fd, bool has_format,
bf143f
     }
bf143f
 
bf143f
     if (s->dump_info.d_class == ELFCLASS64) {
bf143f
-        if (s->shdr_num) {
bf143f
-            s->memory_offset = sizeof(Elf64_Ehdr) +
bf143f
-                               sizeof(Elf64_Phdr) * s->phdr_num +
bf143f
-                               sizeof(Elf64_Shdr) * s->shdr_num + s->note_size;
bf143f
-        } else {
bf143f
-            s->memory_offset = sizeof(Elf64_Ehdr) +
bf143f
-                               sizeof(Elf64_Phdr) * s->phdr_num + s->note_size;
bf143f
-        }
bf143f
+        s->memory_offset = sizeof(Elf64_Ehdr) +
bf143f
+                           sizeof(Elf64_Phdr) * s->phdr_num +
bf143f
+                           sizeof(Elf64_Shdr) * s->shdr_num +
bf143f
+                           s->note_size;
bf143f
     } else {
bf143f
-        if (s->shdr_num) {
bf143f
-            s->memory_offset = sizeof(Elf32_Ehdr) +
bf143f
-                               sizeof(Elf32_Phdr) * s->phdr_num +
bf143f
-                               sizeof(Elf32_Shdr) * s->shdr_num + s->note_size;
bf143f
-        } else {
bf143f
-            s->memory_offset = sizeof(Elf32_Ehdr) +
bf143f
-                               sizeof(Elf32_Phdr) * s->phdr_num + s->note_size;
bf143f
-        }
bf143f
+        s->memory_offset = sizeof(Elf32_Ehdr) +
bf143f
+                           sizeof(Elf32_Phdr) * s->phdr_num +
bf143f
+                           sizeof(Elf32_Shdr) * s->shdr_num +
bf143f
+                           s->note_size;
bf143f
     }
bf143f
 
bf143f
     return;
bf143f
-- 
bf143f
2.37.3
bf143f