How about defining this Pcd as UINT64? We defined PcdPciExpressBaseAddress like 
this way.

So your code should be:

In Dec file:
  gXxxTokenSpaceGuid.PcdXxxAddress|0xFFe8B00E|UINT64|0x12345678

In C code:
  StrPtr = PcdGet64 (PcdXXX) + 0x100;

From: Tim Lewis [mailto:tim.le...@insyde.com]
Sent: Wednesday, May 22, 2013 01:16
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] LTCG and fixed address pointers.

We are having trouble with link-time code generation under Visual Studio when 
using PCDs to specify a specific address and convert it to a pointer, when 
accessed from a library. In a library, the FixedAtBuild PCDs (on x64) are 
defned as extern const UINT32 PcdXXXX; and PcdXXXX contains 0xffe8b00e. The 
code generated by VS2008/2010/2012 linker shows:


xor         r12d,r12d         // r12d = 0

mov         eax,r12d          // eax = r12d == 0  rax = ?

cmp         byte ptr [rax-174FF2h],r12b

Notice LTCG is trying to optimize by using a relative offset from 0. "0 - 
174ff2" is FFFFFFFFFFE8B00E (not FFe8B00e).

The code in question is in the form:

CHAR8 *StrPtr;

StrPtr = (CHAR8 *)(UINTN) (PcdGet(PcdXXXX) + 0x100))
while (*StrPtr != '\0') {
...
}

We have tried nearly everything we can think of, other than turning off LTCG 
for the module or even the specific lines. I am worried about what happens with 
MMIO and other "fixed" addresses. I have tried (CHAR8 *)(UINTN) (UINT32)  and 
almost every possible combination of typecases on the PCD result and the 0x100, 
etc. Even did & 0xffffffff. No effect.

If I turn off LTCG, it correctly creates a 32-bit address.

I haven't been able to get any response on the MS forums.

Anyone have any experience with this?

Tim
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to