[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 02/11] dump: Write ELF section headers right after ELF header
From: |
marcandre . lureau |
Subject: |
[PULL v3 02/11] dump: Write ELF section headers right after ELF header |
Date: |
Wed, 26 Oct 2022 12:55:30 +0400 |
From: Janosch Frank <frankja@linux.ibm.com>
Let's start bundling the writes of the headers and of the data so we
have a clear ordering between them. Since the ELF header uses offsets
to the headers we can freely order them.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20221017083822.43118-3-frankja@linux.ibm.com>
---
dump/dump.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index e7a3b54ebe..b168a25321 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -583,6 +583,8 @@ static void dump_begin(DumpState *s, Error **errp)
* --------------
* | elf header |
* --------------
+ * | sctn_hdr |
+ * --------------
* | PT_NOTE |
* --------------
* | PT_LOAD |
@@ -591,8 +593,6 @@ static void dump_begin(DumpState *s, Error **errp)
* --------------
* | PT_LOAD |
* --------------
- * | sec_hdr |
- * --------------
* | elf note |
* --------------
* | memory |
@@ -608,20 +608,20 @@ static void dump_begin(DumpState *s, Error **errp)
return;
}
- /* write PT_NOTE to vmcore */
- write_elf_phdr_note(s, errp);
+ /* write section headers to vmcore */
+ write_elf_section_headers(s, errp);
if (*errp) {
return;
}
- /* write all PT_LOADs to vmcore */
- write_elf_phdr_loads(s, errp);
+ /* write PT_NOTE to vmcore */
+ write_elf_phdr_note(s, errp);
if (*errp) {
return;
}
- /* write section headers to vmcore */
- write_elf_section_headers(s, errp);
+ /* write all PT_LOADs to vmcore */
+ write_elf_phdr_loads(s, errp);
if (*errp) {
return;
}
@@ -1868,16 +1868,13 @@ static void dump_init(DumpState *s, int fd, bool
has_format,
}
if (dump_is_64bit(s)) {
- s->phdr_offset = sizeof(Elf64_Ehdr);
- s->shdr_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
- s->note_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
- s->memory_offset = s->note_offset + s->note_size;
+ s->shdr_offset = sizeof(Elf64_Ehdr);
+ s->phdr_offset = s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_num;
+ s->note_offset = s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_num;
} else {
-
- s->phdr_offset = sizeof(Elf32_Ehdr);
- s->shdr_offset = s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_num;
- s->note_offset = s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_num;
- s->memory_offset = s->note_offset + s->note_size;
+ s->shdr_offset = sizeof(Elf32_Ehdr);
+ s->phdr_offset = s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_num;
+ s->note_offset = s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_num;
}
return;
--
2.37.3
- [PULL v3 00/11] Dump patches, marcandre . lureau, 2022/10/26
- [PULL v3 01/11] dump: Use a buffer for ELF section data and headers, marcandre . lureau, 2022/10/26
- [PULL v3 03/11] dump: Reorder struct DumpState, marcandre . lureau, 2022/10/26
- [PULL v3 04/11] dump: Reintroduce memory_offset and section_offset, marcandre . lureau, 2022/10/26
- [PULL v3 06/11] s390x: Add protected dump cap, marcandre . lureau, 2022/10/26
- [PULL v3 02/11] dump: Write ELF section headers right after ELF header,
marcandre . lureau <=
- [PULL v3 05/11] dump: Add architecture section and section string table support, marcandre . lureau, 2022/10/26
- [PULL v3 08/11] include/elf.h: add s390x note types, marcandre . lureau, 2022/10/26
- [PULL v3 07/11] s390x: Introduce PV query interface, marcandre . lureau, 2022/10/26
- [PULL v3 09/11] s390x: Add KVM PV dump interface, marcandre . lureau, 2022/10/26
- [PULL v3 10/11] s390x: pv: Add dump support, marcandre . lureau, 2022/10/26
- [PULL v3 11/11] dump/win_dump: limit number of processed PRCBs, marcandre . lureau, 2022/10/26
- Re: [PULL v3 00/11] Dump patches, Stefan Hajnoczi, 2022/10/26
- Re: [PULL v3 00/11] Dump patches, Marc-André Lureau, 2022/10/26