From 07890c07361ede1ecd9eddda54936e75aeb7b255 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 21 Oct 2008 22:55:04 +0000 Subject: * 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. --- ld/ldlang.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'ld/ldlang.c') 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; -- cgit v1.2.1