コード例 #1
0
 protected override void CleanupManagedResources()
 {
     try
     {
         base.CleanupManagedResources();
     }
     finally
     {
         // When we aren't sure if we're being used to harmonise an XIP collection
         // we must check whether the base address has been set to something other than
         // zero and that the address is in the XIP range.
         // NB: Other cases are handled in the constructor.
         if (iType == TCollectionType.EPossiblyXIP)
         {
             if (!iCollection.IsEmptyApartFromDefaultSymbol)
             {
                 Symbol first   = iCollection.FirstSymbol;
                 uint   address = first.Address;
                 if (address > 0)
                 {
                     TMemoryModelRegion region = MMUtilities.RegionByAddress(address);
                     bool isFixed = (region == TMemoryModelRegion.EMemoryModelRegionROM);
                     iCollection.IsFixed = isFixed;
                 }
                 else
                 {
                     // First address is zero, indicates RAM-loaded code and therefore
                     // non-XIP.
                     iCollection.IsFixed = false;
                 }
             }
             else
             {
                 // The collection only contains the default symbol so in that case
                 // it can be thought to be relocatable (although in practise that wouldn't
                 // be very helpful). The main point is that we don't want this collection
                 // to start matching null addresses (quite common when performing symbolic
                 // lookup).
                 iCollection.IsFixed = false;
             }
         }
     }
 }
コード例 #2
0
        private void UpdateAttributes()
        {
            // Remove XIP/RAM attrib before we work out the type...
            iAttributes &= ~TAttributes.EAttributeRAM;
            iAttributes &= ~TAttributes.EAttributeXIP;

            MemoryModel.TMemoryModelType type = MMUtilities.TypeByAddress(Base);
            if (type != MemoryModel.TMemoryModelType.EMemoryModelUnknown)
            {
                MemoryModel.TMemoryModelRegion region = MMUtilities.RegionByAddress(Base, type);
                //
                if (region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionROM)
                {
                    iAttributes |= TAttributes.EAttributeXIP;
                }
                else if (region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode)
                {
                    iAttributes |= TAttributes.EAttributeRAM;
                }
            }
        }
コード例 #3
0
        private bool PreFilterBasedUponFlags(Symbol aSymbol)
        {
            // Do we need to update the length of the previous symbol?
            if ((iFlags & TFlags.EFlagsUpdateLengthOfPreviousSymbol) == TFlags.EFlagsUpdateLengthOfPreviousSymbol)
            {
                FlagBasedUpdateOfLastSymbolLength(aSymbol);
            }

            // Check for Image$$ER_RO$$Base
            // This symbol is emitted for user-side code and can be used to work around some maksym problems.
            string symbolName = aSymbol.Name;

            if (symbolName == KSectionNameUserBase)
            {
                int count = iCollection.Count;
                if (!iCollection.IsEmptyApartFromDefaultSymbol)
                {
                    // Discard all the entries we've seen so far because most likely
                    // they are invalid.
                    System.Diagnostics.Debug.WriteLine(string.Format("Discarding {0} invalid symbols for library: {1}", count, iCollection.FileName));
                    iCollection.Clear();

                    // At this point, we need to reset the base address because any symbols that have gone
                    // before are invalid.
                    iFlags &= ~TFlags.EFlagsHaveSetXIPBaseAddress;
                }
            }

            // Do we need to set the base address for the symbol collection?
            bool haveSetXIPBase = ((iFlags & TFlags.EFlagsHaveSetXIPBaseAddress) == TFlags.EFlagsHaveSetXIPBaseAddress);

            if (!haveSetXIPBase && iType != TCollectionType.ENotXIP)
            {
                // If we're seeing the first valid symbol, then try to set the base address
                bool needToSet = true;
                if (iType == TCollectionType.EPossiblyXIP)
                {
                    // Perhaps we're dealing with an XIP collection. In which case, we need to check
                    // with the memory model utility to decide if it really is or not.
                    //
                    // If the symbol address is zero (NULL), then we can't be dealing with an
                    // XIP collection.
                    if (aSymbol.Address == 0)
                    {
                        // ROFS
                        needToSet = true;
                    }
                    else
                    {
                        TMemoryModelRegion region = MMUtilities.RegionByAddress(aSymbol.Address);
                        needToSet = (region == TMemoryModelRegion.EMemoryModelRegionROM);
                    }
                }

                if (needToSet)
                {
                    SetCollectionBaseAddress(aSymbol);
                }
            }

            bool disallowNewSymbols = (iFlags & TFlags.EFlagsDisallowFurtherSymbolsForCollection) == TFlags.EFlagsDisallowFurtherSymbolsForCollection;

            return(!disallowNewSymbols);
        }