diff options
| author | Michael D Kinney <michael.d.kinney@intel.com> | 2026-05-19 22:51:42 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2026-06-22 18:18:12 +0300 |
| commit | d6eb4c4965328395582b5f7c54997dad8fcf669c (patch) | |
| tree | 8eb6e687f25df4e44ae4880f9825e29f22258d14 /BaseTools/Source/Python | |
| parent | 80bf0137c1ef00047769f3ea7b05f93ec9696b1c (diff) | |
| download | edk2-d6eb4c4965328395582b5f7c54997dad8fcf669c.tar.xz | |
BaseTools/GenFds: Allow PE32 section keywords in any order
Replace sequential if-statements for Align, Xip, and
RELOCS_STRIPPED/RELOCS_RETAINED parsing in _GetEfiSection() with a
while-loop that accepts these keywords in any permutation. Previously,
specifying Xip before Align in a [Rule] PE32 section caused a Python
stack trace.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'BaseTools/Source/Python')
| -rw-r--r-- | BaseTools/Source/Python/GenFds/FdfParser.py | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index d8d09946fd..f61d0f299d 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -3893,33 +3893,34 @@ class FdfParser: raise Warning.Expected("Build number", self.FileName, self.CurrentLineNumber)
EfiSectionObj.BuildNum = self._Token
- if self._GetAlignment():
- if self._Token not in ALIGNMENTS:
- raise Warning("Incorrect alignment '%s'" % self._Token, self.FileName, self.CurrentLineNumber)
- if self._Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
- raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
- EfiSectionObj.Alignment = self._Token
-
- if self._IsKeyword("Xip"):
- if not self._IsToken(TAB_EQUAL_SPLIT):
- raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
- if not self._GetNextWord():
- raise Warning.Expected("Xip value (TRUE/FALSE)", self.FileName, self.CurrentLineNumber)
- XipValue = self._Token.strip().upper()
- if XipValue not in {"TRUE", "FALSE"}:
- raise Warning("Invalid Xip value '%s'" % XipValue, self.FileName, self.CurrentLineNumber)
- EfiSectionObj.Xip = XipValue
-
- if self._IsKeyword('RELOCS_STRIPPED') or self._IsKeyword('RELOCS_RETAINED'):
- if self._SectionCouldHaveRelocFlag(EfiSectionObj.SectionType):
- if self._Token == 'RELOCS_STRIPPED':
- EfiSectionObj.KeepReloc = False
+ while True:
+ if self._GetAlignment():
+ if self._Token not in ALIGNMENTS:
+ raise Warning("Incorrect alignment '%s'" % self._Token, self.FileName, self.CurrentLineNumber)
+ if self._Token == 'Auto' and (not SectionName == BINARY_FILE_TYPE_PE32) and (not SectionName == BINARY_FILE_TYPE_TE):
+ raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
+ EfiSectionObj.Alignment = self._Token
+ elif self._IsKeyword("Xip"):
+ if not self._IsToken(TAB_EQUAL_SPLIT):
+ raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
+ if not self._GetNextWord():
+ raise Warning.Expected("Xip value (TRUE/FALSE)", self.FileName, self.CurrentLineNumber)
+ XipValue = self._Token.strip().upper()
+ if XipValue not in {"TRUE", "FALSE"}:
+ raise Warning("Invalid Xip value '%s'" % XipValue, self.FileName, self.CurrentLineNumber)
+ EfiSectionObj.Xip = XipValue
+ elif self._IsKeyword('RELOCS_STRIPPED') or self._IsKeyword('RELOCS_RETAINED'):
+ if self._SectionCouldHaveRelocFlag(EfiSectionObj.SectionType):
+ if self._Token == 'RELOCS_STRIPPED':
+ EfiSectionObj.KeepReloc = False
+ else:
+ EfiSectionObj.KeepReloc = True
+ if Obj.KeepReloc is not None and Obj.KeepReloc != EfiSectionObj.KeepReloc:
+ raise Warning("Section type %s has reloc strip flag conflict with Rule" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber)
else:
- EfiSectionObj.KeepReloc = True
- if Obj.KeepReloc is not None and Obj.KeepReloc != EfiSectionObj.KeepReloc:
- raise Warning("Section type %s has reloc strip flag conflict with Rule" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber)
+ raise Warning("Section type %s could not have reloc strip flag" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber)
else:
- raise Warning("Section type %s could not have reloc strip flag" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber)
+ break
if self._IsToken(TAB_VALUE_SPLIT):
|
