public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] BaseTools: Fix the bug for VOID* pcd max size from component section
Date: Mon, 9 Apr 2018 05:45:38 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E20A506@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1521784701-10864-1-git-send-email-yonghong.zhu@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Yonghong Zhu
>Sent: Friday, March 23, 2018 1:58 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [Patch] BaseTools: Fix the bug for VOID* pcd max size from
>component section
>
>When the Pcd defined in components section, its value's size is larger
>than the value's size in [pcd] section, it cause build error, because
>original code use the size get in [pcd] section as max size.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py            | 14 ++++++++++----
> BaseTools/Source/Python/AutoGen/GenC.py               |  9 +++++++--
> BaseTools/Source/Python/AutoGen/GenPcdDb.py           |  5 ++++-
> BaseTools/Source/Python/Workspace/BuildClassObject.py |  3 ++-
> 4 files changed, 23 insertions(+), 8 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 8682217..75eaf56 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -2366,16 +2366,15 @@ class PlatformAutoGen(AutoGen):
>                                              ToPcd.Type, Module, FromPcd.Type),
>                                           File=self.MetaFile)
>
>             if FromPcd.MaxDatumSize not in [None, '']:
>                 ToPcd.MaxDatumSize = FromPcd.MaxDatumSize
>+                ToPcd.MaxSizeUserSet = FromPcd.MaxDatumSize
>             if FromPcd.DefaultValue not in [None, '']:
>                 ToPcd.DefaultValue = FromPcd.DefaultValue
>             if FromPcd.TokenValue not in [None, '']:
>                 ToPcd.TokenValue = FromPcd.TokenValue
>-            if FromPcd.MaxDatumSize not in [None, '']:
>-                ToPcd.MaxDatumSize = FromPcd.MaxDatumSize
>             if FromPcd.DatumType not in [None, '']:
>                 ToPcd.DatumType = FromPcd.DatumType
>             if FromPcd.SkuInfoList not in [None, '', []]:
>                 ToPcd.SkuInfoList = FromPcd.SkuInfoList
>             # Add Flexible PCD format parse
>@@ -2470,10 +2469,11 @@ class PlatformAutoGen(AutoGen):
>                     self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)
>         # use PCD value to calculate the MaxDatumSize when it is not specified
>         for Name, Guid in Pcds:
>             Pcd = Pcds[Name, Guid]
>             if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:
>+                Pcd.MaxSizeUserSet = None
>                 Value = Pcd.DefaultValue
>                 if Value in [None, '']:
>                     Pcd.MaxDatumSize = '1'
>                 elif Value[0] == 'L':
>                     Pcd.MaxDatumSize = str((len(Value) - 2) * 2)
>@@ -4180,23 +4180,29 @@ class ModuleAutoGen(AutoGen):
>                         Padding = '0x00, '
>                         if Unicode:
>                             Padding = Padding * 2
>                             ArraySize = ArraySize / 2
>                         if ArraySize < (len(PcdValue) + 1):
>-                            EdkLogger.error("build", AUTOGEN_ERROR,
>+                            if Pcd.MaxSizeUserSet:
>+                                EdkLogger.error("build", AUTOGEN_ERROR,
>                                             "The maximum size of VOID* type PCD '%s.%s' is less
>than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName)
>                                             )
>+                            else:
>+                                ArraySize = len(PcdValue) + 1
>                         if ArraySize > len(PcdValue) + 1:
>                             NewValue = NewValue + Padding * (ArraySize - len(PcdValue) -
>1)
>                         PcdValue = NewValue + Padding.strip().rstrip(',') + '}'
>                     elif len(PcdValue.split(',')) <= ArraySize:
>                         PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize -
>len(PcdValue.split(',')))
>                         PcdValue += '}'
>                     else:
>-                        EdkLogger.error("build", AUTOGEN_ERROR,
>+                        if Pcd.MaxSizeUserSet:
>+                            EdkLogger.error("build", AUTOGEN_ERROR,
>                                         "The maximum size of VOID* type PCD '%s.%s' is less than
>its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName)
>                                         )
>+                        else:
>+                            ArraySize = len(PcdValue) + 1
>                 PcdItem = '%s.%s|%s|0x%X' % \
>                     (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchPcd[1])
>                 PcdComments = ''
>                 if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in
>self._PcdComments:
>                     PcdComments = '\n
>'.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName])
>diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
>b/BaseTools/Source/Python/AutoGen/GenC.py
>index a895067..c2a739b 100644
>--- a/BaseTools/Source/Python/AutoGen/GenC.py
>+++ b/BaseTools/Source/Python/AutoGen/GenC.py
>@@ -1,9 +1,9 @@
> ## @file
> # Routines for generating AutoGen.h and AutoGen.c
> #
>-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
>+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD
>License
> # which accompanies this distribution.  The full text of the license may be
>found at
> # http://opensource.org/licenses/bsd-license.php
> #
>@@ -1108,13 +1108,18 @@ def CreateModulePcdCode(Info, AutoGenC,
>AutoGenH, Pcd):
>                         NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '
>                 if Unicode:
>                     ArraySize = ArraySize / 2;
>
>                 if ArraySize < (len(Value) + 1):
>-                    EdkLogger.error("build", AUTOGEN_ERROR,
>+                    if Pcd.MaxSizeUserSet:
>+                        EdkLogger.error("build", AUTOGEN_ERROR,
>                                     "The maximum size of VOID* type PCD '%s.%s' is less than
>its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName),
>                                     ExtraData="[%s]" % str(Info))
>+                    else:
>+                        ArraySize = GetPcdSize(Pcd)
>+                        if Unicode:
>+                            ArraySize = ArraySize / 2
>                 Value = NewValue + '0 }'
>             Array = '[%d]' % ArraySize
>         #
>         # skip casting for fixed at build since it breaks ARM assembly.
>         # Long term we need PCD macros that work in assembly
>diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>index e2848e7..cc3566f 100644
>--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
>@@ -1387,13 +1387,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen
>(Platform, DynamicPcdList, Phase):
>                     StringHeadOffsetList.append(str(StringTableSize) + 'U')
>                     StringDbOffsetList.append(StringTableSize)
>                     if Pcd.MaxDatumSize != '':
>                         MaxDatumSize = int(Pcd.MaxDatumSize, 0)
>                         if MaxDatumSize < Size:
>-                            EdkLogger.error("build", AUTOGEN_ERROR,
>+                            if Pcd.MaxSizeUserSet:
>+                                EdkLogger.error("build", AUTOGEN_ERROR,
>                                             "The maximum size of VOID* type PCD '%s.%s' is less
>than its actual size occupied." % (Pcd.TokenSpaceGuidCName,
>Pcd.TokenCName),
>                                             ExtraData="[%s]" % str(Platform))
>+                            else:
>+                                MaxDatumSize = Size
>                     else:
>                         MaxDatumSize = Size
>                     StringTabLen = MaxDatumSize
>                     if StringTabLen % 2:
>                         StringTabLen += 1
>diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>index 1352fa2..78332c1 100644
>--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>@@ -1,9 +1,9 @@
> ## @file
> # This file is used to define each component of the build database
> #
>-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
>+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD
>License
> # which accompanies this distribution.  The full text of the license may be
>found at
> # http://opensource.org/licenses/bsd-license.php
> #
>@@ -53,10 +53,11 @@ class PcdClassObject(object):
>         self.Type = Type
>         self.DatumType = DatumType
>         self.DefaultValue = Value
>         self.TokenValue = Token
>         self.MaxDatumSize = MaxDatumSize
>+        self.MaxSizeUserSet = None
>         self.SkuInfoList = SkuInfoList
>         self.Phase = "DXE"
>         self.Pending = False
>         self.IsOverrided = IsOverrided
>         self.IsFromBinaryInf = False
>--
>2.6.1.windows.1
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2018-04-09  5:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23  5:58 [Patch] BaseTools: Fix the bug for VOID* pcd max size from component section Yonghong Zhu
2018-04-09  5:45 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E20A506@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox