@@ -1308,14 +1308,17 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1308
1308
// make that INT32_MAX.
1309
1309
//
1310
1310
1311
- StubUnwindInfoHeader *pHeader = pStubRW->GetUnwindInfoHeader ();
1312
- _ASSERTE (IS_ALIGNED (pHeader, sizeof (void *)));
1311
+ StubUnwindInfoHeader *pHeaderRW = pStubRW->GetUnwindInfoHeader ();
1312
+ StubUnwindInfoHeader *pHeaderRX = pStubRX->GetUnwindInfoHeader ();
1313
+ _ASSERTE (IS_ALIGNED (pHeaderRW, sizeof (void *)));
1313
1314
1314
- BYTE *pbBaseAddress = pbRegionBaseAddress;
1315
+ BYTE *pbBaseAddressRX = pbRegionBaseAddress;
1316
+ BYTE *pbBaseAddressRW = (BYTE*)((uint64_t )pbRegionBaseAddress + (uint64_t )pHeaderRW - (uint64_t )pHeaderRX);
1315
1317
1316
- while ((size_t )((BYTE*)pHeader - pbBaseAddress ) > MaxSegmentSize)
1318
+ while ((size_t )((BYTE*)pHeaderRX - pbBaseAddressRX ) > MaxSegmentSize)
1317
1319
{
1318
- pbBaseAddress += MaxSegmentSize;
1320
+ pbBaseAddressRX += MaxSegmentSize;
1321
+ pbBaseAddressRW += MaxSegmentSize;
1319
1322
}
1320
1323
1321
1324
//
@@ -1327,7 +1330,7 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1327
1330
// allocations are freed.
1328
1331
//
1329
1332
1330
- if ((size_t )(pCode + globalsize - pbBaseAddress ) > MaxSegmentSize)
1333
+ if ((size_t )(pCode + globalsize - pbBaseAddressRX ) > MaxSegmentSize)
1331
1334
{
1332
1335
return false ;
1333
1336
}
@@ -1442,17 +1445,17 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1442
1445
PT_RUNTIME_FUNCTION pCurFunction = &pUnwindInfoHeader->FunctionEntry ;
1443
1446
_ASSERTE (IS_ALIGNED (pCurFunction, sizeof (ULONG)));
1444
1447
1445
- S_UINT32 sBeginAddress = S_BYTEPTR (pCode) - S_BYTEPTR (pbBaseAddress );
1448
+ S_UINT32 sBeginAddress = S_BYTEPTR (pCode) - S_BYTEPTR (pbBaseAddressRX );
1446
1449
if (sBeginAddress .IsOverflow ())
1447
1450
COMPlusThrowArithmetic ();
1448
1451
pCurFunction->BeginAddress = sBeginAddress .Value ();
1449
1452
1450
- S_UINT32 sEndAddress = S_BYTEPTR (pCode) + S_BYTEPTR (globalsize) - S_BYTEPTR (pbBaseAddress );
1453
+ S_UINT32 sEndAddress = S_BYTEPTR (pCode) + S_BYTEPTR (globalsize) - S_BYTEPTR (pbBaseAddressRX );
1451
1454
if (sEndAddress .IsOverflow ())
1452
1455
COMPlusThrowArithmetic ();
1453
1456
pCurFunction->EndAddress = sEndAddress .Value ();
1454
1457
1455
- S_UINT32 sTemp = S_BYTEPTR (pUnwindInfo) - S_BYTEPTR (pbBaseAddress );
1458
+ S_UINT32 sTemp = S_BYTEPTR (pUnwindInfo) - S_BYTEPTR (pbBaseAddressRW );
1456
1459
if (sTemp .IsOverflow ())
1457
1460
COMPlusThrowArithmetic ();
1458
1461
RUNTIME_FUNCTION__SetUnwindInfoAddress (pCurFunction, sTemp .Value ());
@@ -1465,12 +1468,12 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1465
1468
PT_RUNTIME_FUNCTION pCurFunction = &pUnwindInfoHeader->FunctionEntry ;
1466
1469
_ASSERTE (IS_ALIGNED (pCurFunction, sizeof (ULONG)));
1467
1470
1468
- S_UINT32 sBeginAddress = S_BYTEPTR (pCode) - S_BYTEPTR (pbBaseAddress );
1471
+ S_UINT32 sBeginAddress = S_BYTEPTR (pCode) - S_BYTEPTR (pbBaseAddressRX );
1469
1472
if (sBeginAddress .IsOverflow ())
1470
1473
COMPlusThrowArithmetic ();
1471
1474
RUNTIME_FUNCTION__SetBeginAddress (pCurFunction, sBeginAddress .Value ());
1472
1475
1473
- S_UINT32 sTemp = S_BYTEPTR (pUnwindInfo) - S_BYTEPTR (pbBaseAddress );
1476
+ S_UINT32 sTemp = S_BYTEPTR (pUnwindInfo) - S_BYTEPTR (pbBaseAddressRW );
1474
1477
if (sTemp .IsOverflow ())
1475
1478
COMPlusThrowArithmetic ();
1476
1479
RUNTIME_FUNCTION__SetUnwindInfoAddress (pCurFunction, sTemp .Value ());
@@ -1620,11 +1623,11 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1620
1623
1621
1624
_ASSERTE (IS_ALIGNED (pCurFunction, sizeof (void *)));
1622
1625
1623
- S_UINT32 sBeginAddress = S_BYTEPTR (pCode) - S_BYTEPTR (pbBaseAddress );
1626
+ S_UINT32 sBeginAddress = S_BYTEPTR (pCode) - S_BYTEPTR (pbBaseAddressRX );
1624
1627
if (sBeginAddress .IsOverflow ())
1625
1628
COMPlusThrowArithmetic ();
1626
1629
1627
- S_UINT32 sTemp = S_BYTEPTR (pUnwindInfo) - S_BYTEPTR (pbBaseAddress );
1630
+ S_UINT32 sTemp = S_BYTEPTR (pUnwindInfo) - S_BYTEPTR (pbBaseAddressRW );
1628
1631
if (sTemp .IsOverflow ())
1629
1632
COMPlusThrowArithmetic ();
1630
1633
@@ -1749,14 +1752,14 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1749
1752
(pStubHeapSegment = *ppPrevStubHeapSegment);
1750
1753
(ppPrevStubHeapSegment = &pStubHeapSegment->pNext ))
1751
1754
{
1752
- if (pbBaseAddress < pStubHeapSegment->pbBaseAddress )
1755
+ if (pbBaseAddressRX < pStubHeapSegment->pbBaseAddress )
1753
1756
{
1754
1757
// The list is ordered, so address is between segments
1755
1758
pStubHeapSegment = NULL ;
1756
1759
break ;
1757
1760
}
1758
1761
1759
- if (pbBaseAddress == pStubHeapSegment->pbBaseAddress )
1762
+ if (pbBaseAddressRX == pStubHeapSegment->pbBaseAddress )
1760
1763
{
1761
1764
// Found an existing segment
1762
1765
break ;
@@ -1768,7 +1771,7 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1768
1771
//
1769
1772
// RtlInstallFunctionTableCallback will only accept a ULONG for the
1770
1773
// region size. We've already checked above that the RUNTIME_FUNCTION
1771
- // offsets will work relative to pbBaseAddress .
1774
+ // offsets will work relative to pbBaseAddressRX .
1772
1775
//
1773
1776
1774
1777
SIZE_T cbSegment = findBlockArgs.cbBlockSize ;
@@ -1779,7 +1782,7 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1779
1782
NewHolder<StubUnwindInfoHeapSegment> pNewStubHeapSegment = new StubUnwindInfoHeapSegment ();
1780
1783
1781
1784
1782
- pNewStubHeapSegment->pbBaseAddress = pbBaseAddress ;
1785
+ pNewStubHeapSegment->pbBaseAddress = pbBaseAddressRX ;
1783
1786
pNewStubHeapSegment->cbSegment = cbSegment;
1784
1787
pNewStubHeapSegment->pUnwindHeaderList = NULL ;
1785
1788
#ifdef TARGET_AMD64
@@ -1796,7 +1799,7 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1796
1799
1797
1800
InstallEEFunctionTable (
1798
1801
pNewStubHeapSegment,
1799
- pbBaseAddress ,
1802
+ pbBaseAddressRX ,
1800
1803
(ULONG)cbSegment,
1801
1804
&FindStubFunctionEntry,
1802
1805
pNewStubHeapSegment,
@@ -1807,8 +1810,8 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1807
1810
// Link the new stub into the segment.
1808
1811
//
1809
1812
1810
- pHeader ->pNext = pStubHeapSegment->pUnwindHeaderList ;
1811
- pStubHeapSegment->pUnwindHeaderList = pHeader ;
1813
+ pHeaderRW ->pNext = pStubHeapSegment->pUnwindHeaderList ;
1814
+ pStubHeapSegment->pUnwindHeaderList = pHeaderRW ;
1812
1815
1813
1816
#ifdef TARGET_AMD64
1814
1817
// Publish Unwind info to ETW stack crawler
@@ -1819,8 +1822,8 @@ bool StubLinker::EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, Lo
1819
1822
#endif
1820
1823
1821
1824
#ifdef _DEBUG
1822
- _ASSERTE (pHeader ->IsRegistered ());
1823
- _ASSERTE ( &pHeader ->FunctionEntry
1825
+ _ASSERTE (pHeaderRW ->IsRegistered ());
1826
+ _ASSERTE ( &pHeaderRW ->FunctionEntry
1824
1827
== FindStubFunctionEntry ((ULONG64)pCode, EncodeDynamicFunctionTableContext (pStubHeapSegment, DYNFNTABLE_STUB)));
1825
1828
#endif
1826
1829
0 commit comments