public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: brucex.wang@intel.com
To: devel@edk2.groups.io
Cc: BruceX Wang <brucex.wang@intel.com>,
	Guo Dong <guo.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Sean Rhodes <sean@starlabs.systems>,
	James Lu <james.lu@intel.com>
Subject: [PATCH] UefiPayloadPkg: Fix incorrect code on AddSectionHeader
Date: Wed, 14 Jun 2023 22:00:05 +0800	[thread overview]
Message-ID: <9d76dda748aba4b4614d99227d225c87157c5f84.1686750331.git.brucex.wang@intel.com> (raw)

From: BruceX Wang <brucex.wang@intel.com>

Fix incorrect code on AddSectionHeader32() and AddSectionHeader64()

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Signed-off-by: BruceX Wang <brucex.wang@intel.com>
---
 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, SectionHeaderEntrySize, Index, R
         # if RemoveNameOffset != 0 that is remove function.
         if (RemoveNameOffset != 0):
             if (unpacked_header.sh_name > RemoveNameOffset):
-                unpacked_header.sh_name -= RemoveNameOffset
+                unpacked_header.sh_name -= len (SectionName)
             # Modify size of name string section entry in section entry.
             if (Index == StringIndexNumber):
                 unpacked_header.sh_size -= len (SectionName)
@@ -298,7 +298,7 @@ def AddSectionHeader32(SHentry, NewUPLEntrylen, SectionHeaderEntrySize, Index, R
         # if RemoveNameOffset != 0 that is remove function.
         if (RemoveNameOffset != 0):
             if (unpacked_header.sh_name > RemoveNameOffset):
-                unpacked_header.sh_name -= RemoveNameOffset
+                unpacked_header.sh_name -= len (SectionName)
             # Modify size of name string section entry in section entry.
             if (Index == StringIndexNumber):
                 unpacked_header.sh_size -= len (SectionName)
@@ -710,7 +710,7 @@ def AddSection32(UniversalPayloadEntry, AddSectionName, ElfHeaderOffset, Section
         ElfHeaderSize = 52
         ElfHandPH = ElfHeaderSize + (elf_header.e_phnum * elf_header.e_phentsize)
         NewUPLEntry = UPLEntry[:ElfHandPH]
-        # Keep Section header and program header table, AddSection64() only recombined section and section header.
+        # Keep Section header and program header table, AddSection32() only recombined section and section header.
         NewUPLEntry = bytearray(NewUPLEntry)
         # Sections is recombined.
         # 1. name of added section is added in name string section.
-- 
2.39.1.windows.1


             reply	other threads:[~2023-06-14 14:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 14:00 brucex.wang [this message]
2023-06-14 14:07 ` [PATCH] UefiPayloadPkg: Fix incorrect code on AddSectionHeader Wang, BruceX
2023-06-14 14:08   ` Guo, Gua

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-list 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=9d76dda748aba4b4614d99227d225c87157c5f84.1686750331.git.brucex.wang@intel.com \
    --to=devel@edk2.groups.io \
    /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