gold_fallback.
	* errors.cc (Errors::fatal): Adjust call to gold_exit.
	(Errors::fallback): New function.
	(gold_fallback): New function.
	* errors.h (Errors::fallback): New function.
	* gold.cc (gold_exit): Change status parameter to enum; adjust
	all callers.
	(queue_initial_tasks): Call gold_fallback.
	* gold.h: Include cstdlib.
	(Exit_status): New enum type.
	(gold_exit): Change status parameter to enum.
	(gold_fallback): New function.
	* layout.cc (Layout::set_section_offsets): Call gold_fallback.
	(Layout::create_symtab_sections): Likewise.
	(Layout::create_shdrs): Likewise.
	* main.cc (main): Adjust call to gold_exit.
	* output.cc (Output_data_got::add_got_entry): Call gold_fallback.
	(Output_data_got::add_got_entry_pair): Likewise.
	(Output_section::add_input_section): Likewise.
	(Output_section::add_output_section_data): Likewise.
	(Output_segment::set_section_list_addresses): Likewise.
	* x86_64.cc (Output_data_plt_x86_64::add_entry): Likewise.
+2011-06-07  Cary Coutant  <ccoutant@google.com>
+
+       * common.cc (Symbol_table::do_allocate_commons_list): Call
+       gold_fallback.
+       * errors.cc (Errors::fatal): Adjust call to gold_exit.
+       (Errors::fallback): New function.
+       (gold_fallback): New function.
+       * errors.h (Errors::fallback): New function.
+       * gold.cc (gold_exit): Change status parameter to enum; adjust
+       all callers.
+       (queue_initial_tasks): Call gold_fallback.
+       * gold.h: Include cstdlib.
+       (Exit_status): New enum type.
+       (gold_exit): Change status parameter to enum.
+       (gold_fallback): New function.
+       * layout.cc (Layout::set_section_offsets): Call gold_fallback.
+       (Layout::create_symtab_sections): Likewise.
+       (Layout::create_shdrs): Likewise.
+       * main.cc (main): Adjust call to gold_exit.
+       * output.cc (Output_data_got::add_got_entry): Call gold_fallback.
+       (Output_data_got::add_got_entry_pair): Likewise.
+       (Output_section::add_input_section): Likewise.
+       (Output_section::add_output_section_data): Likewise.
+       (Output_segment::set_section_list_addresses): Likewise.
+       * x86_64.cc (Output_data_plt_x86_64::add_entry): Likewise.
+
 2011-06-07  Cary Coutant  <ccoutant@google.com>
 
        * layout.cc (Layout::set_segment_offsets): Don't adjust layout
 
          // For an incremental update, allocate from the free list.
          off = os->allocate(ssym->symsize(), ssym->value());
          if (off == -1)
-           gold_fatal(_("out of patch space in section %s; "
-                        "relink with --incremental-full"),
-                        os->name());
+           gold_fallback(_("out of patch space in section %s; "
+                           "relink with --incremental-full"),
+                         os->name());
          ssym->allocate_common(os, off);
        }
     }
 
   fprintf(stderr, _("%s: fatal error: "), this->program_name_);
   vfprintf(stderr, format, args);
   fputc('\n', stderr);
-  gold_exit(false);
+  gold_exit(GOLD_ERR);
+}
+
+// Report a fallback error.
+
+void
+Errors::fallback(const char* format, va_list args)
+{
+  fprintf(stderr, _("%s: fatal error: "), this->program_name_);
+  vfprintf(stderr, format, args);
+  fputc('\n', stderr);
+  gold_exit(GOLD_FALLBACK);
 }
 
 // Report an error.
   va_end(args);
 }
 
+// Report a fallback error.
+
+void
+gold_fallback(const char* format, ...)
+{
+  va_list args;
+  va_start(args, format);
+  parameters->errors()->fallback(format, args);
+  va_end(args);
+}
+
 // Report an error.
 
 void
 
   void
   fatal(const char* format, va_list) ATTRIBUTE_NORETURN;
 
+  // Report a fallback error.  After printing the error, this must exit
+  // with a special status code indicating that fallback to
+  // --incremental-full is required.
+  void
+  fallback(const char* format, va_list) ATTRIBUTE_NORETURN;
+
   // Report an error and continue.
   void
   error(const char* format, va_list);
 
                          Task_token*, Task_token*);
 
 void
-gold_exit(bool status)
+gold_exit(Exit_status status)
 {
   if (parameters != NULL
       && parameters->options_valid()
       && parameters->options().has_plugins())
     parameters->options().plugins()->cleanup();
-  if (!status && parameters != NULL && parameters->options_valid())
+  if (status != GOLD_OK && parameters != NULL && parameters->options_valid())
     unlink_if_ordinary(parameters->options().output_file_name());
-  exit(status ? EXIT_SUCCESS : EXIT_FAILURE);
+  exit(status);
 }
 
 void
       const char* const s = ": out of memory\n";
       len = write(2, s, strlen(s));
     }
-  gold_exit(false);
+  gold_exit(GOLD_ERR);
 }
 
 // Handle an unreachable case.
 {
   fprintf(stderr, _("%s: internal error in %s, at %s:%d\n"),
          program_name, function, filename, lineno);
-  gold_exit(false);
+  gold_exit(GOLD_ERR);
 }
 
 // This class arranges to run the functions done in the middle of the
   if (cmdline.begin() == cmdline.end())
     {
       if (options.printed_version())
-       gold_exit(true);
+       gold_exit(GOLD_OK);
       gold_fatal(_("no input files"));
     }
 
              if (set_parameters_incremental_full())
                gold_info(_("linking with --incremental-full"));
              else
-               gold_fatal(_("restart link with --incremental-full"));
+               gold_fallback(_("restart link with --incremental-full"));
            }
        }
     }
          // THIS_BLOCKER to be NULL here.  There's no real point in
          // continuing if that happens.
          gold_assert(parameters->errors()->error_count() > 0);
-         gold_exit(false);
+         gold_exit(GOLD_ERR);
        }
     }
 
 
 #include "ansidecl.h"
 
 #include <cstddef>
+#include <cstdlib>
 #include <cstring>
 #include <stdint.h>
 #include <sys/types.h>
 template<int size, bool big_endian>
 struct Relocate_info;
 
+// Exit status codes.
+
+enum Exit_status
+{
+  GOLD_OK = EXIT_SUCCESS,
+  GOLD_ERR = EXIT_FAILURE,
+  GOLD_FALLBACK = EXIT_FAILURE + 1
+};
+
 // Some basic types.  For these we use lower case initial letters.
 
 // For an offset in an input or output file, use off_t.  Note that
 // This function is called to exit the program.  Status is true to
 // exit success (0) and false to exit failure (1).
 extern void
-gold_exit(bool status) ATTRIBUTE_NORETURN;
+gold_exit(Exit_status status) ATTRIBUTE_NORETURN;
 
 // This function is called to emit an error message and then
 // immediately exit with failure.
 extern void
 gold_info(const char* msg, ...) ATTRIBUTE_PRINTF_1;
 
+// This function is called to emit an error message and then
+// immediately exit with fallback status (e.g., when
+// --incremental-update fails and the link needs to be restarted
+// with --incremental-full).
+extern void
+gold_fallback(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
+
 // Work around a bug in gcc 4.3.0.  http://gcc.gnu.org/PR35546 .  This
 // can probably be removed after the bug has been fixed for a while.
 #ifdef HAVE_TEMPLATE_ATTRIBUTES
 
              if (is_debugging_enabled(DEBUG_INCREMENTAL))
                this->free_list_.dump();
              gold_assert((*p)->output_section() != NULL);
-             gold_fatal(_("out of patch space for section %s; "
-                          "relink with --incremental-full"),
-                        (*p)->output_section()->name());
+             gold_fallback(_("out of patch space for section %s; "
+                             "relink with --incremental-full"),
+                           (*p)->output_section()->name());
            }
          (*p)->set_file_offset(off);
          (*p)->finalize_data_size();
          if ((*p)->data_size() > current_size)
            {
              gold_assert((*p)->output_section() != NULL);
-             gold_fatal(_("%s: section changed size; "
-                          "relink with --incremental-full"),
-                        (*p)->output_section()->name());
+             gold_fallback(_("%s: section changed size; "
+                             "relink with --incremental-full"),
+                           (*p)->output_section()->name());
            }
          gold_debug(DEBUG_INCREMENTAL,
                     "set_section_offsets: %08lx %08lx %s",
        {
          symtab_off = this->allocate(off, align, *poff);
           if (off == -1)
-           gold_fatal(_("out of patch space for symbol table; "
-                        "relink with --incremental-full"));
+           gold_fallback(_("out of patch space for symbol table; "
+                           "relink with --incremental-full"));
          gold_debug(DEBUG_INCREMENTAL,
                     "create_symtab_sections: %08lx %08lx .symtab",
                     static_cast<long>(symtab_off),
       oshdrs->pre_finalize_data_size();
       off = this->allocate(oshdrs->data_size(), oshdrs->addralign(), *poff);
       if (off == -1)
-         gold_fatal(_("out of patch space for section header table; "
-                      "relink with --incremental-full"));
+         gold_fallback(_("out of patch space for section header table; "
+                         "relink with --incremental-full"));
       gold_debug(DEBUG_INCREMENTAL,
                 "create_shdrs: %08lx %08lx (section header table)",
                 static_cast<long>(off),
 
 
   // If the user used --noinhibit-exec, we force the exit status to be
   // successful.  This is compatible with GNU ld.
-  gold_exit(errors.error_count() == 0
-           || parameters->options().noinhibit_exec());
+  gold_exit((errors.error_count() == 0
+            || parameters->options().noinhibit_exec())
+           ? GOLD_OK
+           : GOLD_ERR);
 }
 
       // For an incremental update, find an available slot.
       off_t got_offset = this->free_list_.allocate(size / 8, size / 8, 0);
       if (got_offset == -1)
-       gold_fatal(_("out of patch space (GOT);"
-                    " relink with --incremental-full"));
+       gold_fallback(_("out of patch space (GOT);"
+                       " relink with --incremental-full"));
       unsigned int got_index = got_offset / (size / 8);
       gold_assert(got_index < this->entries_.size());
       this->entries_[got_index] = got_entry;
       // For an incremental update, find an available pair of slots.
       off_t got_offset = this->free_list_.allocate(2 * size / 8, size / 8, 0);
       if (got_offset == -1)
-       gold_fatal(_("out of patch space (GOT);"
-                    " relink with --incremental-full"));
+       gold_fallback(_("out of patch space (GOT);"
+                       " relink with --incremental-full"));
       unsigned int got_index = got_offset / (size / 8);
       gold_assert(got_index < this->entries_.size());
       this->entries_[got_index] = got_entry_1;
       offset_in_section = this->free_list_.allocate(input_section_size,
                                                    addralign, 0);
       if (offset_in_section == -1)
-        gold_fatal(_("out of patch space; relink with --incremental-full"));
+        gold_fallback(_("out of patch space; relink with --incremental-full"));
       aligned_offset_in_section = offset_in_section;
     }
   else
          offset_in_section = this->free_list_.allocate(posd->data_size(),
                                                        posd->addralign(), 0);
          if (offset_in_section == -1)
-           gold_fatal(_("out of patch space; relink with --incremental-full"));
+           gold_fallback(_("out of patch space; "
+                           "relink with --incremental-full"));
          // Finalize the address and offset now.
          uint64_t addr = this->address();
          off_t offset = this->offset();
              if (off == -1)
                {
                  gold_assert((*p)->output_section() != NULL);
-                 gold_fatal(_("out of patch space for section %s; "
-                              "relink with --incremental-full"),
-                            (*p)->output_section()->name());
+                 gold_fallback(_("out of patch space for section %s; "
+                                 "relink with --incremental-full"),
+                               (*p)->output_section()->name());
                }
              (*p)->set_address_and_file_offset(addr + (off - startoff), off);
              if ((*p)->data_size() > current_size)
                {
                  gold_assert((*p)->output_section() != NULL);
-                 gold_fatal(_("%s: section changed size; "
-                              "relink with --incremental-full"),
-                            (*p)->output_section()->name());
+                 gold_fallback(_("%s: section changed size; "
+                                 "relink with --incremental-full"),
+                               (*p)->output_section()->name());
                }
            }
        }
 
       // For incremental updates, find an available slot.
       plt_offset = this->free_list_.allocate(plt_entry_size, plt_entry_size, 0);
       if (plt_offset == -1)
-       gold_fatal(_("out of patch space (PLT);"
-                    " relink with --incremental-full"));
+       gold_fallback(_("out of patch space (PLT);"
+                       " relink with --incremental-full"));
 
       // The GOT and PLT entries have a 1-1 correspondance, so the GOT offset
       // can be calculated from the PLT index, adjusting for the three