On 7/26/22 11:22, Janosch Frank wrote: > By splitting the writing of the section headers and (future) section > data we prepare for the addition of a string table section and > architecture sections. > > At the same time we move the writing of the section to the end of the > dump process. This allows the upcoming architecture section code to > add data after all of the common dump data has been written. > > Signed-off-by: Janosch Frank <fran...@linux.ibm.com> > --- > dump/dump.c | 112 ++++++++++++++++++++++++++++++++---------- > include/sysemu/dump.h | 4 ++ > 2 files changed, 90 insertions(+), 26 deletions(-) > > diff --git a/dump/dump.c b/dump/dump.c > index 8a7ce95610..a6bb7bfa21 100644 > --- a/dump/dump.c > +++ b/dump/dump.c > @@ -342,30 +342,69 @@ static void write_elf_phdr_note(DumpState *s, Error > **errp) > } > } >
[...] > + > +static void prepare_elf_section_hdrs(DumpState *s) > +{ > + size_t len, sizeof_shdr; > + > + /* > + * Section ordering: > + * - HDR zero (if needed) > + */ > + sizeof_shdr = dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_Shdr); > + len = sizeof_shdr * s->shdr_num; > + s->elf_section_hdrs = g_malloc0(len); > + > + /* Write special section first */ > + if (s->phdr_num == PN_XNUM) { Should be >= right? > + prepare_elf_section_hdr_zero(s); > + } > +} > + [...]