void *dhandle;
enum bfd_architecture iarch;
unsigned int imach;
- unsigned int c, i;
+ unsigned int num_sec, i;
if (ibfd->xvec->byteorder != obfd->xvec->byteorder
&& ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
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. */
- 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)
}
}
- c = bfd_count_sections (obfd);
- if (c != 0
+ num_sec = bfd_count_sections (obfd);
+ if (num_sec != 0
&& (gap_fill_set || pad_to_set))
{
asection **set;
increasing the section sizes as required to fill the gaps.
We write out the gap contents below. */
- osections = (asection **) xmalloc (c * sizeof (asection *));
+ osections = xmalloc (num_sec * sizeof (*osections));
set = osections;
bfd_map_over_sections (obfd, get_sections, &set);
- qsort (osections, c, sizeof (asection *), compare_section_lma);
+ qsort (osections, num_sec, sizeof (*osections), compare_section_lma);
- gaps = (bfd_size_type *) xmalloc (c * sizeof (bfd_size_type));
- memset (gaps, 0, c * sizeof (bfd_size_type));
+ gaps = xmalloc (num_sec * sizeof (*gaps));
+ memset (gaps, 0, num_sec * sizeof (*gaps));
if (gap_fill_set)
{
- for (i = 0; i < c - 1; i++)
+ for (i = 0; i < num_sec - 1; i++)
{
flagword flags;
bfd_size_type size; /* Octets. */
{
bfd_vma lma; /* Octets. */
bfd_size_type size; /* Octets. */
- unsigned int opb = bfd_octets_per_byte (obfd, osections[c - 1]);
+ unsigned int opb = bfd_octets_per_byte (obfd, osections[num_sec - 1]);
bfd_vma _pad_to = pad_to * opb;
- lma = bfd_section_lma (osections[c - 1]) * opb;
- size = bfd_section_size (osections[c - 1]);
+ lma = bfd_section_lma (osections[num_sec - 1]) * opb;
+ size = bfd_section_size (osections[num_sec - 1]);
if (lma + size < _pad_to)
{
- if (!bfd_set_section_size (osections[c - 1], _pad_to - lma))
+ if (!bfd_set_section_size (osections[num_sec - 1], _pad_to - lma))
{
- bfd_nonfatal_message (NULL, obfd, osections[c - 1],
+ bfd_nonfatal_message (NULL, obfd, osections[num_sec - 1],
_("can't add padding"));
status = 1;
}
else
{
- gaps[c - 1] = _pad_to - (lma + size);
+ gaps[num_sec - 1] = _pad_to - (lma + size);
if (max_gap < _pad_to - (lma + size))
max_gap = _pad_to - (lma + size);
}
}
}
- if (gap_fill_set || pad_to_set)
+ if (gaps != NULL)
{
bfd_byte *buf;
buf = (bfd_byte *) xmalloc (max_gap);
memset (buf, gap_fill, max_gap);
- c = bfd_count_sections (obfd);
- for (i = 0; i < c; i++)
+ for (i = 0; i < num_sec; i++)
{
if (gaps[i] != 0)
{
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);
}
}
}