[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/13] dump: Remove the section if when calculating the memory off
From: |
marcandre . lureau |
Subject: |
[PULL 04/13] dump: Remove the section if when calculating the memory offset |
Date: |
Thu, 21 Apr 2022 16:48:26 +0400 |
From: Janosch Frank <frankja@linux.ibm.com>
When s->shdr_num is 0 we'll add 0 bytes of section headers which is
equivalent to not adding section headers but with the multiplication
we can remove a if/else.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220330123603.107120-5-frankja@linux.ibm.com>
---
dump/dump.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index 285ed4475b0d..9c80680eb2a4 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1817,23 +1817,15 @@ static void dump_init(DumpState *s, int fd, bool
has_format,
}
if (s->dump_info.d_class == ELFCLASS64) {
- if (s->shdr_num) {
- s->memory_offset = sizeof(Elf64_Ehdr) +
- sizeof(Elf64_Phdr) * s->phdr_num +
- sizeof(Elf64_Shdr) * s->shdr_num + s->note_size;
- } else {
- s->memory_offset = sizeof(Elf64_Ehdr) +
- sizeof(Elf64_Phdr) * s->phdr_num + s->note_size;
- }
+ s->memory_offset = sizeof(Elf64_Ehdr) +
+ sizeof(Elf64_Phdr) * s->phdr_num +
+ sizeof(Elf64_Shdr) * s->shdr_num +
+ s->note_size;
} else {
- if (s->shdr_num) {
- s->memory_offset = sizeof(Elf32_Ehdr) +
- sizeof(Elf32_Phdr) * s->phdr_num +
- sizeof(Elf32_Shdr) * s->shdr_num + s->note_size;
- } else {
- s->memory_offset = sizeof(Elf32_Ehdr) +
- sizeof(Elf32_Phdr) * s->phdr_num + s->note_size;
- }
+ s->memory_offset = sizeof(Elf32_Ehdr) +
+ sizeof(Elf32_Phdr) * s->phdr_num +
+ sizeof(Elf32_Shdr) * s->shdr_num +
+ s->note_size;
}
return;
--
2.35.1.693.g805e0a68082a
- [PULL 00/13] Dump patches, marcandre . lureau, 2022/04/21
- [PULL 01/13] dump: Use ERRP_GUARD(), marcandre . lureau, 2022/04/21
- [PULL 02/13] dump: Remove the sh_info variable, marcandre . lureau, 2022/04/21
- [PULL 04/13] dump: Remove the section if when calculating the memory offset,
marcandre . lureau <=
- [PULL 03/13] dump: Introduce shdr_num to decrease complexity, marcandre . lureau, 2022/04/21
- [PULL 05/13] dump: Add more offset variables, marcandre . lureau, 2022/04/21
- [PULL 06/13] dump: Introduce dump_is_64bit() helper function, marcandre . lureau, 2022/04/21
- [PULL 07/13] dump: Consolidate phdr note writes, marcandre . lureau, 2022/04/21
- [PULL 08/13] dump: Cleanup dump_begin write functions, marcandre . lureau, 2022/04/21
- [PULL 10/13] include/qemu: rename Windows context definitions to expose bitness, marcandre . lureau, 2022/04/21
- [PULL 09/13] dump: Consolidate elf note function, marcandre . lureau, 2022/04/21
- [PULL 11/13] dump/win_dump: add helper macros for Windows dump header access, marcandre . lureau, 2022/04/21
- [PULL 12/13] include/qemu: add 32-bit Windows dump structures, marcandre . lureau, 2022/04/21
- [PULL 13/13] dump/win_dump: add 32-bit guest Windows support, marcandre . lureau, 2022/04/21