+/* This routine returns non-zero if 'name' starts with the special objective-c
+ anonymous file-scope static name. It accommodates c++'s mangling of such
+ symbols (in this case the symbols will have form _ZL{d}*_OBJC_* d=digit). */
+
+int
+darwin_label_is_anonymous_local_objc_name (const char *name)
+{
+ const unsigned char *p = (const unsigned char *) name;
+ if (*p != '_')
+ return 0;
+ if (p[1] == 'Z' && p[2] == 'L')
+ {
+ p += 3;
+ while (*p >= '0' && *p <= '9')
+ p++;
+ }
+ return (!strncmp ((const char *)p, "_OBJC_", 6));
+}
+
+/* LTO support for Mach-O. */
+
+/* Section names for LTO sections. */
+static unsigned int lto_section_names_offset = 0;
+
+/* This is the obstack which we use to allocate the many strings. */
+static struct obstack lto_section_names_obstack;
+
+/* Segment name for LTO sections. */
+#define LTO_SEGMENT_NAME "__GNU_LTO"
+
+/* Section name for LTO section names section. */
+#define LTO_NAMES_SECTION "__section_names"
+
+/* File to temporarily store LTO data. This is appended to asm_out_file
+ in darwin_end_file. */
+static FILE *lto_asm_out_file, *saved_asm_out_file;
+static char *lto_asm_out_name;
+
+/* Prepare asm_out_file for LTO output. For darwin, this means hiding
+ asm_out_file and switching to an alternative output file. */
+void
+darwin_asm_lto_start (void)
+{
+ gcc_assert (! saved_asm_out_file);
+ saved_asm_out_file = asm_out_file;
+ if (! lto_asm_out_name)
+ lto_asm_out_name = make_temp_file (".lto.s");
+ lto_asm_out_file = fopen (lto_asm_out_name, "a");
+ if (lto_asm_out_file == NULL)
+ fatal_error ("failed to open temporary file %s for LTO output",
+ lto_asm_out_name);
+ asm_out_file = lto_asm_out_file;
+}
+
+/* Restore asm_out_file. */
+void
+darwin_asm_lto_end (void)
+{
+ gcc_assert (saved_asm_out_file);
+ fclose (lto_asm_out_file);
+ asm_out_file = saved_asm_out_file;
+ saved_asm_out_file = NULL;
+}
+