diff options
author | Cary Coutant <ccoutant@google.com> | 2011-06-08 04:43:28 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2011-06-08 04:43:28 +0000 |
commit | e6455dfbc2dae8cc91f64b4120e87e138970cf84 (patch) | |
tree | ae3c3f5e8ee74a9e4ea1951152ffa055096758b6 | |
parent | fb0e076f5c3d8bfd1f23a96031bfbfb92dc657d2 (diff) | |
download | fsf-binutils-gdb-e6455dfbc2dae8cc91f64b4120e87e138970cf84.zip fsf-binutils-gdb-e6455dfbc2dae8cc91f64b4120e87e138970cf84.tar.gz fsf-binutils-gdb-e6455dfbc2dae8cc91f64b4120e87e138970cf84.tar.bz2 |
* 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.
-rw-r--r-- | gold/ChangeLog | 26 | ||||
-rw-r--r-- | gold/common.cc | 6 | ||||
-rw-r--r-- | gold/errors.cc | 24 | ||||
-rw-r--r-- | gold/errors.h | 6 | ||||
-rw-r--r-- | gold/gold.cc | 16 | ||||
-rw-r--r-- | gold/gold.h | 19 | ||||
-rw-r--r-- | gold/layout.cc | 20 | ||||
-rw-r--r-- | gold/main.cc | 6 | ||||
-rw-r--r-- | gold/output.cc | 25 | ||||
-rw-r--r-- | gold/x86_64.cc | 4 |
10 files changed, 113 insertions, 39 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index f952598..9056d6b 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,5 +1,31 @@ 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 incremental links. * output.cc (Output_segment::set_section_list_addresses): Remove diff --git a/gold/common.cc b/gold/common.cc index bffa829..1a9aea8 100644 --- a/gold/common.cc +++ b/gold/common.cc @@ -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); } } diff --git a/gold/errors.cc b/gold/errors.cc index b586504..b79764b 100644 --- a/gold/errors.cc +++ b/gold/errors.cc @@ -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 diff --git a/gold/errors.h b/gold/errors.h index a8f823d..1e61c8d 100644 --- a/gold/errors.h +++ b/gold/errors.h @@ -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); diff --git a/gold/gold.cc b/gold/gold.cc index 0b901bb..95c226c 100644 --- a/gold/gold.cc +++ b/gold/gold.cc @@ -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); } } diff --git a/gold/gold.h b/gold/gold.h index 133a64e..88fc4de 100644 --- a/gold/gold.h +++ b/gold/gold.h @@ -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 diff --git a/gold/layout.cc b/gold/layout.cc index 1e5d23e..4c0f1f1 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -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), diff --git a/gold/main.cc b/gold/main.cc index 7ca0d70..7de1b87 100644 --- a/gold/main.cc +++ b/gold/main.cc @@ -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); } diff --git a/gold/output.cc b/gold/output.cc index d6d08ff..c7d3e9f 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -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()); } } } diff --git a/gold/x86_64.cc b/gold/x86_64.cc index 0a6a960..d67069e 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -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 |