|
|
62547e |
From 987ede93fa4e3d058acddc19874e467faa116ede Mon Sep 17 00:00:00 2001
|
|
|
62547e |
From: Janosch Frank <frankja@linux.ibm.com>
|
|
|
62547e |
Date: Mon, 17 Oct 2022 08:38:14 +0000
|
|
|
62547e |
Subject: [PATCH 33/42] dump: Write ELF section headers right after ELF header
|
|
|
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: [33/41] e956040753533ac376e9763145192de1e216027d
|
|
|
62547e |
|
|
|
62547e |
Let's start bundling the writes of the headers and of the data so we
|
|
|
62547e |
have a clear ordering between them. Since the ELF header uses offsets
|
|
|
62547e |
to the headers we can freely order them.
|
|
|
62547e |
|
|
|
62547e |
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
|
|
|
62547e |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
62547e |
Message-Id: <20221017083822.43118-3-frankja@linux.ibm.com>
|
|
|
62547e |
(cherry picked from commit cb415fd61e48d52f81dcf38956e3f913651cff1c)
|
|
|
62547e |
Signed-off-by: Cédric Le Goater <clg@redhat.com>
|
|
|
62547e |
---
|
|
|
62547e |
dump/dump.c | 31 ++++++++++++++-----------------
|
|
|
62547e |
1 file changed, 14 insertions(+), 17 deletions(-)
|
|
|
62547e |
|
|
|
62547e |
diff --git a/dump/dump.c b/dump/dump.c
|
|
|
62547e |
index 4142b4cc0c..d17537d4e9 100644
|
|
|
62547e |
--- a/dump/dump.c
|
|
|
62547e |
+++ b/dump/dump.c
|
|
|
62547e |
@@ -584,6 +584,8 @@ static void dump_begin(DumpState *s, Error **errp)
|
|
|
62547e |
* --------------
|
|
|
62547e |
* | elf header |
|
|
|
62547e |
* --------------
|
|
|
62547e |
+ * | sctn_hdr |
|
|
|
62547e |
+ * --------------
|
|
|
62547e |
* | PT_NOTE |
|
|
|
62547e |
* --------------
|
|
|
62547e |
* | PT_LOAD |
|
|
|
62547e |
@@ -592,8 +594,6 @@ static void dump_begin(DumpState *s, Error **errp)
|
|
|
62547e |
* --------------
|
|
|
62547e |
* | PT_LOAD |
|
|
|
62547e |
* --------------
|
|
|
62547e |
- * | sec_hdr |
|
|
|
62547e |
- * --------------
|
|
|
62547e |
* | elf note |
|
|
|
62547e |
* --------------
|
|
|
62547e |
* | memory |
|
|
|
62547e |
@@ -609,20 +609,20 @@ static void dump_begin(DumpState *s, Error **errp)
|
|
|
62547e |
return;
|
|
|
62547e |
}
|
|
|
62547e |
|
|
|
62547e |
- /* write PT_NOTE to vmcore */
|
|
|
62547e |
- write_elf_phdr_note(s, errp);
|
|
|
62547e |
+ /* write section headers to vmcore */
|
|
|
62547e |
+ write_elf_section_headers(s, errp);
|
|
|
62547e |
if (*errp) {
|
|
|
62547e |
return;
|
|
|
62547e |
}
|
|
|
62547e |
|
|
|
62547e |
- /* write all PT_LOADs to vmcore */
|
|
|
62547e |
- write_elf_phdr_loads(s, errp);
|
|
|
62547e |
+ /* write PT_NOTE to vmcore */
|
|
|
62547e |
+ write_elf_phdr_note(s, errp);
|
|
|
62547e |
if (*errp) {
|
|
|
62547e |
return;
|
|
|
62547e |
}
|
|
|
62547e |
|
|
|
62547e |
- /* write section headers to vmcore */
|
|
|
62547e |
- write_elf_section_headers(s, errp);
|
|
|
62547e |
+ /* write all PT_LOADs to vmcore */
|
|
|
62547e |
+ write_elf_phdr_loads(s, errp);
|
|
|
62547e |
if (*errp) {
|
|
|
62547e |
return;
|
|
|
62547e |
}
|
|
|
62547e |
@@ -1877,16 +1877,13 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
62547e |
}
|
|
|
62547e |
|
|
|
62547e |
if (dump_is_64bit(s)) {
|
|
|
62547e |
- s->phdr_offset = sizeof(Elf64_Ehdr);
|
|
|
62547e |
- s->shdr_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
|
|
|
62547e |
- s->note_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
|
|
|
62547e |
- s->memory_offset = s->note_offset + s->note_size;
|
|
|
62547e |
+ s->shdr_offset = sizeof(Elf64_Ehdr);
|
|
|
62547e |
+ s->phdr_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
|
|
|
62547e |
+ s->note_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
|
|
|
62547e |
} else {
|
|
|
62547e |
-
|
|
|
62547e |
- s->phdr_offset = sizeof(Elf32_Ehdr);
|
|
|
62547e |
- s->shdr_offset = s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_num;
|
|
|
62547e |
- s->note_offset = s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_num;
|
|
|
62547e |
- s->memory_offset = s->note_offset + s->note_size;
|
|
|
62547e |
+ s->shdr_offset = sizeof(Elf32_Ehdr);
|
|
|
62547e |
+ s->phdr_offset = s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_num;
|
|
|
62547e |
+ s->note_offset = s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_num;
|
|
|
62547e |
}
|
|
|
62547e |
|
|
|
62547e |
return;
|
|
|
62547e |
--
|
|
|
62547e |
2.37.3
|
|
|
62547e |
|