Sync SECTION_SIZE() from MdePkg to BaseTools, from an earlier patch in
this series.

Cc: Bob Feng <bob.c.f...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Cc: Yonghong Zhu <yonghong....@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1710
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---

Notes:
    v2:
    
    - sync with the v2 MdePkg/PiFirmwareFile SECTION_SIZE patch

 BaseTools/Source/C/Include/Common/PiFirmwareFile.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h 
b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
index 5bc871df4855..7d8acb669b69 100644
--- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
+++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
@@ -300,8 +300,15 @@ typedef struct {
   CHAR16                      VersionString[1];
 } EFI_VERSION_SECTION2;
 
-#define SECTION_SIZE(SectionHeaderPtr) \
-    ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) 
SectionHeaderPtr)->Size) & 0x00ffffff))
+//
+// The argument passed as the SectionHeaderPtr parameter to the SECTION_SIZE()
+// function-like macro below must not have side effects: SectionHeaderPtr is
+// evaluated multiple times.
+//
+#define SECTION_SIZE(SectionHeaderPtr) ((UINT32) ( \
+    (((EFI_COMMON_SECTION_HEADER *) (SectionHeaderPtr))->Size[0]      ) | \
+    (((EFI_COMMON_SECTION_HEADER *) (SectionHeaderPtr))->Size[1] <<  8) | \
+    (((EFI_COMMON_SECTION_HEADER *) (SectionHeaderPtr))->Size[2] << 16)))
 
 #pragma pack()
 
-- 
2.19.1.3.g30247aa5d201



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39309): https://edk2.groups.io/g/devel/message/39309
Mute This Topic: https://groups.io/mt/31233851/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to