Beispiel #1
0
        public override void Add(GenericSymbolEngine aEngine, GenericSymbol aSymbol)
        {
            // We don't take data symbols, just code
            MapSymbol symbol = (MapSymbol)aSymbol;

            MapSymbol.TType type = symbol.Type;

            if (type == MapSymbol.TType.EThumbCode || type == MapSymbol.TType.EARMCode)
            {
                // Don't take code entries with no size
                if (aSymbol.Size > 0)
                {
                    // Make sure we remove the null symbol if this is the first 'valid' symbol for
                    // the collection.
                    if (Count == 1 && this[0].IsUnknownSymbol)
                    {
                        RemoveAt(0);
                    }

                    iEntries.Add(aSymbol);
                }
                else
                {
#if TRACE
                    System.Diagnostics.Debug.WriteLine("Discarding zero size entry: " + aSymbol.ToString());
#endif
                }
            }
        }
        internal void Add(GenericSymbolEngine aEngine, GenericSymbol aSymbol, bool aAllowNonRomSymbols)
        {
            System.Diagnostics.Debug.Assert(aSymbol is SymbolSymbol);

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

            if (symbolName.StartsWith(KSymbolNameImageBaseOrLimitPrefix))
            {
                bool isBase = symbolName.Contains("Base");

                // If we've just seen the base entry, but we already have some stored symbols, then
                // probably this is a maksym problem that we must try to work around.
                if (isBase)
                {
                    int count = iEntries.Count;
                    if (count > 0 && !iEntries[0].IsUnknownSymbol)
                    {
                        // 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, base.HostBinaryFileName));
                        iEntries.Clear();

                        // At this point, we need to reset the base address because any symbols that have gone
                        // before are invalid.
                        iFlags &= ~TFlags.EFlagsHaveSeenFirstSymbol;
                    }
                }
                else
                {
                    // Reached the limit - stop storing symbols at this point as everything else is likely data.
                    iFlags |= TFlags.EFlagsDisallowFurtherSymbolsForCollection;
                }
            }

            // Don't save the entry if we're in disabled state.
            bool newAdditionsDisabled = (iFlags & TFlags.EFlagsDisallowFurtherSymbolsForCollection) == TFlags.EFlagsDisallowFurtherSymbolsForCollection;

            if (!newAdditionsDisabled)
            {
                // Whether or not we keep the entry
                bool addEntry = false;

                // Set base address
                UpdateCollectionBaseAddressBasedUponFirstSymbol(aSymbol);

                GenericSymbol lastSymbol = InternalLastSymbol;
                if (lastSymbol != null)
                {
                    if (lastSymbol.Address > aSymbol.Address)
                    {
                        // Work-around for maksym problem where it fails to parse some MAP files correctly.
                    }
                    else
                    {
                        // If we have a last symbol, and it's address is prior to that of the new symbol, we can
                        // try to update the last symbol's size (if it needs it updating - the method will check that).
                        UpdateLengthOfPreviousSymbol(aSymbol);

                        // Check to see if we already have a symbol within this address range
                        bool overlappingSymbol = LastSymbolSharesSameAddressRange(aSymbol);
                        if (overlappingSymbol)
                        {
                            // They overlap - which one do we keep?
                            addEntry = FilterOutCommonAddressEntry(lastSymbol, aSymbol);
                        }
                        else
                        {
                            addEntry = TakeEntry(aSymbol, aAllowNonRomSymbols);
                        }
                    }
                }
                else
                {
                    addEntry = TakeEntry(aSymbol, aAllowNonRomSymbols);
                }

                // If we need to keep the symbol, then save it now...
                if (addEntry)
                {
                    DoAddEntry(aSymbol);
                }
            }
        }
 public override void Add(GenericSymbolEngine aEngine, GenericSymbol aSymbol)
 {
     Add(aEngine, aSymbol, true);
 }