summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source
Commit message (Collapse)AuthorAgeFilesLines
* BaseTools: Remove equality operator with NoneCarsey, Jaben2018-03-30120-1043/+1043
| | | | | | | | | | replace "== None" with "is None" and "!= None" with "is not None" Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: compare GUID value should not case-sensitiveBin Wang2018-03-291-1/+1
| | | | | | | | | | | | build report error when the same Guid value in FDF file use lowercase, in tools_def.txt file use uppercase. The guid value's compare should not case-sensitive. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bin Wang <binx.a.wang@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: refactor repeated RegExp when no special searching is needed.Carsey, Jaben2018-03-291-4/+5
| | | | | | | | | | use str.replace and try/except. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: dont use enumerate when un-neededCarsey, Jaben2018-03-293-5/+5
| | | | | | | | | | | Since we only use the item from the list and not the numeric value, dont bother with enumerate() Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: move regular expression compile out of function call.Carsey, Jaben2018-03-291-6/+6
| | | | | | | | | | move to the root of the file and dont recompile. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: expression can use single in instead of 3 API calls.Carsey, Jaben2018-03-291-1/+1
| | | | | | | | | | change 3 StartsWith() calls to a single 'in' operation. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: remove local hex number regular expressionCarsey, Jaben2018-03-292-5/+3
| | | | | | | | | | Change to using the new shared hex number regular expression Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Use precompiled RegExpCarsey, Jaben2018-03-291-3/+4
| | | | | | | | | | avoid recompiling the regular expression for each use in a while loop Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: use new shared GUID regular expressionsCarsey, Jaben2018-03-294-11/+9
| | | | | | | | | | | remove local variables that are GUID matching and replace with shared expression. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: GlobalData Add a regular expression for a hex numberCarsey, Jaben2018-03-291-0/+2
| | | | | | | | | | add a shared precompiled regular expression Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Add new RegExp for future useCarsey, Jaben2018-03-291-0/+2
| | | | | | | | | | | Add a precompiled RegExp for 4 hex chars. v2: fixed incorrect numbers of {} Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Regular Expressions refactor out the hex char for later reuseCarsey, Jaben2018-03-291-1/+2
| | | | | | | | | | | | | move hex character info from GUID expressions into seperate variable to facilitate reuse. I had a type with insufficient {} in the first version. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: add GUID pattern to global dataCarsey, Jaben2018-03-291-0/+7
| | | | | | | | | | add a shared global regular expression for GUID matching Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: GlobalData share same MACRO name definitionCarsey, Jaben2018-03-291-3/+6
| | | | | | | | | | use the same MACRO name definition across shared regular expression patterns. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: FdfParser and FdfParserLite share reg expCarsey, Jaben2018-03-292-4/+5
| | | | | | | | | | | | FdfParser can share regular expression from FdfParserLite. reduce overlap and reduce recompile of the same expression. v2: fix missed replacement of Pattern with shared variable Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Update Rsa2048Sha256Sign to use openssl dgst optionLiming Gao2018-03-281-3/+3
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Qin Long <qin.long@intel.com> Reviewed-by: Qin Long <qin.long@intel.com>
* BaseTools: Update Rsa2048Sha256Sign to use openssl standard optionsLiming Gao2018-03-271-2/+2
| | | | | | | | | | | | | | | | | sha256 is not the standard option. It should be replaced by sha -sha256. Otherwise, it doesn't work in MAC OS. In V2, update the option to sha1 -sha256. In late openssl version >= 1.1, there is no sha option, but has sha1,sha256. In previous openssl version < 1.1, there is no sha256, but has sha,sha1. To work with all openssl version, use sha1 -sha256 for it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liao Jui-peng <jui-pengx.liao@intel.com> Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Autogen - modify to use standard parent/child class relationshipsCarsey, Jaben2018-03-271-39/+54
| | | | | | | | | | use __new__ and __init__ to create/manage/initialize objects in standard flow. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools/ECC: Add a new exception supportHess Chen2018-03-271-2/+8
| | | | | | | | Add a new exception support for the checkPoint of no use C type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTool/VfrCompile: Fix potential memory leak issueBi, Dandan2018-03-231-0/+4
| | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=771 Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTool/VfrCompile: make delete[] match with new[]Bi, Dandan2018-03-235-22/+22
| | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=764 Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTool: Fixed the issue of empty PcdDB.BobCF2018-03-231-4/+5
| | | | | | | | | | If there is no dynamic pcds, there should be DB header in the Pcd DataBase. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Add the missing package include directory in PcdValueInit MakefileLiming Gao2018-03-231-1/+3
| | | | | | | | Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Feng Bob C <bob.c.feng@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: FdfParser remove class never used.Carsey, Jaben2018-03-211-15/+0
| | | | | | | | | | the MacroProfile class is never instantiated nor referenced. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: FdfParser & FdfParserLite refactor regular expression for GUIDsCarsey, Jaben2018-03-212-5/+5
| | | | | | | | | | | Instead of recompiling it each time the API is called, just use the global one that exists. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: StrGather remove functions no one callsCarsey, Jaben2018-03-211-30/+0
| | | | | | | | | | simplify the code and remove functions not called anymore Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: StrGather simplify string/int conversion functionsCarsey, Jaben2018-03-211-14/+4
| | | | | | | | | | | use ''.format instead of eval() and use some list comprehension for making list delete some unused variables Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: StrGather has redundant declarationCarsey, Jaben2018-03-211-7/+2
| | | | | | | | | | | remove COMPATIBLE_STRING_TOKEN as it is the same as STRING_TOKEN remove if statement that used one or the other (identical) re Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Override Max size by build Option Pcd for HII typeYonghong Zhu2018-03-211-0/+8
| | | | | | | | | | Current code will generate maxsize for HII type PCD when parser DSC file, while this HII type PCD value maybe override in build command per --pcd option, so the max size need re-calculate. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Fix bug for --pcd VOID* type when no max size is specifiedYonghong Zhu2018-03-201-13/+0
| | | | | | | | | | | | when VOID* type non-structure pcd used in --pcd, and its max size is not specified in DSC or its value is hex value, build break due to the code int(Pcd.MaxDatumSize,10). Now this patch remove this code, because tool will calculate the size info in later phase. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Add Feature Flag Pcd Type into Override listYonghong Zhu2018-03-201-1/+2
| | | | | | | | | when only define the PCD in the DEC file, and use --pcd feature, we also need cover this case for Feature Flag Type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTool: Error handling for PCD datumtype.Feng, Bob C2018-03-192-4/+11
| | | | | | | | | Report error if the Pcd DatumType is wrong. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: RangeExpression - remove unused variableCarsey, Jaben2018-03-191-8/+1
| | | | | | | | | | remove a never used variable. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Expression - remove variableCarsey, Jaben2018-03-191-3/+0
| | | | | | | | | | The InArary variable serves no purpose. just do the work immediately. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Expression - change from series of if to elifCarsey, Jaben2018-03-191-4/+4
| | | | | | | | | | | since the first character of the string cannot be found by multiple if statements, use elif to optomize the behavior. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Expression refactor functionCarsey, Jaben2018-03-191-6/+5
| | | | | | | | | | | The function is about C Names, not C Strings. Move the re.compile outside the function call Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Expression - remove redundant variableCarsey, Jaben2018-03-191-6/+4
| | | | | | | | | | Str is created and not needed. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Fix bug for VOID* DynamicDefault Pcd use Flexible formatYonghong Zhu2018-03-181-8/+0
| | | | | | | | | | | define a flexible pcd format in Dyanmic/DynamicExDefault section, it cause build error. [PcdsDynamicExDefault.common.DEFAULT] pcdToken.Name|{GUID("11111111-2222-42eb-b5eb-fef31d207cb4")} Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Detect structure pcd header file change.BobCF2018-03-171-54/+135
| | | | | | | | | Detect structure pcd header file change Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: --hash --binary-destination generate wrong binary pathFeng, YunhuaX2018-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | Option --hash --binary-destination generate Binaries section in the inf file, but the path of ASL file is begin with Output directory, so need replace Output directory with '', will get the file name RamDisk.aml Incorrect AML file path in inf file on linux: [Binaries.X64] PE32|RamDiskDxe.efi ASL|home/tiano/Desktop/hash/edk2/Build/OvmfX64/RELEASE_GCC5/X64 /MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe/OUTPUT/RamDisk.aml DXE_DEPEX|RamDiskDxe.depex BIN|RamDiskDxeOffset.bin Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: UPT: remove unused variable and inaccessible code.Carsey, Jaben2018-03-151-19/+1
| | | | | | | | | | | gINCLUDE_PATTERN is never used. IncList is always empty. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Get Pcd DatumType from DEC file for --pcdYonghong Zhu2018-03-121-0/+1
| | | | | | | | | It is regression bug that missing the Pcd DatumType info from DEC file for --pcd . Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: GlobalData remove unused variableCarsey, Jaben2018-03-091-2/+1
| | | | | | | | | | gWideStringPattern is not used. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Fix parse OFFSET_OF get wrong offsetFeng, YunhuaX2018-03-091-1/+2
| | | | | | | | | | Fix parse OFFSET_OF get wrong offset Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
* BaseTools: Fix a bug for --pcd used in ConditionalStatement calculateYonghong Zhu2018-03-093-1/+5
| | | | | | | | | Move the GlobalData.BuildOptionPcd before FdfParser() function and add type check for Pcd item. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Update --pcd parser to support flexible pcd formatYonghong Zhu2018-03-098-268/+159
| | | | | | | | This patch update --pcd parser to support flexible pcd format. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools: Fixed Pcd from command line issue.BobCF2018-03-094-47/+31
| | | | | | | | | Save the pcd command line value in Pcd object Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools/header.makefile: revert gcc-8 "-Wno-xxx" options on OSXLaszlo Ersek2018-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I recently added the gcc-8 specific "-Wno-stringop-truncation" and "-Wno-restrict" options to BUILD_CFLAGS, both for "Darwin" (XCODE5 / clang, OSX) and otherwise (gcc, Linux / Cygwin). I also regression-tested the change with gcc-4.8 on Linux -- gcc-4.8 does not know either of the (gcc-8 specific) "-Wno-stringop-truncation" and "-Wno-restrict" options, yet the build completed fine (by GCC design). Regarding OSX, my expectation was that - XCODE5 / clang would either recognize these warnings options (because clang does recognize most -W options of gcc), - or, similarly to gcc, clang would simply ignore the "-Wno-xxx" flags that it didn't recognize. Neither is the case; the new flags have broken the BaseTools build on OSX. Revert them (for OSX only). Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reported-by: Liming Gao <liming.gao@intel.com> Fixes: 1d212a83df0eaf32a6f5d4159beb2d77832e0231 Fixes: 9222154ae7b3eef75ae88cdb56158256227cb929 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
* BaseTools/GenVtf: silence false "stringop-overflow" warning with memcpy()Laszlo Ersek2018-03-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc-8 (which is part of Fedora 28) enables the new warning "-Wstringop-overflow" in "-Wall". This warning is documented in detail at <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the introduction says > Warn for calls to string manipulation functions such as memcpy and > strcpy that are determined to overflow the destination buffer. It breaks the BaseTools build with: > GenVtf.c: In function 'ConvertVersionInfo': > GenVtf.c:132:7: error: 'strncpy' specified bound depends on the length > of the source argument [-Werror=stringop-overflow=] > strncpy (TemStr + 4 - Length, Str, Length); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > GenVtf.c:130:14: note: length computed here > Length = strlen(Str); > ^~~~~~~~~~~ It is a false positive because, while the bound equals the length of the source argument, the destination pointer is moved back towards the beginning of the destination buffer by the same amount (and this amount is range-checked first, so we can't precede the start of the dest buffer). Replace both strncpy() calls with memcpy(). Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Cole Robinson <crobinso@redhat.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reported-by: Cole Robinson <crobinso@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* BaseTools/header.makefile: add "-Wno-restrict"Laszlo Ersek2018-03-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc-8 (which is part of Fedora 28) enables the new warning "-Wrestrict" in "-Wall". This warning is documented in detail at <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the introduction says > Warn when an object referenced by a restrict-qualified parameter (or, in > C++, a __restrict-qualified parameter) is aliased by another argument, > or when copies between such objects overlap. It breaks the BaseTools build (in the Brotli compression library) with: > In function 'ProcessCommandsInternal', > inlined from 'ProcessCommands' at dec/decode.c:1828:10: > dec/decode.c:1781:9: error: 'memcpy' accessing between 17 and 2147483631 > bytes at offsets 16 and 16 overlaps between 17 and 2147483631 bytes at > offset 16 [-Werror=restrict] > memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In function 'ProcessCommandsInternal', > inlined from 'SafeProcessCommands' at dec/decode.c:1833:10: > dec/decode.c:1781:9: error: 'memcpy' accessing between 17 and 2147483631 > bytes at offsets 16 and 16 overlaps between 17 and 2147483631 bytes at > offset 16 [-Werror=restrict] > memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Paolo Bonzini <pbonzini@redhat.com> analyzed the Brotli source in detail, and concluded that the warning is a false positive: > This seems safe to me, because it's preceded by: > > uint8_t* copy_dst = &s->ringbuffer[pos]; > uint8_t* copy_src = &s->ringbuffer[src_start]; > int dst_end = pos + i; > int src_end = src_start + i; > if (src_end > pos && dst_end > src_start) { > /* Regions intersect. */ > goto CommandPostWrapCopy; > } > > If [src_start, src_start + i) and [pos, pos + i) don't intersect, then > neither do [src_start + 16, src_start + i) and [pos + 16, pos + i). > > The if seems okay: > > (src_start + i > pos && pos + i > src_start) > > which can be rewritten to: > > (pos < src_start + i && src_start < pos + i) > > Then the numbers are in one of these two orders: > > pos <= src_start < pos + i <= src_start + i > src_start <= pos < src_start + i <= pos + i > > These two would be allowed by the "if", but they can only happen if pos > == src_start so they degenerate to the same two orders above: > > pos <= src_start < src_start + i <= pos + i > src_start <= pos < pos + i <= src_start + i > > So it is a false positive in GCC. Disable the warning for now. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Cole Robinson <crobinso@redhat.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reported-by: Cole Robinson <crobinso@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>