* elf-hppa.h (elf_hppa_final_link): Use gp val of zero when none

of the usual sections are found.
	* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Tidy.
	Strip .dynbss if it is zero size.
	* elf32-arm.c (elf32_arm_size_dynamic_sections): Likewise.
	* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
	* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise, and
	.dynsbss.
	(i370_elf_finish_dynamic_sections): Don't attempt to write .got
	when it is zero size.
	* elf32-i386.c (elf_i386_size_dynamic_sections): Correct handling
	of .dynbss and zero size sections.
	* elf32-m32r.c (m32r_elf_size_dynamic_sections): Strip .dynbss if
	it is zero size.
	* elf32-m68k.c (elf_m68k_size_dynamic_sections): Tidy.  Strip
	.dynbss if zero size.
	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise, .dynsbss
	too.
	* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
	* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
	* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Tidy.  Strip
	.plt.* and .got.plt.* if zero size.
	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Tidy.  Strip
	.got* and .dynbss if zero size.
	* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Tidy.  Strip
	* elf64-ppc.c (create_linkage_sections): Create branch lookup table
	in .data.rel.ro.brlt or .rodata.brlt, and similarly for associated
	reloc section.
	(create_got_section): Always create new .got and .rela.got sections.
	(ppc64_elf_size_dynamic_sections): Tidy.  Strip .dynbss if zero size.
	* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Handle
	dynamic bss sections correctly.
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Tidy.
	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Tidy.  Strip
	.dynbss if zero size.
This commit is contained in:
Alan Modra 2005-07-08 06:20:06 +00:00
parent b4f261e094
commit c456f0829f
23 changed files with 388 additions and 425 deletions

View file

@ -1,3 +1,45 @@
2005-07-08 Alan Modra <amodra@bigpond.net.au>
* elf-hppa.h (elf_hppa_final_link): Use gp val of zero when none
of the usual sections are found.
* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Tidy.
Strip .dynbss if it is zero size.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Likewise.
* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise, and
.dynsbss.
(i370_elf_finish_dynamic_sections): Don't attempt to write .got
when it is zero size.
* elf32-i386.c (elf_i386_size_dynamic_sections): Correct handling
of .dynbss and zero size sections.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Strip .dynbss if
it is zero size.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Tidy. Strip
.dynbss if zero size.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise, .dynsbss
too.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Tidy. Strip
.plt.* and .got.plt.* if zero size.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Tidy. Strip
.got* and .dynbss if zero size.
* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Tidy. Strip
* elf64-ppc.c (create_linkage_sections): Create branch lookup table
in .data.rel.ro.brlt or .rodata.brlt, and similarly for associated
reloc section.
(create_got_section): Always create new .got and .rela.got sections.
(ppc64_elf_size_dynamic_sections): Tidy. Strip .dynbss if zero size.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
* elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Handle
dynamic bss sections correctly.
* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Tidy.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Tidy. Strip
.dynbss if zero size.
2005-07-08 Ben Elliston <bje@au.ibm.com>
* elf32-xtensa.c: Include <stdarg.h> unconditionally, not only
@ -326,7 +368,7 @@
2005-06-27 Carlos O'Donell <carlos@systemhalted.org>
* bfd/elf32-hppa.c (struct elf32_hppa_stub_hash_entry):
* bfd/elf32-hppa.c (struct elf32_hppa_stub_hash_entry):
Use bh_root, and hh.
(struct elf32_hppa_link_hash_entry): Use eh, and hsh_cache.
(struct elf32_hppa_dyn_reloc_entry): Use hdh_next.

View file

@ -1259,9 +1259,9 @@ elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
if (!sec || (sec->flags & SEC_EXCLUDE))
sec = bfd_get_section_by_name (abfd, ".data");
if (!sec || (sec->flags & SEC_EXCLUDE))
return FALSE;
gp_val = sec->output_offset + sec->output_section->vma;
gp_val = 0;
else
gp_val = sec->output_offset + sec->output_section->vma;
}
}

View file

@ -4221,7 +4221,6 @@ _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info)
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char * name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -4230,34 +4229,14 @@ _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info)
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;
@ -4288,23 +4267,36 @@ _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info)
s->reloc_count = 0;
}
}
else if (strncmp (name, ".got", 4) != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".dynbss") != 0)
/* It's not one of our sections, so don't allocate space. */
continue;
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,
but this way if it does, we get a R_MN10300_NONE reloc
instead of garbage. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}

View file

@ -5852,7 +5852,6 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char * name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -5861,38 +5860,14 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
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, ".rel", 4) == 0)
{
if (s->size == 0)
{
/* If we don't need this section, strip it from the
output file. This is mostly to handle .rel.bss and
.rel.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)
{
/* Remember whether there are any reloc sections other
than .rel.plt. */
@ -5904,21 +5879,34 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
s->reloc_count = 0;
}
}
else if (strncmp (name, ".got", 4) != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".dynbss") != 0)
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
if (strip)
if (s->size == 0)
{
/* If we don't need this section, strip it from the
output file. This is mostly to handle .rel.bss and
.rel.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_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}

View file

@ -2935,7 +2935,6 @@ elf_cris_size_dynamic_sections (output_bfd, info)
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -2944,38 +2943,14 @@ elf_cris_size_dynamic_sections (output_bfd, info)
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)
{
/* Remember whether there are any reloc sections other
than .rela.plt. */
@ -2987,25 +2962,38 @@ elf_cris_size_dynamic_sections (output_bfd, info)
s->reloc_count = 0;
}
}
else if (strncmp (name, ".got", 4) != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".dynbss") != 0)
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc here
in case unused entries are not reclaimed before the section's
contents are written out. This should not happen, but this way
if it does, we will not write out garbage. For reloc sections,
this will make entries have the type R_CRIS_NONE. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}

View file

@ -2274,7 +2274,8 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
sec->size = (sec->size + sizeof (plt_stub) + mask) & ~mask;
}
}
else if (sec == htab->sgot)
else if (sec == htab->sgot
|| sec == htab->sdynbss)
;
else if (strncmp (bfd_get_section_name (dynobj, sec), ".rela", 5) == 0)
{
@ -2311,10 +2312,13 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
}
if ((sec->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. Zero it, because
we may not fill in all the reloc sections. */
sec->contents = bfd_zalloc (dynobj, sec->size);
if (sec->contents == NULL && sec->size != 0)
if (sec->contents == NULL)
return FALSE;
}

View file

@ -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;
if (strip)
&& strcmp (name, ".sdata2") != 0
&& strcmp (name, ".dynbss") != 0
&& strcmp (name, ".dynsbss") != 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;
}
/* It's not one of our sections, so don't allocate space. */
continue;
}
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. */
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;

View file

@ -1948,7 +1948,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
}
if (s->size == 0 && strip_section)
if (s->size == 0)
{
/* If we don't need this section, strip it from the
output file. This is mostly to handle .rel.bss and
@ -1959,11 +1959,14 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
adjust_dynamic_symbol is called, and it is that
function which decides whether anything needs to go
into these sections. */
s->flags |= SEC_EXCLUDE;
if (strip_section)
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,

View file

@ -2264,7 +2264,8 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (s == htab->splt
|| s == htab->sgot
|| s == htab->sgotplt)
|| s == htab->sgotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
comment below. */
@ -2297,6 +2298,9 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,

View file

@ -1189,7 +1189,6 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -1198,38 +1197,14 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
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)
{
relocs = TRUE;
@ -1238,18 +1213,31 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
s->reloc_count = 0;
}
}
else if (strncmp (name, ".got", 4) != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".dynbss") != 0)
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. */
/* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
Unused entries should be reclaimed before the section's contents
@ -1257,7 +1245,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
order to prevent writing out garbage, we initialise the section's
contents to zero. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}

View file

@ -4708,7 +4708,9 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|| s == htab->glink
|| s == htab->got
|| s == htab->sgotplt
|| s == htab->sbss)
|| s == htab->sbss
|| s == htab->dynbss
|| s == htab->dynsbss)
{
/* We'd like to strip these sections if they aren't needed, but if
we've exported dynamic symbols from them we must leave them.
@ -4725,19 +4727,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
}
else if (strncmp (bfd_get_section_name (dynobj, s), ".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. */
}
else
if (s->size != 0)
{
/* Remember whether there are any relocation sections. */
relocs = TRUE;
@ -4755,6 +4745,15 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (s->size == 0 && strip_section)
{
/* 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;
}

View file

@ -2105,7 +2105,8 @@ elf_s390_size_dynamic_sections (output_bfd, info)
if (s == htab->splt
|| s == htab->sgot
|| s == htab->sgotplt)
|| s == htab->sgotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
comment below. */
@ -2141,6 +2142,9 @@ elf_s390_size_dynamic_sections (output_bfd, info)
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,

View file

@ -4354,7 +4354,8 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (s == htab->splt
|| s == htab->sgot
|| s == htab->sgotplt)
|| s == htab->sgotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
comment below. */
@ -4390,6 +4391,9 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,

View file

@ -1173,7 +1173,6 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -1182,38 +1181,14 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
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;
@ -1243,21 +1218,34 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
s->reloc_count = 0;
}
}
else if (strncmp (name, ".got", 4) != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".dynbss") != 0)
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. */
s->contents = (bfd_byte *) bfd_alloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}

View file

@ -1405,7 +1405,6 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -1414,37 +1413,23 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
of the dynobj section names depend upon the input files. */
name = bfd_get_section_name (dynobj, s);
strip = FALSE;
if (strncmp (name, ".rela", 5) == 0)
{
if (strcmp (name, ".rela.plt") == 0)
relplt = TRUE;
else if (strcmp (name, ".rela.got") == 0)
relgot = TRUE;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
s->reloc_count = 0;
}
else if (strncmp (name, ".plt.", 5) == 0
|| strncmp (name, ".got.plt.", 9) == 0)
{
if (s->size == 0)
if (s->size != 0)
{
/* If we don't need this section, strip it from the output
file. We must create the ".plt*" and ".got.plt*"
sections in create_dynamic_sections and/or check_relocs
based on a conservative estimate of the PLT relocation
count, because the sections must be created before the
linker maps input sections to output sections. The
linker does that before size_dynamic_sections, where we
compute the exact size of the PLT, so there may be more
of these sections than are actually needed. */
strip = TRUE;
if (strcmp (name, ".rela.plt") == 0)
relplt = TRUE;
else if (strcmp (name, ".rela.got") == 0)
relgot = TRUE;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
s->reloc_count = 0;
}
}
else if (strcmp (name, ".got") != 0
else if (strncmp (name, ".plt.", 5) != 0
&& strncmp (name, ".got.plt.", 9) != 0
&& strcmp (name, ".got") != 0
&& strcmp (name, ".plt") != 0
&& strcmp (name, ".got.plt") != 0
&& strcmp (name, ".xt.lit.plt") != 0
@ -1454,13 +1439,24 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
}
if (strip)
s->flags |= SEC_EXCLUDE;
else
if (s->size == 0)
{
/* If we don't need this section, strip it from the output
file. We must create the ".plt*" and ".got.plt*"
sections in create_dynamic_sections and/or check_relocs
based on a conservative estimate of the PLT relocation
count, because the sections must be created before the
linker maps input sections to output sections. The
linker does that before size_dynamic_sections, where we
compute the exact size of the PLT, so there may be more
of these sections than are actually needed. */
s->flags |= SEC_EXCLUDE;
}
else if ((s->flags & SEC_HAS_CONTENTS) != 0)
{
/* Allocate memory for the section contents. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}
}

View file

@ -2767,7 +2767,6 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
if (!(s->flags & SEC_LINKER_CREATED))
continue;
@ -2776,23 +2775,11 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
of the dynobj section names depend upon the input files. */
name = bfd_get_section_name (dynobj, s);
/* If we don't need this section, strip it from the output file.
This is to handle .rela.bss and .rela.plt. We must create it
in create_dynamic_sections, because it 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 = FALSE;
if (strncmp (name, ".rela", 5) == 0)
{
strip = (s->size == 0);
if (!strip)
if (s->size != 0)
{
if (strcmp(name, ".rela.plt") == 0)
if (strcmp (name, ".rela.plt") == 0)
relplt = TRUE;
/* We use the reloc_count field as a counter if we need
@ -2800,19 +2787,30 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
s->reloc_count = 0;
}
}
else if (strcmp (name, ".plt") != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".plt") != 0
&& strcmp (name, ".dynbss") != 0)
{
/* It's not one of our dynamic sections, so don't allocate space. */
continue;
}
if (strip)
s->flags |= SEC_EXCLUDE;
else
if (s->size == 0)
{
/* If we don't need this section, strip it from the output file.
This is to handle .rela.bss and .rela.plt. We must create it
in create_dynamic_sections, because it 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;
}
else if ((s->flags & SEC_HAS_CONTENTS) != 0)
{
/* Allocate memory for the section contents. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}
}

View file

@ -1699,7 +1699,6 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
@ -1708,60 +1707,21 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
of the dynobj section names depend upon the input files. */
name = bfd_get_section_name (dynobj, s);
strip = 0;
if (strcmp (name, ".plt") == 0)
{
/* Strip this section if we don't need it; see the comment below. */
if (s->size == 0)
{
strip = TRUE;
}
else
{
/* Remember whether there is a PLT. */
plt = TRUE;
}
/* Remember whether there is a PLT. */
plt = s->size != 0;
}
else if (strcmp (name, ".dlt") == 0)
else if (strcmp (name, ".opd") == 0
|| strncmp (name, ".dlt", 4) == 0
|| strcmp (name, ".stub") == 0
|| strcmp (name, ".got") == 0)
{
/* Strip this section if we don't need it; see the comment below. */
if (s->size == 0)
{
strip = TRUE;
}
}
else if (strcmp (name, ".opd") == 0)
{
/* Strip this section if we don't need it; see the comment below. */
if (s->size == 0)
{
strip = TRUE;
}
}
else if (strncmp (name, ".rela", 5) == 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. */
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;
@ -1792,20 +1752,30 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
s->reloc_count = 0;
}
}
else if (strncmp (name, ".dlt", 4) != 0
&& strcmp (name, ".stub") != 0
&& strcmp (name, ".got") != 0)
else
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents if it has not
been allocated already. We use bfd_zalloc here in case
unused entries are not reclaimed before the section's
@ -1815,7 +1785,7 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
if (s->contents == NULL)
{
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}
}

View file

@ -3195,7 +3195,7 @@ struct ppc_branch_hash_entry {
/* Base hash table entry structure. */
struct bfd_hash_entry root;
/* Offset within .branch_lt. */
/* Offset within branch lookup table. */
unsigned int offset;
/* Generation marker. */
@ -3693,26 +3693,50 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info)
|| ! bfd_set_section_alignment (dynobj, htab->glink, 2))
return FALSE;
/* Create .branch_lt for plt_branch stubs. */
flags = (SEC_ALLOC | SEC_LOAD
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt",
flags);
/* Create branch lookup table for plt_branch stubs. */
if (info->shared)
{
flags = (SEC_ALLOC | SEC_LOAD
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
htab->brlt
= bfd_make_section_anyway_with_flags (dynobj, ".data.rel.ro.brlt",
flags);
}
else
{
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
htab->brlt
= bfd_make_section_anyway_with_flags (dynobj, ".rodata.brlt", flags);
}
if (htab->brlt == NULL
|| ! bfd_set_section_alignment (dynobj, htab->brlt, 3))
return FALSE;
if (info->shared || info->emitrelocations)
if (info->shared)
{
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
htab->relbrlt = bfd_make_section_anyway_with_flags (dynobj,
".rela.branch_lt",
flags);
if (!htab->relbrlt
|| ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3))
return FALSE;
htab->relbrlt
= bfd_make_section_anyway_with_flags (dynobj, ".rela.data.rel.ro.brlt",
flags);
}
else if (info->emitrelocations)
{
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
| SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
htab->relbrlt
= bfd_make_section_anyway_with_flags (dynobj, ".rela.rodata.brlt",
flags);
}
else
return TRUE;
if (!htab->relbrlt
|| ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3))
return FALSE;
return TRUE;
}
@ -3739,13 +3763,13 @@ create_got_section (bfd *abfd, struct bfd_link_info *info)
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
| SEC_LINKER_CREATED);
got = bfd_make_section_with_flags (abfd, ".got", flags);
got = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
if (!got
|| !bfd_set_section_alignment (abfd, got, 3))
return FALSE;
relgot = bfd_make_section_with_flags (abfd, ".rela.got",
flags | SEC_READONLY);
relgot = bfd_make_section_anyway_with_flags (abfd, ".rela.got",
flags | SEC_READONLY);
if (!relgot
|| ! bfd_set_section_alignment (abfd, relgot, 3))
return FALSE;
@ -7696,26 +7720,15 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
else if (s == htab->got
|| s == htab->plt
|| s == htab->glink)
|| s == htab->glink
|| s == htab->dynbss)
{
/* Strip this section if we don't need it; see the
comment below. */
}
else if (strncmp (bfd_get_section_name (dynobj, s), ".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. */
}
else
if (s->size != 0)
{
if (s != htab->relplt)
relocs = TRUE;
@ -7733,12 +7746,20 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
/* .plt is in the bss section. We don't initialise it. */
if (s == htab->plt)
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
@ -9120,7 +9141,7 @@ ppc64_elf_size_stubs (bfd *output_bfd,
(*htab->layout_sections_again) ();
}
/* It would be nice to strip .branch_lt from the output if the
/* It would be nice to strip htab->brlt from the output if the
section is empty, but it's too late. If we strip sections here,
the dynamic symbol table is corrupted since the section symbol
for the stripped section isn't written. */

View file

@ -2076,7 +2076,8 @@ elf_s390_size_dynamic_sections (output_bfd, info)
if (s == htab->splt
|| s == htab->sgot
|| s == htab->sgotplt)
|| s == htab->sgotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
comment below. */
@ -2112,6 +2113,9 @@ elf_s390_size_dynamic_sections (output_bfd, info)
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,

View file

@ -3566,7 +3566,6 @@ sh64_elf64_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;
@ -3575,38 +3574,14 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd,
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;
@ -3637,21 +3612,34 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd,
s->reloc_count = 0;
}
}
else if (strncmp (name, ".got", 4) != 0)
else if (strncmp (name, ".got", 4) != 0
&& strcmp (name, ".dynbss") != 0)
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}

View file

@ -1686,6 +1686,9 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. We use bfd_zalloc
here in case unused entries are not reclaimed before the
section's contents are written out. This should not happen,

View file

@ -6668,7 +6668,6 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip;
/* It's OK to base decisions on the section name, because none
of the dynobj section names depend upon the input files. */
@ -6677,24 +6676,9 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
strip = FALSE;
if (strncmp (name, ".rel", 4) == 0)
{
if (s->size == 0)
{
/* We only strip the section if the output section name
has the same name. Otherwise, there might be several
input sections for this output section. FIXME: This
code is probably not needed these days anyhow, since
the linker now does not create empty output sections. */
if (s->output_section != NULL
&& strcmp (name,
bfd_get_section_name (s->output_section->owner,
s->output_section)) == 0)
strip = TRUE;
}
else
if (s->size != 0)
{
const char *outname;
asection *target;
@ -6818,15 +6802,18 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
continue;
}
if (strip)
if (s->size == 0)
{
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)
{
bfd_set_error (bfd_error_no_memory);
return FALSE;

View file

@ -2152,55 +2152,54 @@ _bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd,
memory for them. */
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
bfd_boolean strip = FALSE;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
/* 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);
if (strncmp (name, ".rela", 5) == 0)
if (s == htab->splt
|| s == htab->sgot
|| s == htab->sdynbss)
{
if (s->size == 0)
{
/* If we don't need this section, strip it from the
output file. This is to handle .rela.bss and
.rel.plt. We must create it in
create_dynamic_sections, because it 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
/* Strip this section if we don't need it; see the
comment below. */
}
else if (strncmp (s->name, ".rela", 5) == 0)
{
if (s->size != 0)
{
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
s->reloc_count = 0;
}
}
else if (s != htab->splt && s != htab->sgot)
else
{
/* It's not one of our sections, so don't allocate space. */
/* It's not one of our sections. */
continue;
}
if (strip)
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. */
s->flags |= SEC_EXCLUDE;
continue;
}
if ((s->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Allocate memory for the section contents. Zero the memory
for the benefit of .rela.plt, which has 4 unused entries
at the beginning, and we don't want garbage. */
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
if (s->contents == NULL)
return FALSE;
}