示例#1
0
        public void CollectAllSymbols()
        {
            if (dynamic_symbols != null)
            {
                return;
            }

            var dyn_msgSend_functions = new [] {
                new { Name = "xamarin_dyn_objc_msgSend", ValidAbis = Abi.SimulatorArchMask | Abi.ARM64 },
                new { Name = "xamarin_dyn_objc_msgSendSuper", ValidAbis = Abi.SimulatorArchMask | Abi.ARM64 },
                new { Name = "xamarin_dyn_objc_msgSend_stret", ValidAbis = Abi.SimulatorArchMask },
                new { Name = "xamarin_dyn_objc_msgSendSuper_stret", ValidAbis = Abi.SimulatorArchMask },
            };

            var cache_location = Path.Combine(App.Cache.Location, "entry-points.txt");

            if (cached_link)
            {
                dynamic_symbols = new Symbols();
                dynamic_symbols.Load(cache_location, this);
            }
            else
            {
                if (LinkContext == null)
                {
                    // This happens when using the simlauncher and the msbuild tasks asked for a list
                    // of symbols (--symbollist). In that case just produce an empty list, since the
                    // binary shouldn't end up stripped anyway.
                    dynamic_symbols = new Symbols();
                }
                else
                {
                    dynamic_symbols = LinkContext.RequiredSymbols;
                }

                // keep the debugging helper in debugging binaries only
                var has_mono_pmip = App.EnableDebug;
#if MMP
                has_mono_pmip &= !Driver.IsUnifiedFullSystemFramework;
#endif
                if (has_mono_pmip)
                {
                    dynamic_symbols.AddFunction("mono_pmip");
                }

                bool has_dyn_msgSend;

                switch (App.Platform)
                {
                case ApplePlatform.iOS:
                case ApplePlatform.TVOS:
                case ApplePlatform.WatchOS:
                    has_dyn_msgSend = App.IsSimulatorBuild;
                    break;

                case ApplePlatform.MacCatalyst:
                case ApplePlatform.MacOSX:
                    has_dyn_msgSend = App.MarshalObjectiveCExceptions != MarshalObjectiveCExceptionMode.Disable && !App.RequiresPInvokeWrappers;
                    break;

                default:
                    throw ErrorHelper.CreateError(71, Errors.MX0071, App.Platform, App.ProductName);
                }

                if (has_dyn_msgSend)
                {
                    foreach (var dyn_msgSend_function in dyn_msgSend_functions)
                    {
                        dynamic_symbols.AddFunction(dyn_msgSend_function.Name);
                    }
                }

#if MONOTOUCH
                if (App.EnableProfiling && App.LibProfilerLinkMode == AssemblyBuildTarget.StaticObject)
                {
                    dynamic_symbols.AddFunction("mono_profiler_init_log");
                }
#endif

                dynamic_symbols.Save(cache_location);
            }

            foreach (var dynamicFunction in dyn_msgSend_functions)
            {
                var symbol = dynamic_symbols.Find(dynamicFunction.Name);
                if (symbol != null)
                {
                    symbol.ValidAbis = dynamicFunction.ValidAbis;
                }
            }

            foreach (var name in App.IgnoredSymbols)
            {
                var symbol = dynamic_symbols.Find(name);
                if (symbol == null)
                {
                    ErrorHelper.Warning(5218, Errors.MT5218, StringUtils.Quote(name));
                }
                else
                {
                    symbol.Ignore = true;
                }
            }
        }
示例#2
0
        public void CollectAllSymbols()
        {
            if (dynamic_symbols != null)
            {
                return;
            }

            var cache_location = Path.Combine(App.Cache.Location, "entry-points.txt");

            if (cached_link)
            {
                dynamic_symbols = new Symbols();
                dynamic_symbols.Load(cache_location, this);
            }
            else
            {
                if (LinkContext == null)
                {
                    // This happens when using the simlauncher and the msbuild tasks asked for a list
                    // of symbols (--symbollist). In that case just produce an empty list, since the
                    // binary shouldn't end up stripped anyway.
                    dynamic_symbols = new Symbols();
                }
                else
                {
                    dynamic_symbols = LinkContext.RequiredSymbols;
                }

                // keep the debugging helper in debugging binaries only
                var has_mono_pmip = App.EnableDebug;
#if MMP
                has_mono_pmip &= !Driver.IsUnifiedFullSystemFramework;
#endif
                if (has_mono_pmip)
                {
                    dynamic_symbols.AddFunction("mono_pmip");
                }

                bool has_dyn_msgSend;
#if MONOTOUCH
                has_dyn_msgSend = App.IsSimulatorBuild;
#else
                has_dyn_msgSend = App.MarshalObjectiveCExceptions != MarshalObjectiveCExceptionMode.Disable && !App.RequiresPInvokeWrappers && Is64Build;
#endif

                if (has_dyn_msgSend)
                {
                    dynamic_symbols.AddFunction("xamarin_dyn_objc_msgSend");
                    dynamic_symbols.AddFunction("xamarin_dyn_objc_msgSendSuper");
                    dynamic_symbols.AddFunction("xamarin_dyn_objc_msgSend_stret");
                    dynamic_symbols.AddFunction("xamarin_dyn_objc_msgSendSuper_stret");
                }

#if MONOTOUCH
                if (App.EnableProfiling && App.LibProfilerLinkMode == AssemblyBuildTarget.StaticObject)
                {
                    dynamic_symbols.AddFunction("mono_profiler_init_log");
                }
#endif

                dynamic_symbols.Save(cache_location);
            }

            foreach (var name in App.IgnoredSymbols)
            {
                var symbol = dynamic_symbols.Find(name);
                if (symbol == null)
                {
                    ErrorHelper.Warning(5218, $"Can't ignore the dynamic symbol {StringUtils.Quote (name)} (--ignore-dynamic-symbol={StringUtils.Quote (name)}) because it was not detected as a dynamic symbol.");
                }
                else
                {
                    symbol.Ignore = true;
                }
            }
        }