int unused_section_number = 0;
asection *sec;
flagword flags;
+ size_t name_len;
+ char *sec_name;
for (sec = abfd->sections; sec; sec = sec->next)
if (unused_section_number <= sec->target_index)
unused_section_number = sec->target_index + 1;
- if (name == namebuf)
+ name_len = strlen (name) + 1;
+ sec_name = bfd_alloc (abfd, name_len);
+ if (sec_name == NULL)
{
- name = (const char *) bfd_alloc (abfd, strlen (namebuf) + 1);
- if (name == NULL)
- {
- _bfd_error_handler (_("%pB: out of memory creating name for empty section"),
- abfd);
- return;
- }
- strcpy ((char *) name, namebuf);
+ _bfd_error_handler (_("%pB: out of memory creating name "
+ "for empty section"), abfd);
+ return;
}
+ memcpy (sec_name, name, name_len);
flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
- sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
+ sec = bfd_make_section_anyway_with_flags (abfd, sec_name, flags);
if (sec == NULL)
{
_bfd_error_handler (_("%pB: unable to create fake empty section"),
if (!bfd_malloc_and_get_section (abfd, rel_section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
if (offset >= rel_section->size || offset + 8 > rel_section->size)
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
/* xgettext:c-format */
_("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"),
start_address, loadable_toc_address, toc_address);
- if (data != NULL)
- free (data);
+ free (data);
}
else
{
/* Read the whole section. Some of the fields might be before dataoff. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
if (! bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
if (! bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
if (! bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
if (! bfd_malloc_and_get_section (abfd, section, & data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
/* Read the whole section. */
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}
if (!bfd_malloc_and_get_section (abfd, section, &data))
{
- if (data != NULL)
- free (data);
+ free (data);
return FALSE;
}