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

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