From: Janosch Frank <frankja@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com, richard.henderson@linaro.org,
pbonzini@redhat.com
Subject: [PATCH v3 4/9] dump: Remove the section if when calculating the memory offset
Date: Wed, 30 Mar 2022 12:35:58 +0000 [thread overview]
Message-ID: <20220330123603.107120-5-frankja@linux.ibm.com> (raw)
In-Reply-To: <20220330123603.107120-1-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>
---
dump/dump.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index cd11dec0f4..bdff651da4 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1808,23 +1808,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.32.0
next prev parent reply other threads:[~2022-03-30 12:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 12:35 [PATCH v3 0/9] dump: Cleanup and consolidation Janosch Frank
2022-03-30 12:35 ` [PATCH v3 1/9] dump: Use ERRP_GUARD() Janosch Frank
2022-03-31 8:59 ` Marc-André Lureau
2022-03-31 9:48 ` Janosch Frank
2022-03-31 10:11 ` Marc-André Lureau
2022-03-30 12:35 ` [PATCH v3 2/9] dump: Remove the sh_info variable Janosch Frank
2022-03-31 8:58 ` Marc-André Lureau
2022-03-31 9:47 ` Janosch Frank
2022-03-31 13:49 ` Marc-André Lureau
2022-04-07 9:48 ` [PATCH v4] " Janosch Frank
2022-03-30 12:35 ` [PATCH v3 3/9] dump: Introduce shdr_num to decrease complexity Janosch Frank
2022-03-31 8:56 ` Marc-André Lureau
2022-03-30 12:35 ` Janosch Frank [this message]
2022-03-31 8:56 ` [PATCH v3 4/9] dump: Remove the section if when calculating the memory offset Marc-André Lureau
2022-03-30 12:35 ` [PATCH v3 5/9] dump: Add more offset variables Janosch Frank
2022-03-30 12:36 ` [PATCH v3 6/9] dump: Introduce dump_is_64bit() helper function Janosch Frank
2022-03-31 8:56 ` Marc-André Lureau
2022-03-30 12:36 ` [PATCH v3 7/9] dump: Consolidate phdr note writes Janosch Frank
2022-03-31 8:56 ` Marc-André Lureau
2022-03-30 12:36 ` [PATCH v3 8/9] dump: Cleanup dump_begin write functions Janosch Frank
2022-03-31 8:56 ` Marc-André Lureau
2022-03-30 12:36 ` [PATCH v3 9/9] dump: Consolidate elf note function Janosch Frank
2022-03-31 8:56 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220330123603.107120-5-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).