From 7c07ececf49a7b57a84e50ca8f7040c11d1c8cfa Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 29 Jul 2008 22:58:03 +0000 Subject: [PATCH] * script.cc (Script_options::finalize_symbols): Finalize SECTIONS symbols before other symbols. * testsuite/script_test_2.cc (test_addr): Declare. (test_addr_alias): Declare. (main): Check that test_addr and test_addr_alias have the right values. * testsuite/script_test_2.t: Define test_addr_alias and test_addr. --- gold/ChangeLog | 11 +++++++++++ gold/script.cc | 8 ++++++-- gold/testsuite/script_test_2.cc | 5 +++++ gold/testsuite/script_test_2.t | 3 +++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 853984950e8..48508a9f29d 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,14 @@ +2008-07-29 Ian Lance Taylor + + * script.cc (Script_options::finalize_symbols): Finalize SECTIONS + symbols before other symbols. + * testsuite/script_test_2.cc (test_addr): Declare. + (test_addr_alias): Declare. + (main): Check that test_addr and test_addr_alias have the right + values. + * testsuite/script_test_2.t: Define test_addr_alias and + test_addr. + 2008-07-24 Ian Lance Taylor PR 5990 diff --git a/gold/script.cc b/gold/script.cc index 4bfe33c898c..f6e4a396f2c 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -1109,6 +1109,12 @@ Script_options::add_symbols_to_table(Symbol_table* symtab) void Script_options::finalize_symbols(Symbol_table* symtab, const Layout* layout) { + // We finalize the symbols defined in SECTIONS first, because they + // are the ones which may have changed. This way if symbol outside + // SECTIONS are defined in terms of symbols inside SECTIONS, they + // will get the right value. + this->script_sections_.finalize_symbols(symtab, layout); + for (Symbol_assignments::iterator p = this->symbol_assignments_.begin(); p != this->symbol_assignments_.end(); ++p) @@ -1118,8 +1124,6 @@ Script_options::finalize_symbols(Symbol_table* symtab, const Layout* layout) p != this->assertions_.end(); ++p) (*p)->check(symtab, layout); - - this->script_sections_.finalize_symbols(symtab, layout); } // Set section addresses. We set all the symbols which have absolute diff --git a/gold/testsuite/script_test_2.cc b/gold/testsuite/script_test_2.cc index 9ba3aad74d2..71045516920 100644 --- a/gold/testsuite/script_test_2.cc +++ b/gold/testsuite/script_test_2.cc @@ -35,6 +35,8 @@ extern char end_data[]; extern char start_fill[]; extern char end_fill[]; extern char end_test_area[]; +extern char test_addr[]; +extern char test_addr_alias[]; int main(int, char**) @@ -66,4 +68,7 @@ main(int, char**) assert(end_fill == start_fill + 8); assert(end_test_area == end_fill); + + assert(test_addr == start_test_area_1); + assert(test_addr_alias == test_addr); } diff --git a/gold/testsuite/script_test_2.t b/gold/testsuite/script_test_2.t index 41a87213768..73d39df530b 100644 --- a/gold/testsuite/script_test_2.t +++ b/gold/testsuite/script_test_2.t @@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +test_addr_alias = test_addr; + SECTIONS { /* With luck this will work everywhere. */ @@ -62,4 +64,5 @@ SECTIONS end_fill = .; } end_test_area = .; + test_addr = ADDR(.gold_test); } -- 2.30.2