HDRR *symhdr = &debug->symbolic_header;
bool ret;
-#define READ(ptr, offset, count, size, type) \
+#define READ(ptr, offset, count, size) \
do \
{ \
size_t amt; \
ret = false; \
goto return_something; \
} \
- debug->ptr = (type) _bfd_malloc_and_read (input_bfd, amt, amt); \
+ debug->ptr = _bfd_malloc_and_read (input_bfd, amt + 1, amt); \
if (debug->ptr == NULL) \
{ \
ret = false; \
goto return_something; \
} \
+ ((char *) debug->ptr)[amt] = 0; \
} while (0)
/* If raw_syments is not NULL, then the data was already by read by
_bfd_ecoff_slurp_symbolic_info. */
if (ecoff_data (input_bfd)->raw_syments == NULL)
{
- READ (line, cbLineOffset, cbLine, sizeof (unsigned char),
- unsigned char *);
- READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, void *);
- READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, void *);
- READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, void *);
- READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, void *);
- READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
- union aux_ext *);
- READ (ss, cbSsOffset, issMax, sizeof (char), char *);
- READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, void *);
- READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, void *);
+ READ (line, cbLineOffset, cbLine, sizeof (unsigned char));
+ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size);
+ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size);
+ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size);
+ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size);
+ READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext));
+ READ (ss, cbSsOffset, issMax, sizeof (char));
+ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size);
+ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size);
}
#undef READ
/* The symbolic header contains absolute file offsets and sizes to
read. */
-#define READ(ptr, offset, count, size, type) \
+#define READ(ptr, offset, count, size) \
do \
{ \
size_t amt; \
} \
if (bfd_seek (abfd, symhdr->offset, SEEK_SET) != 0) \
goto error_return; \
- debug->ptr = (type) _bfd_malloc_and_read (abfd, amt, amt); \
+ debug->ptr = _bfd_malloc_and_read (abfd, amt + 1, amt); \
if (debug->ptr == NULL) \
goto error_return; \
+ ((char *) debug->ptr)[amt] = 0; \
} while (0)
- READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
- READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, void *);
- READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, void *);
- READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, void *);
- READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, void *);
- READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
- union aux_ext *);
- READ (ss, cbSsOffset, issMax, sizeof (char), char *);
- READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
- READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, void *);
- READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, void *);
- READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, void *);
+ READ (line, cbLineOffset, cbLine, sizeof (unsigned char));
+ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size);
+ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size);
+ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size);
+ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size);
+ READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext));
+ READ (ss, cbSsOffset, issMax, sizeof (char));
+ READ (ssext, cbSsExtOffset, issExtMax, sizeof (char));
+ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size);
+ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size);
+ READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size);
#undef READ
return true;
#define _bfd_constant_p(v) 0
#endif
-static inline bfd_byte *
+static inline void *
_bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);
return NULL;
}
-static inline bfd_byte *
+static inline void *
_bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);
#define _bfd_constant_p(v) 0
#endif
-static inline bfd_byte *
+static inline void *
_bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);
return NULL;
}
-static inline bfd_byte *
+static inline void *
_bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);