thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
97168e
From 987ede93fa4e3d058acddc19874e467faa116ede Mon Sep 17 00:00:00 2001
97168e
From: Janosch Frank <frankja@linux.ibm.com>
97168e
Date: Mon, 17 Oct 2022 08:38:14 +0000
97168e
Subject: [PATCH 33/42] dump: Write ELF section headers right after ELF header
97168e
MIME-Version: 1.0
97168e
Content-Type: text/plain; charset=UTF-8
97168e
Content-Transfer-Encoding: 8bit
97168e
97168e
RH-Author: Cédric Le Goater <clg@redhat.com>
97168e
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
97168e
RH-Bugzilla: 1664378 2043909
97168e
RH-Acked-by: Thomas Huth <thuth@redhat.com>
97168e
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
97168e
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
97168e
RH-Commit: [33/41] e956040753533ac376e9763145192de1e216027d
97168e
97168e
Let's start bundling the writes of the headers and of the data so we
97168e
have a clear ordering between them. Since the ELF header uses offsets
97168e
to the headers we can freely order them.
97168e
97168e
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
97168e
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
97168e
Message-Id: <20221017083822.43118-3-frankja@linux.ibm.com>
97168e
(cherry picked from commit cb415fd61e48d52f81dcf38956e3f913651cff1c)
97168e
Signed-off-by: Cédric Le Goater <clg@redhat.com>
97168e
---
97168e
 dump/dump.c | 31 ++++++++++++++-----------------
97168e
 1 file changed, 14 insertions(+), 17 deletions(-)
97168e
97168e
diff --git a/dump/dump.c b/dump/dump.c
97168e
index 4142b4cc0c..d17537d4e9 100644
97168e
--- a/dump/dump.c
97168e
+++ b/dump/dump.c
97168e
@@ -584,6 +584,8 @@ static void dump_begin(DumpState *s, Error **errp)
97168e
      *   --------------
97168e
      *   |  elf header |
97168e
      *   --------------
97168e
+     *   |  sctn_hdr   |
97168e
+     *   --------------
97168e
      *   |  PT_NOTE    |
97168e
      *   --------------
97168e
      *   |  PT_LOAD    |
97168e
@@ -592,8 +594,6 @@ static void dump_begin(DumpState *s, Error **errp)
97168e
      *   --------------
97168e
      *   |  PT_LOAD    |
97168e
      *   --------------
97168e
-     *   |  sec_hdr    |
97168e
-     *   --------------
97168e
      *   |  elf note   |
97168e
      *   --------------
97168e
      *   |  memory     |
97168e
@@ -609,20 +609,20 @@ static void dump_begin(DumpState *s, Error **errp)
97168e
         return;
97168e
     }
97168e
 
97168e
-    /* write PT_NOTE to vmcore */
97168e
-    write_elf_phdr_note(s, errp);
97168e
+    /* write section headers to vmcore */
97168e
+    write_elf_section_headers(s, errp);
97168e
     if (*errp) {
97168e
         return;
97168e
     }
97168e
 
97168e
-    /* write all PT_LOADs to vmcore */
97168e
-    write_elf_phdr_loads(s, errp);
97168e
+    /* write PT_NOTE to vmcore */
97168e
+    write_elf_phdr_note(s, errp);
97168e
     if (*errp) {
97168e
         return;
97168e
     }
97168e
 
97168e
-    /* write section headers to vmcore */
97168e
-    write_elf_section_headers(s, errp);
97168e
+    /* write all PT_LOADs to vmcore */
97168e
+    write_elf_phdr_loads(s, errp);
97168e
     if (*errp) {
97168e
         return;
97168e
     }
97168e
@@ -1877,16 +1877,13 @@ static void dump_init(DumpState *s, int fd, bool has_format,
97168e
     }
97168e
 
97168e
     if (dump_is_64bit(s)) {
97168e
-        s->phdr_offset = sizeof(Elf64_Ehdr);
97168e
-        s->shdr_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
97168e
-        s->note_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
97168e
-        s->memory_offset = s->note_offset + s->note_size;
97168e
+        s->shdr_offset = sizeof(Elf64_Ehdr);
97168e
+        s->phdr_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
97168e
+        s->note_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
97168e
     } else {
97168e
-
97168e
-        s->phdr_offset = sizeof(Elf32_Ehdr);
97168e
-        s->shdr_offset = s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_num;
97168e
-        s->note_offset = s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_num;
97168e
-        s->memory_offset = s->note_offset + s->note_size;
97168e
+        s->shdr_offset = sizeof(Elf32_Ehdr);
97168e
+        s->phdr_offset = s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_num;
97168e
+        s->note_offset = s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_num;
97168e
     }
97168e
 
97168e
     return;
97168e
-- 
97168e
2.37.3
97168e