static bfd_boolean
is_dwo_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
{
- const char *name = bfd_section_name (sec);
- int len = strlen (name);
+ const char *name;
+ int len;
+
+ if (sec == NULL || (name = bfd_section_name (sec)) == NULL)
+ return FALSE;
+
+ len = strlen (name);
+ if (len < 5)
+ return FALSE;
return strncmp (name + len - 4, ".dwo", 4) == 0;
}
{
elf_symbol_type *elf_sym;
- elf_sym = elf_symbol_from (sym->the_bfd, sym);
+ elf_sym = elf_symbol_from (sym);
if (elf_sym != NULL)
switch (ELF_ST_VISIBILITY (elf_sym->internal_elf_sym.st_other))
{
{
/* PR 17636: Call non-fatal so that we return to our parent who
may need to tidy temporary files. */
- non_fatal (_("Unable to change endianness of input file(s)"));
+ non_fatal (_("unable to change endianness of '%s'"),
+ bfd_get_archive_filename (ibfd));
+ return FALSE;
+ }
+
+ if (ibfd->read_only)
+ {
+ non_fatal (_("unable to modify '%s' due to errors"),
+ bfd_get_archive_filename (ibfd));
return FALSE;
}
file_alignment, section_alignment);
}
+
+ if (preserve_dates
+ && bfd_get_flavour (ibfd) == bfd_target_coff_flavour
+ && bfd_pei_p (ibfd))
+ pe->timestamp = pe_data (ibfd)->coff.timestamp;
}
if (isympp)
for (pdump = dump_sections; pdump != NULL; pdump = pdump->next)
{
+ FILE * f;
+ bfd_byte *contents;
+
osec = bfd_get_section_by_name (ibfd, pdump->name);
if (osec == NULL)
{
}
bfd_size_type size = bfd_section_size (osec);
- if (size == 0)
- {
- bfd_nonfatal_message (NULL, ibfd, osec,
- _("can't dump section - it is empty"));
- continue;
- }
+ /* Note - we allow the dumping of zero-sized sections,
+ creating an empty file. */
- FILE * f;
f = fopen (pdump->filename, FOPEN_WB);
if (f == NULL)
{
continue;
}
- bfd_byte *contents;
if (bfd_malloc_and_get_section (ibfd, osec, &contents))
{
- if (fwrite (contents, 1, size, f) != size)
+ if (size != 0 && fwrite (contents, 1, size, f) != size)
{
non_fatal (_("error writing section contents to %s (error: %s)"),
pdump->filename,
/* It is likely that output sections are in the same order
as the input sections, but do not assume that this is
the case. */
- if (strcmp (bfd_section_name (merged->sec),
- bfd_section_name (osec)) != 0)
+ if (merged->sec->output_section != osec)
{
for (merged = merged_note_sections;
merged != NULL;
merged = merged->next)
- if (strcmp (bfd_section_name (merged->sec),
- bfd_section_name (osec)) == 0)
+ if (merged->sec->output_section == osec)
break;
if (merged == NULL)
status = 1;
bfd_nonfatal_message (NULL, ibfd, isection,
_("relocation count is negative"));
+ free (relpp);
return;
}
}
temp_relpp [temp_relcount++] = relpp [i];
}
relcount = temp_relcount;
- if (isection->orelocation == NULL)
+ if (relpp != isection->orelocation)
free (relpp);
relpp = temp_relpp;
}
if (relcount == 0)
{
osection->flags &= ~SEC_RELOC;
- free (relpp);
+ if (relpp != isection->orelocation)
+ free (relpp);
}
}
}