From: Janosch Frank <frankja@linux.ibm.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
"Bonzini, Paolo" <pbonzini@redhat.com>,
mhartmay@linux.ibm.com,
Christian Borntraeger <borntraeger@linux.ibm.com>,
imbrenda@linux.ibm.com, Halil Pasic <pasic@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>,
"open list:S390 SCLP-backed..." <qemu-s390x@nongnu.org>,
"Henderson, Richard" <richard.henderson@linaro.org>
Subject: Re: [PATCH v2 05/11] dump/dump: Add section string table support
Date: Thu, 14 Jul 2022 13:53:42 +0200 [thread overview]
Message-ID: <39c9c903-a2dc-6799-b77c-825f9bde069e@linux.ibm.com> (raw)
In-Reply-To: <CAMxuvawZehnqK=UN03nKEdtwL7yySKgb6GG5GV1S3CT_d0_iyg@mail.gmail.com>
On 7/13/22 17:58, Marc-André Lureau wrote:
> Hi
>
> On Wed, Jul 13, 2022 at 5:07 PM Janosch Frank <frankja@linux.ibm.com> wrote:
>>
>> Time to add a bit more descriptiveness to the dumps.
>
> Please add some more description & motivation to the patch (supposedly
> necessary for next patches), and explain that it currently doesn't
> change the dump (afaict).
How about:
As sections don't have a type like the notes do we need another way to
determine their contents. The string table allows us to assign each
section an identification string which architectures can then use to tag
their sections with.
There will be no string table if the architecture doesn't add custom
sections which are introduced in a following patch.
>>
>> - 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;
>> - } 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;
>> + /*
>> + * calculate shdr_num and elf_section_data_size so we know the offsets and
>> + * sizes of all parts.
>> + *
>> + * If phdr_num overflowed we have at least one section header
>> + * More sections/hdrs can be added by the architectures
>> + */
>> + if (s->shdr_num > 1) {
>> + /* Reserve the string table */
>> + s->shdr_num += 1;
>> }
>>
>> + tmp = (s->phdr_num == PN_XNUM) ? s->sh_info : s->phdr_num;
>> + if (dump_is_64bit(s)) {
>> + 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) * tmp;
>> + } else {
>> + 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) * tmp;
>> + }
>> + s->memory_offset = s->note_offset + s->note_size;
>
> I suggest to split this in a different patch. It's not obvious that
> you can change phdr_offset / shdr_offset, it deserves a comment.
Right, will do
>
>> + s->section_offset = s->memory_offset + s->total_size;
>> +
>> return;
>>
>> cleanup:
>> diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
>> index 8379e29ef6..2c25c7d309 100644
>> --- a/include/sysemu/dump.h
>> +++ b/include/sysemu/dump.h
>> @@ -178,6 +178,7 @@ typedef struct DumpState {
>> void *elf_section_hdrs;
>> uint64_t elf_section_data_size;
>> void *elf_section_data;
>> + GArray *string_table_buf; /* String table section */
>>
>> uint8_t *note_buf; /* buffer for notes */
>> size_t note_buf_offset; /* the writing place in note_buf */
>> --
>> 2.34.1
>>
>
next prev parent reply other threads:[~2022-07-14 11:55 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 13:03 [PATCH v2 00/11] dump: Add arch section and s390x PV dump Janosch Frank
2022-07-13 13:03 ` [PATCH v2 01/11] dump: Cleanup memblock usage Janosch Frank
2022-07-13 15:09 ` Marc-André Lureau
2022-07-13 15:30 ` Janosch Frank
2022-07-13 15:35 ` Marc-André Lureau
2022-07-14 9:40 ` Janosch Frank
2022-07-15 8:34 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 02/11] dump: Allocate header Janosch Frank
2022-07-13 15:20 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 03/11] dump: Split write of section headers and data and add a prepare step Janosch Frank
2022-07-13 15:31 ` Marc-André Lureau
2022-07-14 11:45 ` Janosch Frank
2022-07-13 13:03 ` [PATCH v2 04/11] dump: Reorder struct DumpState Janosch Frank
2022-07-13 15:46 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 05/11] dump/dump: Add section string table support Janosch Frank
2022-07-13 15:58 ` Marc-André Lureau
2022-07-14 11:53 ` Janosch Frank [this message]
2022-07-14 11:55 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 06/11] dump/dump: Add arch section support Janosch Frank
2022-07-13 16:02 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 07/11] linux header sync Janosch Frank
2022-07-13 16:03 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 08/11] s390x: Add protected dump cap Janosch Frank
2022-07-13 13:03 ` [PATCH v2 09/11] s390x: Introduce PV query interface Janosch Frank
2022-07-15 8:10 ` Marc-André Lureau
2022-07-15 8:18 ` Janosch Frank
2022-07-15 8:23 ` Marc-André Lureau
2022-07-13 13:03 ` [PATCH v2 10/11] s390x: Add KVM PV dump interface Janosch Frank
2022-07-13 13:03 ` [PATCH v2 11/11] s390x: pv: Add dump support Janosch Frank
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=39c9c903-a2dc-6799-b77c-825f9bde069e@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=marcandre.lureau@redhat.com \
--cc=mhartmay@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.