aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2000-09-07 09:09:19 +0000
committerAlan Modra <amodra@gmail.com>2000-09-07 09:09:19 +0000
commited15ac6a0a461de02bf1d4c50762300fc05e5ca6 (patch)
tree9b1c3f12734038595b917255c765d13fbb1ab12d /ld/emultempl
parent71bfc0aef6964c54b8e29466e97fb246cdeb2049 (diff)
downloadfsf-binutils-gdb-ed15ac6a0a461de02bf1d4c50762300fc05e5ca6.zip
fsf-binutils-gdb-ed15ac6a0a461de02bf1d4c50762300fc05e5ca6.tar.gz
fsf-binutils-gdb-ed15ac6a0a461de02bf1d4c50762300fc05e5ca6.tar.bz2
Fix an orphan section problem caused by weird linker scripts.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/elf32.em43
1 files changed, 23 insertions, 20 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 037ac5a..c7ba497 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1203,29 +1203,32 @@ gld${EMULATION_NAME}_place_orphan (file, s)
}
place->section = &snew->next; /* Save the end of this list. */
- /* We try to put the output statements in some sort of
- reasonable order here, because they determine the final load
- addresses of the orphan sections. */
- if (place->stmt == NULL)
+ if (add.head != NULL)
{
- /* Put the new statement list right at the head. */
- *add.tail = place->os->header.next;
- place->os->header.next = add.head;
- }
- else
- {
- /* Put it after the last orphan statement we added. */
- *add.tail = *place->stmt;
- *place->stmt = add.head;
- }
+ /* We try to put the output statements in some sort of
+ reasonable order here, because they determine the final
+ load addresses of the orphan sections. */
+ 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;
+ }
+ else
+ {
+ /* Put it after the last orphan statement we added. */
+ *add.tail = *place->stmt;
+ *place->stmt = add.head;
+ }
- /* Fix the global list pointer if we happened to tack our new
- list at the tail. */
- if (*old->tail == add.head)
- old->tail = add.tail;
+ /* Fix the global list pointer if we happened to tack our
+ new list at the tail. */
+ if (*old->tail == add.head)
+ old->tail = add.tail;
- /* Save the end of this list. */
- place->stmt = add.tail;
+ /* Save the end of this list. */
+ place->stmt = add.tail;
+ }
}
return true;