aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i370.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-i370.c')
-rw-r--r--bfd/elf32-i370.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index d0a28d5..4062489 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -635,7 +635,6 @@ i370_elf_size_dynamic_sections (bfd *output_bfd,
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
- bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@@ -643,32 +642,15 @@ i370_elf_size_dynamic_sections (bfd *output_bfd,
/* It's OK to base decisions on the section name, because none
of the dynobj section names depend upon the input files. */
name = bfd_get_section_name (dynobj, s);
- strip = FALSE;
if (strcmp (name, ".plt") == 0)
{
- if (s->size == 0)
- /* Strip this section if we don't need it; see the
- comment below. */
- strip = TRUE;
- else
- /* Remember whether there is a PLT. */
- plt = TRUE;
+ /* Remember whether there is a PLT. */
+ plt = s->size != 0;
}
else if (strncmp (name, ".rela", 5) == 0)
{
- if (s->size == 0)
- /* If we don't need this section, strip it from the
- output file. This is mostly to handle .rela.bss and
- .rela.plt. We must create both sections in
- create_dynamic_sections, because they must be created
- before the linker maps input sections to output
- sections. The linker does that before
- adjust_dynamic_symbol is called, and it is that
- function which decides whether anything needs to go
- into these sections. */
- strip = TRUE;
- else
+ if (s->size != 0)
{
asection *target;
const char *outname;
@@ -693,24 +675,35 @@ i370_elf_size_dynamic_sections (bfd *output_bfd,
}
else if (strcmp (name, ".got") != 0
&& strcmp (name, ".sdata") != 0
- && strcmp (name, ".sdata2") != 0)
- /* It's not one of our sections, so don't allocate space. */
- continue;
+ && strcmp (name, ".sdata2") != 0
+ && strcmp (name, ".dynbss") != 0
+ && strcmp (name, ".dynsbss") != 0)
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
- if (strip)
+ if (s->size == 0)
{
- if (!bfd_section_removed_from_list (s->output_section->owner,
- s->output_section))
- {
- bfd_section_list_remove (s->output_section->owner,
- s->output_section);
- --s->output_section->owner->section_count;
- }
+ /* If we don't need this section, strip it from the
+ output file. This is mostly to handle .rela.bss and
+ .rela.plt. We must create both sections in
+ create_dynamic_sections, because they must be created
+ before the linker maps input sections to output
+ sections. The linker does that before
+ adjust_dynamic_symbol is called, and it is that
+ function which decides whether anything needs to go
+ into these sections. */
+ s->flags |= SEC_EXCLUDE;
continue;
}
+
+ if ((s->flags & SEC_HAS_CONTENTS) == 0)
+ continue;
+
/* Allocate memory for the section contents. */
s->contents = bfd_zalloc (dynobj, s->size);
- if (s->contents == NULL && s->size != 0)
+ if (s->contents == NULL)
return FALSE;
}
@@ -965,7 +958,7 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
}
}
- if (sgot)
+ if (sgot && sgot->size != 0)
{
unsigned char *contents = sgot->contents;