[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 11/18] dump: Swap segment and section header locations
From: |
Janosch Frank |
Subject: |
[PATCH v5 11/18] dump: Swap segment and section header locations |
Date: |
Thu, 11 Aug 2022 12:11:04 +0000 |
For the upcoming string table and arch section support we need to
modify the elf layout a bit. Instead of the segments, i.e. the guest's
memory contents, being the last area the section data will live at
the end of the file. This will allow us to write the section data
after all guest memory has been dumped which is important for the s390
PV dump support.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
dump/dump.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index 0051c71d08..31eb20108c 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -595,6 +595,9 @@ static void dump_begin(DumpState *s, Error **errp)
* --------------
* | memory |
* --------------
+ * | sectn data |
+ * --------------
+
*
* we only know where the memory is saved after we write elf note into
* vmcore.
@@ -1842,17 +1845,16 @@ 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;
}
+ s->memory_offset = s->note_offset + s->note_size;
+ s->section_offset = s->memory_offset + s->total_size;
return;
--
2.34.1
- Re: [PATCH v5 18/18] s390x: pv: Add dump support, (continued)
- [PATCH v5 02/18] dump: Rename write_elf_loads to write_elf_phdr_loads, Janosch Frank, 2022/08/11
- [PATCH v5 07/18] dump: Split elf header functions into prepare and write, Janosch Frank, 2022/08/11
- [PATCH v5 06/18] dump: Rework dump_calculate_size function, Janosch Frank, 2022/08/11
- [PATCH v5 04/18] dump: Rework get_start_block, Janosch Frank, 2022/08/11
- [PATCH v5 12/18] dump/dump: Add section string table support, Janosch Frank, 2022/08/11
- [PATCH v5 11/18] dump: Swap segment and section header locations,
Janosch Frank <=
- [PATCH v5 08/18] dump: Rename write_elf*_phdr_note to prepare_elf*_phdr_note, Janosch Frank, 2022/08/11
- [PATCH v5 01/18] dump: Replace opaque DumpState pointer with a typed one, Janosch Frank, 2022/08/11
- [PATCH v5 13/18] dump/dump: Add arch section support, Janosch Frank, 2022/08/11