From 48f2ff543db37fece56b0a507427917e06dc1b66 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 29 Jul 2007 12:33:38 +0000 Subject: [PATCH] ld/ * ldlang.c (lang_insert_orphan): When searching through linker script to place an orphan, don't stop on statements that appear outside of SECTIONS. * emultempl/elf32.em (output_rel_find): Prefer read-only alloc sections over read/write alloc sections. ld/testsuite/ * ld-elf/weak-dyn-1.rd: Adjust. --- ld/ChangeLog | 8 ++++++++ ld/emultempl/elf32.em | 10 +++++++++- ld/ldlang.c | 3 ++- ld/testsuite/ChangeLog | 4 ++++ ld/testsuite/ld-elf/weak-dyn-1.rd | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 5741a84..6671254 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2007-07-29 Alan Modra + + * ldlang.c (lang_insert_orphan): When searching through linker + script to place an orphan, don't stop on statements that appear + outside of SECTIONS. + * emultempl/elf32.em (output_rel_find): Prefer read-only alloc + sections over read/write alloc sections. + 2007-07-28 Jakub Jelinek * scripttempl/elf.sc: Add .note.gnu.build-id. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 6261e1d..b82e087 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1567,6 +1567,7 @@ output_rel_find (asection *sec, int isdyn) lang_output_section_statement_type *lookup; lang_output_section_statement_type *last = NULL; lang_output_section_statement_type *last_alloc = NULL; + lang_output_section_statement_type *last_ro_alloc = NULL; lang_output_section_statement_type *last_rel = NULL; lang_output_section_statement_type *last_rel_alloc = NULL; int rela = sec->name[4] == 'a'; @@ -1601,7 +1602,11 @@ output_rel_find (asection *sec, int isdyn) last = lookup; if (lookup->bfd_section != NULL && (lookup->bfd_section->flags & SEC_ALLOC) != 0) - last_alloc = lookup; + { + last_alloc = lookup; + if ((lookup->bfd_section->flags & SEC_READONLY) != 0) + last_ro_alloc = lookup; + } } if (last_rel_alloc) @@ -1610,6 +1615,9 @@ output_rel_find (asection *sec, int isdyn) if (last_rel) return last_rel; + if (last_ro_alloc) + return last_ro_alloc; + if (last_alloc) return last_alloc; diff --git a/ld/ldlang.c b/ld/ldlang.c index ecc0dad..decfc5f 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1654,13 +1654,14 @@ lang_insert_orphan (asection *s, case lang_output_section_statement_enum: if (assign != NULL) where = assign; + break; case lang_input_statement_enum: case lang_address_statement_enum: case lang_target_statement_enum: case lang_output_statement_enum: case lang_group_statement_enum: case lang_afile_asection_pair_statement_enum: - break; + continue; } break; } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 9e58f02..ffa18f0 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-07-29 Alan Modra + + * ld-elf/weak-dyn-1.rd: Adjust. + 2007-07-25 Daniel Jacobowitz * ld-cdtest/cdtest-foo.cc (strncpy): Fix parameter name. diff --git a/ld/testsuite/ld-elf/weak-dyn-1.rd b/ld/testsuite/ld-elf/weak-dyn-1.rd index 169abd8..ab5e0ba 100644 --- a/ld/testsuite/ld-elf/weak-dyn-1.rd +++ b/ld/testsuite/ld-elf/weak-dyn-1.rd @@ -1,3 +1,3 @@ #... -0+800000 .* foo.* +.* foo.* #pass -- 2.7.4