@@ -5344,16 +5344,15 @@ _bfd_mn10300_elf_finish_dynamic_sections (struct bfd_link_info *info,
dynobj = htab->root.dynobj;
sgot = htab->root.sgotplt;
- BFD_ASSERT (sgot != NULL);
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (htab->root.dynamic_sections_created)
{
asection * splt;
Elf32_External_Dyn * dyncon;
Elf32_External_Dyn * dynconend;
- BFD_ASSERT (sdyn != NULL);
+ BFD_ASSERT (sdyn != NULL && sgot != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -5424,7 +5423,7 @@ _bfd_mn10300_elf_finish_dynamic_sections (struct bfd_link_info *info,
}
/* Fill in the first three entries in the global offset table. */
- if (sgot->size > 0)
+ if (sgot != NULL && sgot->size > 0)
{
if (sdyn == NULL)
bfd_put_32 (info->output_bfd, 0, sgot->contents);
@@ -5434,9 +5433,9 @@ _bfd_mn10300_elf_finish_dynamic_sections (struct bfd_link_info *info,
sgot->contents);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 4);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 8);
- }
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ }
return true;
}
@@ -4038,7 +4038,6 @@ elf32_bfinfdpic_late_size_sections (struct bfd_link_info *info)
struct elf_link_hash_table *htab;
bfd *dynobj;
asection *s;
- struct _bfinfdpic_dynamic_got_plt_info gpinfo;
htab = elf_hash_table (info);
dynobj = htab->dynobj;
@@ -4058,28 +4057,33 @@ elf32_bfinfdpic_late_size_sections (struct bfd_link_info *info)
}
}
- memset (&gpinfo, 0, sizeof (gpinfo));
- gpinfo.g.info = info;
-
- for (;;)
+ if (bfinfdpic_relocs_info (info))
{
- htab_t relocs = bfinfdpic_relocs_info (info);
+ struct _bfinfdpic_dynamic_got_plt_info gpinfo;
+ memset (&gpinfo, 0, sizeof (gpinfo));
+ gpinfo.g.info = info;
- htab_traverse (relocs, _bfinfdpic_resolve_final_relocs_info, &relocs);
+ for (;;)
+ {
+ htab_t relocs = bfinfdpic_relocs_info (info);
- if (relocs == bfinfdpic_relocs_info (info))
- break;
- }
+ htab_traverse (relocs, _bfinfdpic_resolve_final_relocs_info, &relocs);
+
+ if (relocs == bfinfdpic_relocs_info (info))
+ break;
+ }
- htab_traverse (bfinfdpic_relocs_info (info), _bfinfdpic_count_got_plt_entries,
- &gpinfo.g);
+ htab_traverse (bfinfdpic_relocs_info (info),
+ _bfinfdpic_count_got_plt_entries, &gpinfo.g);
- /* Allocate space to save the summary information, we're going to
- use it if we're doing relaxations. */
- bfinfdpic_dynamic_got_plt_info (info) = bfd_alloc (dynobj, sizeof (gpinfo.g));
+ /* Allocate space to save the summary information, we're going to
+ use it if we're doing relaxations. */
+ bfinfdpic_dynamic_got_plt_info (info) = bfd_alloc (dynobj,
+ sizeof (gpinfo.g));
- if (!_bfinfdpic_size_got_plt (info->output_bfd, &gpinfo))
- return false;
+ if (!_bfinfdpic_size_got_plt (info->output_bfd, &gpinfo))
+ return false;
+ }
s = bfd_get_linker_section (dynobj, ".dynbss");
if (s && s->size == 0)
@@ -4218,11 +4222,6 @@ static bool
elf32_bfinfdpic_finish_dynamic_sections (struct bfd_link_info *info,
bfd_byte *buf ATTRIBUTE_UNUSED)
{
- bfd *dynobj;
- asection *sdyn;
-
- dynobj = elf_hash_table (info)->dynobj;
-
if (bfinfdpic_got_section (info))
{
BFD_ASSERT (bfinfdpic_gotrel_section (info)->size
@@ -4262,12 +4261,11 @@ elf32_bfinfdpic_finish_dynamic_sections (struct bfd_link_info *info,
* sizeof (Elf32_External_Rel)));
}
- sdyn = bfd_get_linker_section (dynobj, ".dynamic");
-
if (elf_hash_table (info)->dynamic_sections_created)
{
- Elf32_External_Dyn * dyncon;
- Elf32_External_Dyn * dynconend;
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ asection *sdyn = bfd_get_linker_section (dynobj, ".dynamic");
+ Elf32_External_Dyn *dyncon, *dynconend;
BFD_ASSERT (sdyn != NULL);
@@ -4866,15 +4864,10 @@ static bool
bfin_finish_dynamic_sections (struct bfd_link_info *info,
bfd_byte *buf ATTRIBUTE_UNUSED)
{
- bfd *dynobj;
- asection *sdyn;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- sdyn = bfd_get_linker_section (dynobj, ".dynamic");
-
if (elf_hash_table (info)->dynamic_sections_created)
{
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ asection *sdyn = bfd_get_linker_section (dynobj, ".dynamic");
Elf32_External_Dyn *dyncon, *dynconend;
BFD_ASSERT (sdyn != NULL);
@@ -2589,9 +2589,7 @@ _bfd_cr16_elf_finish_dynamic_sections (struct bfd_link_info *info,
asection * sdyn;
dynobj = elf_hash_table (info)->dynobj;
-
sgot = elf_hash_table (info)->sgotplt;
- BFD_ASSERT (sgot != NULL);
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
@@ -2599,7 +2597,7 @@ _bfd_cr16_elf_finish_dynamic_sections (struct bfd_link_info *info,
Elf32_External_Dyn * dyncon;
Elf32_External_Dyn * dynconend;
- BFD_ASSERT (sdyn != NULL);
+ BFD_ASSERT (sdyn != NULL && sgot != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -2638,7 +2636,7 @@ _bfd_cr16_elf_finish_dynamic_sections (struct bfd_link_info *info,
}
/* Fill in the first three entries in the global offset table. */
- if (sgot->size > 0)
+ if (sgot != NULL && sgot->size > 0)
{
if (sdyn == NULL)
bfd_put_32 (info->output_bfd, 0, sgot->contents);
@@ -2646,9 +2644,9 @@ _bfd_cr16_elf_finish_dynamic_sections (struct bfd_link_info *info,
bfd_put_32 (info->output_bfd,
sdyn->output_section->vma + sdyn->output_offset,
sgot->contents);
- }
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ }
return true;
}
@@ -2317,9 +2317,7 @@ elf_cris_finish_dynamic_sections (struct bfd_link_info *info,
asection *sdyn;
dynobj = elf_hash_table (info)->dynobj;
-
sgot = elf_hash_table (info)->sgotplt;
- BFD_ASSERT (sgot != NULL);
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
@@ -2328,7 +2326,7 @@ elf_cris_finish_dynamic_sections (struct bfd_link_info *info,
Elf32_External_Dyn *dyncon, *dynconend;
splt = elf_hash_table (info)->splt;
- BFD_ASSERT (splt != NULL && sdyn != NULL);
+ BFD_ASSERT (splt != NULL && sdyn != NULL && sgot != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -2416,7 +2414,7 @@ elf_cris_finish_dynamic_sections (struct bfd_link_info *info,
}
/* Fill in the first three entries in the global offset table. */
- if (sgot->size > 0)
+ if (sgot != NULL && sgot->size > 0)
{
if (sdyn == NULL)
bfd_put_32 (info->output_bfd, 0, sgot->contents);
@@ -2426,9 +2424,9 @@ elf_cris_finish_dynamic_sections (struct bfd_link_info *info,
sgot->contents);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 4);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 8);
- }
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ }
return true;
}
@@ -2084,7 +2084,8 @@ lm32_elf_late_size_sections (struct bfd_link_info *info)
return false;
/* Allocate .rofixup section. */
- if (IS_FDPIC (info->output_bfd))
+ if (IS_FDPIC (info->output_bfd)
+ && lm32fdpic_fixup32_section (info) != NULL)
{
struct weak_symbol_list *list_start = NULL, *list_end = NULL;
int rgot_weak_count = 0;
@@ -762,7 +762,7 @@ m32c_elf_finish_dynamic_sections (struct bfd_link_info *info,
/* As an extra sanity check, verify that all plt entries have
been filled in. */
- if (dynobj != NULL && splt != NULL)
+ if (splt != NULL)
{
bfd_byte *contents = splt->contents;
unsigned int i, size = splt->size;
@@ -779,24 +779,20 @@ m32c_elf_finish_dynamic_sections (struct bfd_link_info *info,
static bool
m32c_elf_early_size_sections (struct bfd_link_info *info)
{
- bfd *dynobj;
asection *splt;
if (bfd_link_relocatable (info))
return true;
- dynobj = elf_hash_table (info)->dynobj;
- if (dynobj == NULL)
- return true;
-
splt = elf_hash_table (info)->splt;
- BFD_ASSERT (splt != NULL);
-
- splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size);
- if (splt->contents == NULL)
- return false;
- splt->alloced = 1;
-
+ if (splt != NULL)
+ {
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ splt->contents = bfd_zalloc (dynobj, splt->size);
+ if (splt->contents == NULL)
+ return false;
+ splt->alloced = 1;
+ }
return true;
}
@@ -4278,9 +4278,7 @@ elf_m68k_finish_dynamic_sections (struct bfd_link_info *info,
asection *sdyn;
dynobj = elf_hash_table (info)->dynobj;
-
sgot = elf_hash_table (info)->sgotplt;
- BFD_ASSERT (sgot != NULL);
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
@@ -4289,7 +4287,7 @@ elf_m68k_finish_dynamic_sections (struct bfd_link_info *info,
Elf32_External_Dyn *dyncon, *dynconend;
splt = elf_hash_table (info)->splt;
- BFD_ASSERT (splt != NULL && sdyn != NULL);
+ BFD_ASSERT (splt != NULL && sdyn != NULL && sgot != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -4347,7 +4345,7 @@ elf_m68k_finish_dynamic_sections (struct bfd_link_info *info,
}
/* Fill in the first three entries in the global offset table. */
- if (sgot->size > 0)
+ if (sgot != NULL && sgot->size > 0)
{
if (sdyn == NULL)
bfd_put_32 (info->output_bfd, 0, sgot->contents);
@@ -4357,9 +4355,9 @@ elf_m68k_finish_dynamic_sections (struct bfd_link_info *info,
sgot->contents);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 4);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 8);
- }
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ }
return true;
}
@@ -1444,7 +1444,7 @@ rl78_elf_finish_dynamic_sections (struct bfd_link_info *info,
dynobj = elf_hash_table (info)->dynobj;
splt = elf_hash_table (info)->splt;
- if (dynobj != NULL && splt != NULL)
+ if (splt != NULL)
{
bfd_byte *contents = splt->contents;
unsigned int i, size = splt->size;
@@ -1462,24 +1462,20 @@ rl78_elf_finish_dynamic_sections (struct bfd_link_info *info,
static bool
rl78_elf_early_size_sections (struct bfd_link_info *info)
{
- bfd *dynobj;
asection *splt;
if (bfd_link_relocatable (info))
return true;
- dynobj = elf_hash_table (info)->dynobj;
- if (dynobj == NULL)
- return true;
-
splt = elf_hash_table (info)->splt;
- BFD_ASSERT (splt != NULL);
-
- splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size);
- if (splt->contents == NULL)
- return false;
- splt->alloced = 1;
-
+ if (splt != NULL)
+ {
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ splt->contents = bfd_zalloc (dynobj, splt->size);
+ if (splt->contents == NULL)
+ return false;
+ splt->alloced = 1;
+ }
return true;
}
@@ -1100,13 +1100,13 @@ score_elf_got_info (bfd *abfd, asection **sgotp)
struct score_got_info *g;
sgot = score_elf_got_section (abfd, true);
- BFD_ASSERT (sgot != NULL);
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = score_elf_section_data (sgot)->u.got_info;
- BFD_ASSERT (g != NULL);
-
if (sgotp)
*sgotp = sgot;
+
+ g = NULL;
+ if (sgot != NULL)
+ g = score_elf_section_data (sgot)->u.got_info;
+
return g;
}
@@ -3206,7 +3206,6 @@ s3_bfd_score_elf_early_size_sections (struct bfd_link_info *info)
dynobj = elf_hash_table (info)->dynobj;
if (dynobj == NULL)
- /* Relocatable links don't have it. */
return true;
g = score_elf_got_info (dynobj, &s);
@@ -984,13 +984,13 @@ score_elf_got_info (bfd *abfd, asection **sgotp)
struct score_got_info *g;
sgot = score_elf_got_section (abfd, true);
- BFD_ASSERT (sgot != NULL);
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = score_elf_section_data (sgot)->u.got_info;
- BFD_ASSERT (g != NULL);
-
if (sgotp)
*sgotp = sgot;
+
+ g = NULL;
+ if (sgot != NULL)
+ g = score_elf_section_data (sgot)->u.got_info;
+
return g;
}
@@ -3010,7 +3010,6 @@ s7_bfd_score_elf_early_size_sections (struct bfd_link_info *info)
dynobj = elf_hash_table (info)->dynobj;
if (dynobj == NULL)
- /* Relocatable links don't have it. */
return true;
g = score_elf_got_info (dynobj, &s);
@@ -1729,9 +1729,7 @@ elf_vax_finish_dynamic_sections (struct bfd_link_info *info,
asection *sdyn;
dynobj = elf_hash_table (info)->dynobj;
-
sgot = elf_hash_table (info)->sgotplt;
- BFD_ASSERT (sgot != NULL);
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
@@ -1740,7 +1738,7 @@ elf_vax_finish_dynamic_sections (struct bfd_link_info *info,
Elf32_External_Dyn *dyncon, *dynconend;
splt = elf_hash_table (info)->splt;
- BFD_ASSERT (splt != NULL && sdyn != NULL);
+ BFD_ASSERT (splt != NULL && sdyn != NULL && sgot != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -1794,7 +1792,7 @@ elf_vax_finish_dynamic_sections (struct bfd_link_info *info,
}
/* Fill in the first three entries in the global offset table. */
- if (sgot->size > 0)
+ if (sgot != NULL && sgot->size > 0)
{
if (sdyn == NULL)
bfd_put_32 (info->output_bfd, 0, sgot->contents);
@@ -1804,10 +1802,10 @@ elf_vax_finish_dynamic_sections (struct bfd_link_info *info,
sgot->contents);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 4);
bfd_put_32 (info->output_bfd, 0, sgot->contents + 8);
- }
- if (elf_section_data (sgot->output_section) != NULL)
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ if (elf_section_data (sgot->output_section) != NULL)
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+ }
return true;
}
@@ -713,24 +713,20 @@ xstormy16_elf_relax_section (bfd *dynobj,
static bool
xstormy16_elf_early_size_sections (struct bfd_link_info *info)
{
- bfd *dynobj;
asection *splt;
if (bfd_link_relocatable (info))
return true;
- dynobj = elf_hash_table (info)->dynobj;
- if (dynobj == NULL)
- return true;
-
splt = elf_hash_table (info)->splt;
- BFD_ASSERT (splt != NULL);
-
- splt->contents = bfd_zalloc (dynobj, splt->size);
- if (splt->contents == NULL)
- return false;
- splt->alloced = 1;
-
+ if (splt != NULL)
+ {
+ bfd *dynobj = elf_hash_table (info)->dynobj;
+ splt->contents = bfd_zalloc (dynobj, splt->size);
+ if (splt->contents == NULL)
+ return false;
+ splt->alloced = 1;
+ }
return true;
}
@@ -970,7 +966,7 @@ xstormy16_elf_finish_dynamic_sections (struct bfd_link_info *info,
/* As an extra sanity check, verify that all plt entries have
been filled in. */
- if (dynobj != NULL && splt != NULL)
+ if (splt != NULL)
{
bfd_byte *contents = splt->contents;
unsigned int i, size = splt->size;
@@ -1804,7 +1804,7 @@ elf64_hppa_late_size_sections (struct bfd_link_info *info)
}
/* Add __text_seg section symbol to dynamic table. */
- if (!hppa_info->text_hash_entry)
+ if (hppa_info->root.dynamic_sections_created && !hppa_info->text_hash_entry)
{
asection *s;
@@ -1833,7 +1833,7 @@ elf64_hppa_late_size_sections (struct bfd_link_info *info)
}
/* Add __data_seg section symbol to dynamic table. */
- if (!hppa_info->data_hash_entry)
+ if (hppa_info->root.dynamic_sections_created && !hppa_info->data_hash_entry)
{
asection *s;