From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.12786.1686751214230976019 for ; Wed, 14 Jun 2023 07:00:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=USrYC9JS; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: brucex.wang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686751214; x=1718287214; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=AOGfraWePfXOtZZFkh4PfWCRCmKcDdlio+xdpPKUNnA=; b=USrYC9JSWHt1Pz6f4s0xmcBIbOpYhPySEFLve3iL6j6ooVhqkz1j1WTN QT5wYyrT9OmxxA9IPa2jqwhAh9Hbb2i7Ha0peBfFsF17IjLGl96fnoBsq E8Wfyj+R6ULn1pODxR1Ac+gA8W68Gl8Z7qtXkg2plfZaW6YeS4CvZoINC 7Fd9PkwMGiLrFlIBhANw9TnDB/73ipaZGu7DboXaVGVEKTMybHGatgUem lGLFH+9zapF/7Hit0xOP4HrONqj2wXVCRgczgpJSPkn9gbmOOKUH4w6ia 5k7AR1oer6pWfFBgZwfq55YbZmaYjg12FrLdeZ5yqQ30v8NyHbYdvnh2R Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="348276965" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="348276965" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 07:00:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="745084401" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="745084401" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by orsmga001.jf.intel.com with ESMTP; 14 Jun 2023 07:00:11 -0700 From: brucex.wang@intel.com To: devel@edk2.groups.io Cc: BruceX Wang , Guo Dong , Ray Ni , Sean Rhodes , James Lu Subject: [PATCH] UefiPayloadPkg: Fix incorrect code on AddSectionHeader Date: Wed, 14 Jun 2023 22:00:05 +0800 Message-Id: <9d76dda748aba4b4614d99227d225c87157c5f84.1686750331.git.brucex.wang@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: BruceX Wang Fix incorrect code on AddSectionHeader32() and AddSectionHeader64() Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Signed-off-by: BruceX Wang --- UefiPayloadPkg/Tools/ElfFv.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UefiPayloadPkg/Tools/ElfFv.py b/UefiPayloadPkg/Tools/ElfFv.py index a3d5bf08b9..3f0f9272a7 100644 --- a/UefiPayloadPkg/Tools/ElfFv.py +++ b/UefiPayloadPkg/Tools/ElfFv.py @@ -267,7 +267,7 @@ def AddSectionHeader64(SHentry, NewUPLEntrylen, Section= HeaderEntrySize, Index, R # if RemoveNameOffset !=3D 0 that is remove function.=0D if (RemoveNameOffset !=3D 0):=0D if (unpacked_header.sh_name > RemoveNameOffset):=0D - unpacked_header.sh_name -=3D RemoveNameOffset=0D + unpacked_header.sh_name -=3D len (SectionName)=0D # Modify size of name string section entry in section entry.=0D if (Index =3D=3D StringIndexNumber):=0D unpacked_header.sh_size -=3D len (SectionName)=0D @@ -298,7 +298,7 @@ def AddSectionHeader32(SHentry, NewUPLEntrylen, Section= HeaderEntrySize, Index, R # if RemoveNameOffset !=3D 0 that is remove function.=0D if (RemoveNameOffset !=3D 0):=0D if (unpacked_header.sh_name > RemoveNameOffset):=0D - unpacked_header.sh_name -=3D RemoveNameOffset=0D + unpacked_header.sh_name -=3D len (SectionName)=0D # Modify size of name string section entry in section entry.=0D if (Index =3D=3D StringIndexNumber):=0D unpacked_header.sh_size -=3D len (SectionName)=0D @@ -710,7 +710,7 @@ def AddSection32(UniversalPayloadEntry, AddSectionName,= ElfHeaderOffset, Section ElfHeaderSize =3D 52=0D ElfHandPH =3D ElfHeaderSize + (elf_header.e_phnum * elf_header.e_p= hentsize)=0D NewUPLEntry =3D UPLEntry[:ElfHandPH]=0D - # Keep Section header and program header table, AddSection64() onl= y recombined section and section header.=0D + # Keep Section header and program header table, AddSection32() onl= y recombined section and section header.=0D NewUPLEntry =3D bytearray(NewUPLEntry)=0D # Sections is recombined.=0D # 1. name of added section is added in name string section.=0D --=20 2.39.1.windows.1