* common.cc (Symbol_table::do_allocate_commons_list): Call
authorCary Coutant <ccoutant@google.com>
Wed, 8 Jun 2011 04:43:28 +0000 (04:43 +0000)
committerCary Coutant <ccoutant@google.com>
Wed, 8 Jun 2011 04:43:28 +0000 (04:43 +0000)
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.

gold/ChangeLog
gold/common.cc
gold/errors.cc
gold/errors.h
gold/gold.cc
gold/gold.h
gold/layout.cc
gold/main.cc
gold/output.cc
gold/x86_64.cc

index f9525984102fe71252ae1b8118913896a3fe582c..9056d6b0309342745e79c5a5802fbf4335743e0f 100644 (file)
@@ -1,3 +1,29 @@
+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
index bffa8290d933d1d34923ac53aaa13c000134aa59..1a9aea871cee91d7ea4f110b8aa47b99f01a9236 100644 (file)
@@ -351,9 +351,9 @@ Symbol_table::do_allocate_commons_list(
          // 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);
        }
     }
index b58650488236fca56b3184602933c26e2a951341..b79764bd1d8285308e7bef6468e929c3279b18ef 100644 (file)
@@ -81,7 +81,18 @@ Errors::fatal(const char* format, va_list args)
   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.
@@ -212,6 +223,17 @@ gold_fatal(const char* format, ...)
   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
index a8f823d1ff53873bd48be49d64e29b9811d9379b..1e61c8dbb5c3d749dca169a99adf068161c7ae10 100644 (file)
@@ -49,6 +49,12 @@ class Errors
   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);
index 0b901bb120d7caabae3b640c84882a6515953d67..95c226c5dd56a58b4840ba1b4c98c474820597fd 100644 (file)
@@ -58,15 +58,15 @@ process_incremental_input(Incremental_binary*, unsigned int, Input_objects*,
                          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
@@ -87,7 +87,7 @@ gold_nomem()
       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.
@@ -97,7 +97,7 @@ do_gold_unreachable(const char* filename, int lineno, const char* function)
 {
   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
@@ -176,7 +176,7 @@ queue_initial_tasks(const General_options& options,
   if (cmdline.begin() == cmdline.end())
     {
       if (options.printed_version())
-       gold_exit(true);
+       gold_exit(GOLD_OK);
       gold_fatal(_("no input files"));
     }
 
@@ -222,7 +222,7 @@ queue_initial_tasks(const General_options& options,
              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"));
            }
        }
     }
@@ -748,7 +748,7 @@ queue_middle_tasks(const General_options& options,
          // 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);
        }
     }
 
index 133a64ef25110c1bb62d58655ea4ec1e5347248b..88fc4de603b7e01cb1119263b5ac9f6ad4d4478f 100644 (file)
@@ -27,6 +27,7 @@
 #include "ansidecl.h"
 
 #include <cstddef>
+#include <cstdlib>
 #include <cstring>
 #include <stdint.h>
 #include <sys/types.h>
@@ -166,6 +167,15 @@ class Output_file;
 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
@@ -183,7 +193,7 @@ extern const char* program_name;
 // 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.
@@ -203,6 +213,13 @@ gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
 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
index 1e5d23ef64ad7e61925b1419589e3c07f53ea235..4c0f1f1cfce13235080e7e4f68af5852f208a1d6 100644 (file)
@@ -3125,18 +3125,18 @@ Layout::set_section_offsets(off_t off, Layout::Section_offset_pass pass)
              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",
@@ -3391,8 +3391,8 @@ Layout::create_symtab_sections(const Input_objects* input_objects,
        {
          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),
@@ -3462,8 +3462,8 @@ Layout::create_shdrs(const Output_section* shstrtab_section, off_t* poff)
       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),
index 7ca0d7072f733ce3f17e61b77c0521dfb10a0e5c..7de1b8779dc96a17c17ef5e6d846b5b9a28d5241 100644 (file)
@@ -291,6 +291,8 @@ main(int argc, char** argv)
 
   // 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);
 }
index d6d08ffacfff5fcb3f02508ba1b395db57c876b0..c7d3e9f7153157c35b9fac1e43a6ecbf0c06f9ad 100644 (file)
@@ -1705,8 +1705,8 @@ Output_data_got<size, big_endian>::add_got_entry(Got_entry got_entry)
       // 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;
@@ -1735,8 +1735,8 @@ Output_data_got<size, big_endian>::add_got_entry_pair(Got_entry got_entry_1,
       // 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;
@@ -2270,7 +2270,7 @@ Output_section::add_input_section(Layout* layout,
       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
@@ -2374,7 +2374,8 @@ Output_section::add_output_section_data(Output_section_data* posd)
          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();
@@ -4170,17 +4171,17 @@ Output_segment::set_section_list_addresses(Layout* layout, bool reset,
              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());
                }
            }
        }
index 0a6a960ef4ffef9c1140108773f6df89c637240c..d67069e7010779fc657f30153df5bd4846a78520 100644 (file)
@@ -915,8 +915,8 @@ Output_data_plt_x86_64::add_entry(Symbol* gsym)
       // 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
This page took 0.039562 seconds and 4 git commands to generate.