diff options
| author | Mingjie Shen <shen497@purdue.edu> | 2026-09-01 01:14:24 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2026-09-03 13:36:41 +0300 |
| commit | 52f19aacd569aa0f1f264108ed518a96657f9088 (patch) | |
| tree | d0dd59a9aae0be99dc2934ea99c5e693b18cc1d0 /BaseTools/Source/Python/Workspace/MetaFileParser.py | |
| parent | d68e8b775ffd142aa93648b4d45255d3a8233874 (diff) | |
| download | edk2-52f19aacd569aa0f1f264108ed518a96657f9088.tar.xz | |
BaseTools/GenSec: Use SECTION_SIZE to read section size
Replace the open-coded read of the 3-byte section Size[] field with
the SECTION_SIZE() macro from Pi/PiFirmwareFile.h. The macro reads
exactly the three Size[] bytes (endianness-safe) instead of a 4-byte
load that over-reads the adjacent byte. No functional change.
Verified by building BaseTools and running GenSec:
python3 BaseTools/Edk2ToolsBuild.py -t GCC
GenSec -s EFI_SECTION_RAW -o out.sec in.bin # in.bin: 100 bytes
out.sec is 104 bytes: the 100-byte payload plus the 4-byte
EFI_COMMON_SECTION_HEADER. The Size field of the header reads
0x000068, matching out.sec's size that is calculated by SECTION_SIZE.
Generated with the following Coccinelle semantic patch:
```smpl
@@
EFI_COMMON_SECTION_HEADER *E;
typedef UINT32;
@@
(
- *(UINT32 *)(E->Size) & 0x00FFFFFF
+ SECTION_SIZE (E)
|
- *(UINT32 *)E->Size & 0x00FFFFFF
+ SECTION_SIZE (E)
)
```
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py')
0 files changed, 0 insertions, 0 deletions
