aboutsummaryrefslogtreecommitdiff
path: root/sim/common/run.c
diff options
context:
space:
mode:
authorJackie Smith Cashion <jsmith@redhat.com>1996-09-17 10:10:35 +0000
committerJackie Smith Cashion <jsmith@redhat.com>1996-09-17 10:10:35 +0000
commit3733d1095f6d398f467781d27f12a25895e10908 (patch)
treeb60ac26f586733bf8a509770f9af96f7163f70e4 /sim/common/run.c
parent1db0c2f75cbd377b93546a300fe01150127dd9eb (diff)
downloadgdb-3733d1095f6d398f467781d27f12a25895e10908.zip
gdb-3733d1095f6d398f467781d27f12a25895e10908.tar.gz
gdb-3733d1095f6d398f467781d27f12a25895e10908.tar.bz2
Tue Sep 17 11:04:50 1996 James G. Smith <jsmith@cygnus.co.uk>
* run.c (main): Explicitly cast malloc() parameter. This is needed because for certain builds the size field being given to malloc() is actually 64bits long, and without a cast or malloc prototype the resulting value used by malloc() depended on the host endianness, and how long long paramaters are passed into functions.
Diffstat (limited to 'sim/common/run.c')
-rw-r--r--sim/common/run.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sim/common/run.c b/sim/common/run.c
index 982d99c..76cc48a 100644
--- a/sim/common/run.c
+++ b/sim/common/run.c
@@ -112,13 +112,22 @@ main (ac, av)
for (s = abfd->sections; s; s = s->next)
if (abfd && (s->flags & SEC_LOAD))
{
- unsigned char *buffer = (unsigned char *)malloc (bfd_section_size (abfd, s));
- bfd_get_section_contents (abfd,
- s,
- buffer,
- 0,
- bfd_section_size (abfd, s));
- sim_write (s->vma, buffer, bfd_section_size (abfd, s));
+ unsigned char *buffer = (unsigned char *)malloc ((size_t)(bfd_section_size (abfd, s)));
+ if (buffer != NULL)
+ {
+ bfd_get_section_contents (abfd,
+ s,
+ buffer,
+ 0,
+ bfd_section_size (abfd, s));
+ sim_write (s->vma, buffer, bfd_section_size (abfd, s));
+ }
+ else
+ {
+ fprintf (stderr, "run: failed to allocate section buffer: %s\n",
+ bfd_errmsg(bfd_get_error()));
+ exit (1);
+ }
}
start_address = bfd_get_start_address (abfd);