aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2005-12-24 07:48:30 +0000
committerAlan Modra <amodra@gmail.com>2005-12-24 07:48:30 +0000
commit218868ba41c7305c13c7b4c7e781cabeb11dce62 (patch)
tree148725757508f4e7ea6da7c9d9f13e51de1fae4c /ld
parent3555e8e589e1fe0ddfaf668d31ea2bb8828dfee5 (diff)
downloadgdb-218868ba41c7305c13c7b4c7e781cabeb11dce62.zip
gdb-218868ba41c7305c13c7b4c7e781cabeb11dce62.tar.gz
gdb-218868ba41c7305c13c7b4c7e781cabeb11dce62.tar.bz2
* ldlang.h (lang_output_section_statement_type): Add prev.
* ldlang.c (output_statement_newfunc): Set os.prev. (lang_insert_orphan): Likewise. (output_prev_sec_find): Use os.prev.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/ldlang.c22
-rw-r--r--ld/ldlang.h1
3 files changed, 23 insertions, 7 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index c0c61d8..dea1f29 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-24 Alan Modra <amodra@bigpond.net.au>
+
+ * ldlang.h (lang_output_section_statement_type): Add prev.
+ * ldlang.c (output_statement_newfunc): Set os.prev.
+ (lang_insert_orphan): Likewise.
+ (output_prev_sec_find): Use os.prev.
+
2005-12-22 Santosh Raktawan <santoshr2@kpitcummins.com>
* ld/emulparms/h8300helf.sh (TINY_READONLY_SECTION,
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 8ef48d1..f51f68e 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -912,6 +912,14 @@ output_statement_newfunc (struct bfd_hash_entry *entry,
(lang_statement_union_type *) &ret->os,
&ret->os.header.next);
+ /* For every output section statement added to the list, except the
+ first one, lang_output_section_statement.tail points to the "next"
+ field of the last element of the list. */
+ if (lang_output_section_statement.head != NULL)
+ ret->os.prev = (lang_output_section_statement_type *)
+ ((char *) lang_output_section_statement.tail
+ - offsetof (lang_output_section_statement_type, next));
+
/* GCC's strict aliasing rules prevent us from just casting the
address, so we store the pointer in a variable and cast that
instead. */
@@ -1290,20 +1298,15 @@ lang_output_section_find_by_flags (const asection *sec,
static asection *
output_prev_sec_find (lang_output_section_statement_type *os)
{
- asection *s = (asection *) NULL;
lang_output_section_statement_type *lookup;
- for (lookup = &lang_output_section_statement.head->output_section_statement;
- lookup != NULL;
- lookup = lookup->next)
+ for (lookup = os->prev; lookup != NULL; lookup = lookup->prev)
{
if (lookup->constraint == -1)
continue;
- if (lookup == os)
- return s;
if (lookup->bfd_section != NULL && lookup->bfd_section->owner != NULL)
- s = lookup->bfd_section;
+ return lookup->bfd_section;
}
return NULL;
@@ -1544,7 +1547,12 @@ lang_insert_orphan (asection *s,
/* Do the same for the list of output section statements. */
newly_added_os = *os_tail;
*os_tail = NULL;
+ newly_added_os->prev = (lang_output_section_statement_type *)
+ ((char *) place->os_tail
+ - offsetof (lang_output_section_statement_type, next));
newly_added_os->next = *place->os_tail;
+ if (newly_added_os->next != NULL)
+ newly_added_os->next->prev = newly_added_os;
*place->os_tail = newly_added_os;
place->os_tail = &newly_added_os->next;
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 381bb04..cf5b01f 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -130,6 +130,7 @@ typedef struct lang_output_section_statement_struct
lang_statement_header_type header;
lang_statement_list_type children;
struct lang_output_section_statement_struct *next;
+ struct lang_output_section_statement_struct *prev;
const char *name;
asection *bfd_section;
lang_memory_region_type *region;