summaryrefslogtreecommitdiffstats
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2008-10-21 22:55:04 +0000
committerAlan Modra <amodra@gmail.com>2008-10-21 22:55:04 +0000
commit07890c07361ede1ecd9eddda54936e75aeb7b255 (patch)
tree9614fde0af0381770c85d063e27ee8976670414a /ld/ldlang.c
parent570685ada822793c5fd8fa6dc218d4deda934667 (diff)
downloadppe42-binutils-07890c07361ede1ecd9eddda54936e75aeb7b255.tar.gz
ppe42-binutils-07890c07361ede1ecd9eddda54936e75aeb7b255.zip
* ldlang.c (lang_output_section_find_by_flags): Handle non-alloc
sections. * emultempl/elf32.em (enum orphan_save_index): Add orphan_nonalloc. (hold): Likewise. (gld${EMULATION_NAME}_place_orphan): Handle non-alloc orphans.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 29084490e7..322ce5bc5d 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1363,7 +1363,8 @@ lang_output_section_find_by_flags (const asection *sec,
return found;
}
- if (sec->flags & SEC_CODE)
+ if ((sec->flags & SEC_CODE) != 0
+ && (sec->flags & SEC_ALLOC) != 0)
{
/* Try for a rw code section. */
for (look = first; look; look = look->next)
@@ -1383,7 +1384,8 @@ lang_output_section_find_by_flags (const asection *sec,
found = look;
}
}
- else if (sec->flags & (SEC_READONLY | SEC_THREAD_LOCAL))
+ else if ((sec->flags & (SEC_READONLY | SEC_THREAD_LOCAL)) != 0
+ && (sec->flags & SEC_ALLOC) != 0)
{
/* .rodata can go after .text, .sdata2 after .rodata. */
for (look = first; look; look = look->next)
@@ -1404,7 +1406,8 @@ lang_output_section_find_by_flags (const asection *sec,
found = look;
}
}
- else if (sec->flags & SEC_SMALL_DATA)
+ else if ((sec->flags & SEC_SMALL_DATA) != 0
+ && (sec->flags & SEC_ALLOC) != 0)
{
/* .sdata goes after .data, .sbss after .sdata. */
for (look = first; look; look = look->next)
@@ -1426,7 +1429,8 @@ lang_output_section_find_by_flags (const asection *sec,
found = look;
}
}
- else if (sec->flags & SEC_HAS_CONTENTS)
+ else if ((sec->flags & SEC_HAS_CONTENTS) != 0
+ && (sec->flags & SEC_ALLOC) != 0)
{
/* .data goes after .rodata. */
for (look = first; look; look = look->next)
@@ -1446,9 +1450,9 @@ lang_output_section_find_by_flags (const asection *sec,
found = look;
}
}
- else
+ else if ((sec->flags & SEC_ALLOC) != 0)
{
- /* .bss goes last. */
+ /* .bss goes after any other alloc section. */
for (look = first; look; look = look->next)
{
flags = look->flags;
@@ -1465,6 +1469,20 @@ lang_output_section_find_by_flags (const asection *sec,
found = look;
}
}
+ else
+ {
+ /* non-alloc go last. */
+ for (look = first; look; look = look->next)
+ {
+ flags = look->flags;
+ if (look->bfd_section != NULL)
+ flags = look->bfd_section->flags;
+ flags ^= sec->flags;
+ if (!(flags & SEC_DEBUGGING))
+ found = look;
+ }
+ return found;
+ }
if (found || !match_type)
return found;
OpenPOWER on IntegriCloud