From 1e5e54006d7db345069fa1eff2b2cfbd9a722981 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 10 Dec 2002 03:34:43 +0000 Subject: * emultempl/elf32.em (struct orphan_save): Add os_tail field. (gld${EMULATION_NAME}_place_orphan): Re-order output_section_statement list too. --- ld/ChangeLog | 6 ++++++ ld/emultempl/elf32.em | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 5d35770..74c9200 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2002-12-10 Alan Modra + + * emultempl/elf32.em (struct orphan_save): Add os_tail field. + (gld${EMULATION_NAME}_place_orphan): Re-order output_section_statement + list too. + 2002-12-08 Alan Modra * ldlang.h: Formatting. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 06fdd81..b7c31fa 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1071,6 +1071,7 @@ struct orphan_save { lang_output_section_statement_type *os; asection **section; lang_statement_union_type **stmt; + lang_statement_union_type **os_tail; }; static bfd_boolean @@ -1093,6 +1094,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) const char *secname; const char *ps = NULL; lang_output_section_statement_type *os; + lang_statement_union_type **os_tail; etree_type *load_base; int isdyn = 0; @@ -1242,6 +1244,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) exp_nameop (ADDR, secname)); } + os_tail = lang_output_section_statement.tail; os = lang_enter_output_section_statement (secname, address, 0, (bfd_vma) 0, (etree_type *) NULL, @@ -1321,11 +1324,15 @@ gld${EMULATION_NAME}_place_orphan (file, s) read/write section before or amongst the read-only ones. */ if (add.head != NULL) { + lang_statement_union_type *newly_added_os; + if (place->stmt == NULL) { /* Put the new statement list right at the head. */ *add.tail = place->os->header.next; place->os->header.next = add.head; + + place->os_tail = &place->os->next; } else { @@ -1341,6 +1348,21 @@ gld${EMULATION_NAME}_place_orphan (file, s) /* Save the end of this list. */ place->stmt = add.tail; + + /* Do the same for the list of output section statements. */ + newly_added_os = *os_tail; + *os_tail = NULL; + newly_added_os->output_section_statement.next = *place->os_tail; + *place->os_tail = newly_added_os; + place->os_tail = &newly_added_os->output_section_statement.next; + + /* Fixing the global list pointer here is a little different. + We added to the list in lang_enter_output_section_statement, + trimmed off the new output_section_statment above when + assigning *os_tail = NULL, but possibly added it back in + the same place when assigning *place->os_tail. */ + if (*os_tail == NULL) + lang_output_section_statement.tail = os_tail; } } -- cgit v1.1