BaseTools/PiFirmwareFile: fix undefined behavior in SECTION_SIZE

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

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1710
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Laszlo Ersek 2019-04-12 15:10:09 +02:00
parent fc76bbd94d
commit d3b3ee09a6
1 changed files with 9 additions and 2 deletions

View File

@ -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()