summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2010-11-05 05:56:53 +0000
committerAlan Modra <amodra@gmail.com>2010-11-05 05:56:53 +0000
commitf4eaaf7fceed097ed62542f9940986b1de01aa48 (patch)
treebf874d78f5edddba96666ef788fc9a99b98b1db1
parent7cdfa31841aea9665682cadb03aaade2821721b1 (diff)
downloadbinutils-gdb-f4eaaf7fceed097ed62542f9940986b1de01aa48.tar.gz
* ldlang.c (lang_add_section): Distinguish ELF treatment of NOLOAD.
(map_input_to_output_sections): Likewise. (lang_size_sections_1): Likewise. (IGNORE_SECTION): Don't test SEC_NEVER_LOAD. (lang_check_section_addresses): Likewise.
-rw-r--r--ld/ChangeLog8
-rw-r--r--ld/ldlang.c38
2 files changed, 27 insertions, 19 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index cd29ee843dc..e3620b93ef6 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2010-11-05 Alan Modra <amodra@gmail.com>
+
+ * ldlang.c (lang_add_section): Distinguish ELF treatment of NOLOAD.
+ (map_input_to_output_sections): Likewise.
+ (lang_size_sections_1): Likewise.
+ (IGNORE_SECTION): Don't test SEC_NEVER_LOAD.
+ (lang_check_section_addresses): Likewise.
+
2010-11-04 Kai Tietz <kai.tietz@onevision.com>
* scripttempl/pe.sc (.debug_types): New.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 798d7a11097..9038ebfff3b 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2250,16 +2250,14 @@ lang_add_section (lang_statement_list_type *ptr,
case noload_section:
flags &= ~SEC_LOAD;
flags |= SEC_NEVER_LOAD;
- if (((bfd_get_flavour (section->owner)
- == bfd_target_ecoff_flavour)
- || (bfd_get_flavour (section->owner)
- == bfd_target_coff_flavour)))
- {
- if ((flags & (SEC_COFF_SHARED_LIBRARY | SEC_DEBUGGING)) == 0)
- flags &= ~SEC_HAS_CONTENTS;
- }
- else
+ /* Unfortunately GNU ld has managed to evolve two different
+ meanings to NOLOAD in scripts. ELF gets a .bss style noload,
+ alloc, no contents section. All others get a noload, noalloc
+ section. */
+ if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour)
flags &= ~SEC_HAS_CONTENTS;
+ else
+ flags &= ~SEC_ALLOC;
break;
}
@@ -3571,7 +3569,11 @@ map_input_to_output_sections
flags = SEC_HAS_CONTENTS;
break;
case noload_section:
- flags = SEC_NEVER_LOAD;
+ if (bfd_get_flavour (link_info.output_bfd)
+ == bfd_target_elf_flavour)
+ flags = SEC_NEVER_LOAD | SEC_ALLOC;
+ else
+ flags = SEC_NEVER_LOAD | SEC_HAS_CONTENTS;
break;
}
if (os->bfd_section == NULL)
@@ -4633,13 +4635,9 @@ sort_sections_by_lma (const void *arg1, const void *arg2)
return 0;
}
-/* On ELF, a debugging section must never set SEC_NEVER_LOAD, as no output
- would be written for it. So the combination of debugging and never-load
- is something which can only happen for pe-coff and must not be ignored. */
#define IGNORE_SECTION(s) \
- ((s->flags & (SEC_NEVER_LOAD | SEC_DEBUGGING)) == SEC_NEVER_LOAD \
- || (s->flags & SEC_ALLOC) == 0 \
- || ((s->flags & SEC_THREAD_LOCAL) != 0 \
+ ((s->flags & SEC_ALLOC) == 0 \
+ || ((s->flags & SEC_THREAD_LOCAL) != 0 \
&& (s->flags & SEC_LOAD) == 0))
/* Check to see if any allocated sections overlap with other allocated
@@ -4671,8 +4669,7 @@ lang_check_section_addresses (void)
for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
{
/* Only consider loadable sections with real contents. */
- if ((s->flags & (SEC_NEVER_LOAD | SEC_DEBUGGING)) == SEC_NEVER_LOAD
- || !(s->flags & SEC_LOAD)
+ if (!(s->flags & SEC_LOAD)
|| !(s->flags & SEC_ALLOC)
|| s->size == 0)
continue;
@@ -5251,7 +5248,10 @@ lang_size_sections_1
should have space allocated to it, unless the
user has explicitly stated that the section
should not be allocated. */
- if (output_section_statement->sectype != noalloc_section)
+ if (output_section_statement->sectype != noalloc_section
+ && (output_section_statement->sectype != noload_section
+ || (bfd_get_flavour (link_info.output_bfd)
+ == bfd_target_elf_flavour)))
output_section_statement->bfd_section->flags |= SEC_ALLOC;
}
dot = newdot;