diff options
author | Ian Lance Taylor <ian@airs.com> | 2009-12-31 03:48:46 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2009-12-31 03:48:46 +0000 |
commit | d7bb5745008bb111becc3dc87e7ce243f59b7170 (patch) | |
tree | 90278a6e9c9daca6652c0e8c90ddfc77ef9accee | |
parent | PR 10931 (diff) | |
download | binutils-gdb-d7bb5745008bb111becc3dc87e7ce243f59b7170.tar.gz binutils-gdb-d7bb5745008bb111becc3dc87e7ce243f59b7170.tar.bz2 binutils-gdb-d7bb5745008bb111becc3dc87e7ce243f59b7170.zip |
PR 10979
* script.cc (read_input_script): If we see a new SECTIONS clause,
and we have added an input section, give an error.
* layout.h (class Layout): Add have_added_input_section function.
Add have_added_input_section_ field.
* layout.cc (Layout::Layout): Initialize
have_added_input_section_.
(Layout::layout): Set have_added_input_section_.
(Layout::layout_eh_frame): Likewise.
-rw-r--r-- | gold/ChangeLog | 12 | ||||
-rw-r--r-- | gold/layout.cc | 3 | ||||
-rw-r--r-- | gold/layout.h | 7 | ||||
-rw-r--r-- | gold/script.cc | 9 |
4 files changed, 31 insertions, 0 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index b4c0f6f44f1..508968de668 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,5 +1,17 @@ 2009-12-30 Ian Lance Taylor <iant@google.com> + PR 10979 + * script.cc (read_input_script): If we see a new SECTIONS clause, + and we have added an input section, give an error. + * layout.h (class Layout): Add have_added_input_section function. + Add have_added_input_section_ field. + * layout.cc (Layout::Layout): Initialize + have_added_input_section_. + (Layout::layout): Set have_added_input_section_. + (Layout::layout_eh_frame): Likewise. + +2009-12-30 Ian Lance Taylor <iant@google.com> + PR 10931 * options.h (class General_options): Add --sort-common option. * symtab.h (class Symbol_table): Define Sort_commons_order enum. diff --git a/gold/layout.cc b/gold/layout.cc index 54625325764..8bbeebe938a 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -192,6 +192,7 @@ Layout::Layout(int number_of_input_files, Script_options* script_options) debug_info_(NULL), group_signatures_(), output_file_size_(-1), + have_added_input_section_(false), sections_are_attached_(false), input_requires_executable_stack_(false), input_with_gnu_stack_note_(false), @@ -610,6 +611,7 @@ Layout::layout(Sized_relobj<size, big_endian>* object, unsigned int shndx, *off = os->add_input_section(object, shndx, name, shdr, reloc_shndx, this->script_options_->saw_sections_clause()); + this->have_added_input_section_ = true; return os; } @@ -818,6 +820,7 @@ Layout::layout_eh_frame(Sized_relobj<size, big_endian>* object, bool saw_sections_clause = this->script_options_->saw_sections_clause(); *off = os->add_input_section(object, shndx, name, shdr, reloc_shndx, saw_sections_clause); + this->have_added_input_section_ = true; } return os; diff --git a/gold/layout.h b/gold/layout.h index 06060effda9..604f19b1fdf 100644 --- a/gold/layout.h +++ b/gold/layout.h @@ -433,6 +433,11 @@ class Layout is_linkonce(const char* name) { return strncmp(name, ".gnu.linkonce", sizeof(".gnu.linkonce") - 1) == 0; } + // Whether we have added an input section. + bool + have_added_input_section() const + { return this->have_added_input_section_; } + // Return true if a section is a debugging section. static inline bool is_debug_info_section(const char* name) @@ -990,6 +995,8 @@ class Layout Group_signatures group_signatures_; // The size of the output file. off_t output_file_size_; + // Whether we have added an input section to an output section. + bool have_added_input_section_; // Whether we have attached the sections to the segments. bool sections_are_attached_; // Whether we have seen an object file marked to require an diff --git a/gold/script.cc b/gold/script.cc index fb1b2e111fd..53919e6b016 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -1398,6 +1398,9 @@ read_input_script(Workqueue* workqueue, Symbol_table* symtab, Layout* layout, &lex, input_file->will_search_for()); + bool old_saw_sections_clause = + layout->script_options()->saw_sections_clause(); + if (yyparse(&closure) != 0) { if (closure.found_incompatible_target()) @@ -1411,6 +1414,12 @@ read_input_script(Workqueue* workqueue, Symbol_table* symtab, Layout* layout, return false; } + if (!old_saw_sections_clause + && layout->script_options()->saw_sections_clause() + && layout->have_added_input_section()) + gold_error(_("%s: SECTIONS seen after other input files; try -T/--script"), + input_file->filename().c_str()); + if (!closure.saw_inputs()) return true; |