From nobody Tue Feb 10 03:39:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666774649; cv=none; d=zohomail.com; s=zohoarc; b=anBWmOGzKYTOZLsTWEKfZBDirmdnSx0iG4P76gZYp5W6BQxlonStkTBIQzyWREH2O4tSQBjJrOWAZY/Wptm6FabmdpHhfLfluUwYBohOoLEvRjqKS+UMpfaE70WR+NWeS79hsXOwWulfXBME6ggeCpinOGBMBb0/Jr1JeC4iXTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666774649; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=51si67oMLHfMigUNv16V9jLVZNglhcVFQhgyfCf3TyU=; b=ED+33p+sKAjNOlHIECSaDJy9tphWddw1KTRaUYNjEsVrReJHyyRlqP1zw+bv6+Xq9p5LWf2aqcRJeMAkhCYUXguA32RaRTaIZQgg4ggly6GivrS/t544zM3acSlf5p3ucZkjWMkFD14KdKSRAOcezpSwxeFTi5NrpOpclHAB7Kw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666774649539538.7832031194306; Wed, 26 Oct 2022 01:57:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oncDX-0003W7-TR; Wed, 26 Oct 2022 04:56:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oncCd-0008G8-Bh for qemu-devel@nongnu.org; Wed, 26 Oct 2022 04:56:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oncCb-0000KA-Q3 for qemu-devel@nongnu.org; Wed, 26 Oct 2022 04:55:59 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-160-3aWeoHCKMOuAOunSkzkHdA-1; Wed, 26 Oct 2022 04:55:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9985D1C07827; Wed, 26 Oct 2022 08:55:52 +0000 (UTC) Received: from localhost (unknown [10.39.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id CED212166B2B; Wed, 26 Oct 2022 08:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666774556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=51si67oMLHfMigUNv16V9jLVZNglhcVFQhgyfCf3TyU=; b=EOs/y0KeBMYJBx3ZBPmo2FpbHj/yoyiXG6AK8D1Q3plUH3grQRE15kW9DsJHTfr2sfOaK/ Vt6BnJvgnvJs8d8mAi8tIjmaKm9rfqoh6JFLyrTOmmtk3oojjW5o8deZtY6WhHM9tvM+0e DlW9/HCBXynRUjxZc6iNhtD9iBpLhY4= X-MC-Unique: 3aWeoHCKMOuAOunSkzkHdA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Cornelia Huck , Halil Pasic , Christian Borntraeger , Eric Farman , Thomas Huth , David Hildenbrand , qemu-s390x@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Janosch Frank Subject: [PULL v3 02/11] dump: Write ELF section headers right after ELF header Date: Wed, 26 Oct 2022 12:55:30 +0400 Message-Id: <20221026085540.254253-3-marcandre.lureau@redhat.com> In-Reply-To: <20221026085540.254253-1-marcandre.lureau@redhat.com> References: <20221026085540.254253-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.517, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666774650917100003 From: Janosch Frank Let's start bundling the writes of the headers and of the data so we have a clear ordering between them. Since the ELF header uses offsets to the headers we can freely order them. Signed-off-by: Janosch Frank Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20221017083822.43118-3-frankja@linux.ibm.com> --- dump/dump.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index e7a3b54ebe..b168a25321 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -583,6 +583,8 @@ static void dump_begin(DumpState *s, Error **errp) * -------------- * | elf header | * -------------- + * | sctn_hdr | + * -------------- * | PT_NOTE | * -------------- * | PT_LOAD | @@ -591,8 +593,6 @@ static void dump_begin(DumpState *s, Error **errp) * -------------- * | PT_LOAD | * -------------- - * | sec_hdr | - * -------------- * | elf note | * -------------- * | memory | @@ -608,20 +608,20 @@ static void dump_begin(DumpState *s, Error **errp) return; } =20 - /* write PT_NOTE to vmcore */ - write_elf_phdr_note(s, errp); + /* write section headers to vmcore */ + write_elf_section_headers(s, errp); if (*errp) { return; } =20 - /* write all PT_LOADs to vmcore */ - write_elf_phdr_loads(s, errp); + /* write PT_NOTE to vmcore */ + write_elf_phdr_note(s, errp); if (*errp) { return; } =20 - /* write section headers to vmcore */ - write_elf_section_headers(s, errp); + /* write all PT_LOADs to vmcore */ + write_elf_phdr_loads(s, errp); if (*errp) { return; } @@ -1868,16 +1868,13 @@ static void dump_init(DumpState *s, int fd, bool ha= s_format, } =20 if (dump_is_64bit(s)) { - s->phdr_offset =3D sizeof(Elf64_Ehdr); - s->shdr_offset =3D s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_n= um; - s->note_offset =3D s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_n= um; - s->memory_offset =3D s->note_offset + s->note_size; + s->shdr_offset =3D sizeof(Elf64_Ehdr); + s->phdr_offset =3D s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_n= um; + s->note_offset =3D s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_n= um; } else { - - s->phdr_offset =3D sizeof(Elf32_Ehdr); - s->shdr_offset =3D s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_n= um; - s->note_offset =3D s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_n= um; - s->memory_offset =3D s->note_offset + s->note_size; + s->shdr_offset =3D sizeof(Elf32_Ehdr); + s->phdr_offset =3D s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_n= um; + s->note_offset =3D s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_n= um; } =20 return; --=20 2.37.3