* 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.
This commit is contained in:
Alan Modra 2010-11-05 05:56:53 +00:00
parent 7cdfa31841
commit f4eaaf7fce
2 changed files with 27 additions and 19 deletions

View file

@ -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> 2010-11-04 Kai Tietz <kai.tietz@onevision.com>
* scripttempl/pe.sc (.debug_types): New. * scripttempl/pe.sc (.debug_types): New.

View file

@ -2250,16 +2250,14 @@ lang_add_section (lang_statement_list_type *ptr,
case noload_section: case noload_section:
flags &= ~SEC_LOAD; flags &= ~SEC_LOAD;
flags |= SEC_NEVER_LOAD; flags |= SEC_NEVER_LOAD;
if (((bfd_get_flavour (section->owner) /* Unfortunately GNU ld has managed to evolve two different
== bfd_target_ecoff_flavour) meanings to NOLOAD in scripts. ELF gets a .bss style noload,
|| (bfd_get_flavour (section->owner) alloc, no contents section. All others get a noload, noalloc
== bfd_target_coff_flavour))) section. */
{ if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour)
if ((flags & (SEC_COFF_SHARED_LIBRARY | SEC_DEBUGGING)) == 0)
flags &= ~SEC_HAS_CONTENTS; flags &= ~SEC_HAS_CONTENTS;
}
else else
flags &= ~SEC_HAS_CONTENTS; flags &= ~SEC_ALLOC;
break; break;
} }
@ -3571,7 +3569,11 @@ map_input_to_output_sections
flags = SEC_HAS_CONTENTS; flags = SEC_HAS_CONTENTS;
break; break;
case noload_section: 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; break;
} }
if (os->bfd_section == NULL) if (os->bfd_section == NULL)
@ -4633,12 +4635,8 @@ sort_sections_by_lma (const void *arg1, const void *arg2)
return 0; 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) \ #define IGNORE_SECTION(s) \
((s->flags & (SEC_NEVER_LOAD | SEC_DEBUGGING)) == SEC_NEVER_LOAD \ ((s->flags & SEC_ALLOC) == 0 \
|| (s->flags & SEC_ALLOC) == 0 \
|| ((s->flags & SEC_THREAD_LOCAL) != 0 \ || ((s->flags & SEC_THREAD_LOCAL) != 0 \
&& (s->flags & SEC_LOAD) == 0)) && (s->flags & SEC_LOAD) == 0))
@ -4671,8 +4669,7 @@ lang_check_section_addresses (void)
for (s = link_info.output_bfd->sections; s != NULL; s = s->next) for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
{ {
/* Only consider loadable sections with real contents. */ /* Only consider loadable sections with real contents. */
if ((s->flags & (SEC_NEVER_LOAD | SEC_DEBUGGING)) == SEC_NEVER_LOAD if (!(s->flags & SEC_LOAD)
|| !(s->flags & SEC_LOAD)
|| !(s->flags & SEC_ALLOC) || !(s->flags & SEC_ALLOC)
|| s->size == 0) || s->size == 0)
continue; continue;
@ -5251,7 +5248,10 @@ lang_size_sections_1
should have space allocated to it, unless the should have space allocated to it, unless the
user has explicitly stated that the section user has explicitly stated that the section
should not be allocated. */ 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; output_section_statement->bfd_section->flags |= SEC_ALLOC;
} }
dot = newdot; dot = newdot;