summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinney, Michael D <michael.d.kinney@intel.com>2018-06-08 21:15:26 -0700
committerKinney, Michael D <michael.d.kinney@intel.com>2018-06-14 15:43:22 -0700
commit8e965809998bfb674515e9d13d93a4fcec0f95c5 (patch)
treeefa0282b400174ac61e99f353536232e129324df
parentb2e043b6895d70c57ef390d160e05c9d6f44298d (diff)
downloadedk2-8e965809998bfb674515e9d13d93a4fcec0f95c5.tar.gz
edk2-8e965809998bfb674515e9d13d93a4fcec0f95c5.tar.bz2
edk2-8e965809998bfb674515e9d13d93a4fcec0f95c5.zip
BaseTools/BinToPcd: --offset must be 8-byte aligned
https://bugzilla.tianocore.org/show_bug.cgi?id=974 https://bugzilla.tianocore.org/show_bug.cgi?id=965 Update help to state that --offset must be 8-byte aligned. Verify that --offset is 8-byte aligned and print an error message if it is not 8-byte aligned. Cc: Yanyan Sun <yanyan.sun@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
-rw-r--r--BaseTools/Scripts/BinToPcd.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
index 7e3380190e..54cb844d68 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -89,7 +89,7 @@ if __name__ == '__main__':
parser.add_argument("-m", "--max-size", dest = 'MaxSize', type = ValidateUnsignedInteger,
help = "Maximum size of the PCD. Ignored with --type HII.")
parser.add_argument("-f", "--offset", dest = 'Offset', type = ValidateUnsignedInteger,
- help = "VPD offset if --type is VPD. UEFI Variable offset if --type is HII.")
+ help = "VPD offset if --type is VPD. UEFI Variable offset if --type is HII. Must be 8-byte aligned.")
parser.add_argument("-n", "--variable-name", dest = 'VariableName',
help = "UEFI variable name. Only used with --type HII.")
parser.add_argument("-g", "--variable-guid", type = ValidateGuidName, dest = 'VariableGuid',
@@ -178,6 +178,12 @@ if __name__ == '__main__':
Pcd = ' %s|*|%d|%s' % (args.PcdName, args.MaxSize, PcdValue)
else:
#
+ # --offset value must be 8-byte aligned
+ #
+ if (args.Offset % 8) != 0:
+ print 'BinToPcd: error: argument --offset must be 8-byte aligned.'
+ sys.exit()
+ #
# Use the --offset value provided.
#
Pcd = ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, PcdValue)
@@ -194,6 +200,12 @@ if __name__ == '__main__':
# Use UEFI Variable offset of 0 if --offset is not provided
#
args.Offset = 0
+ #
+ # --offset value must be 8-byte aligned
+ #
+ if (args.Offset % 8) != 0:
+ print 'BinToPcd: error: argument --offset must be 8-byte aligned.'
+ sys.exit()
Pcd = ' %s|L"%s"|%s|%d|%s' % (args.PcdName, args.VariableName, args.VariableGuid, args.Offset, PcdValue)
if args.Verbose:
print 'BinToPcd: Convert binary file to PCD statement compatible with PCD sections'