summaryrefslogtreecommitdiff
path: root/bfd/sco5-core.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2001-09-18 09:57:26 +0000
committerAlan Modra <amodra@bigpond.net.au>2001-09-18 09:57:26 +0000
commit61ffdd1d822cded8cecc95731a8bc06a6cc225b6 (patch)
tree261becea396865cbd7db1b5c72564cc6ca3532a0 /bfd/sco5-core.c
parentbaa3391557891f36d27f4525e2d10e540ddd9329 (diff)
downloadbinutils-redhat-61ffdd1d822cded8cecc95731a8bc06a6cc225b6.tar.gz
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become bfd_bread and bfd_bwrite. o bfd_*alloc now all take a bfd_size_type arg, and will error if size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files or bugs in linker scripts etc. o file_ptr becomes a bfd_signed_vma. Besides matching sizes with various other types involved in handling sections, this should make it easier for bfd to support a 64 bit off_t on 32 bit hosts that provide it. o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*) generally available. They now cast their args to bfd_vma and bfd_byte * as appropriate, which removes a swag of casts from the source. o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and aout-encap.c. o Zillions of formatting and -Wconversion fixes.
Diffstat (limited to 'bfd/sco5-core.c')
-rw-r--r--bfd/sco5-core.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c
index 62f9c986f5..a84ef45c5b 100644
--- a/bfd/sco5-core.c
+++ b/bfd/sco5-core.c
@@ -1,5 +1,5 @@
/* BFD back end for SCO5 core files (U-area and raw sections)
- Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Written by Jouke Numan <jnuman@hiscom.nl>
This file is part of BFD, the Binary File Descriptor library.
@@ -79,7 +79,9 @@ static asymbol *
sco5_core_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
@@ -92,17 +94,17 @@ read_uarea(abfd, filepos)
{
struct sco5_core_struct *rawptr;
+ bfd_size_type amt = sizeof (struct sco5_core_struct);
- rawptr = ((struct sco5_core_struct *)
- bfd_zmalloc (sizeof (struct sco5_core_struct)));
+ rawptr = (struct sco5_core_struct *) bfd_zmalloc (amt);
if (rawptr == NULL)
return NULL;
abfd->tdata.sco5_core_data = rawptr;
- if ((bfd_seek (abfd, filepos, SEEK_SET) != 0)
- || (bfd_read ((void *)&rawptr->u, 1, sizeof rawptr->u, abfd)
- != sizeof rawptr->u))
+ if (bfd_seek (abfd, (file_ptr) filepos, SEEK_SET) != 0
+ || bfd_bread ((void *) &rawptr->u, (bfd_size_type) sizeof rawptr->u,
+ abfd) != sizeof rawptr->u)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
@@ -150,9 +152,10 @@ sco5_core_file_p (abfd)
coresize = statbuf.st_size;
}
/* Last long in core is sizeof struct coreoffsets, read it */
- if ((bfd_seek (abfd, coresize-sizeof coffset_siz, SEEK_SET) != 0)
- || (bfd_read ((void *)&coffset_siz, 1, sizeof coffset_siz, abfd)
- != sizeof coffset_siz) )
+ if ((bfd_seek (abfd, (file_ptr) (coresize - sizeof coffset_siz),
+ SEEK_SET) != 0)
+ || bfd_bread ((void *) &coffset_siz, (bfd_size_type) sizeof coffset_siz,
+ abfd) != sizeof coffset_siz)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
@@ -160,8 +163,8 @@ sco5_core_file_p (abfd)
/* Use it to seek start of coreoffsets region, read it and determine
validity */
- if ((bfd_seek (abfd, coresize-coffset_siz, SEEK_SET) != 0)
- || (bfd_read ((void *)&coffsets, 1, sizeof coffsets, abfd)
+ if ((bfd_seek (abfd, (file_ptr) (coresize - coffset_siz), SEEK_SET) != 0)
+ || (bfd_bread ((void *) &coffsets, (bfd_size_type) sizeof coffsets, abfd)
!= sizeof coffsets)
|| ((coffsets.u_info != 1) && (coffsets.u_info != C_VERSION)))
{
@@ -207,13 +210,15 @@ sco5_core_file_p (abfd)
coresecthead and check its validity */
if ((bfd_seek (abfd,
- coresize - coffset_siz - 2 * sizeof coffset_siz,
+ (file_ptr) (coresize - coffset_siz - 2 * sizeof coffset_siz),
SEEK_SET) != 0)
- || (bfd_read ((void *)&nsecs, 1, sizeof nsecs, abfd) != sizeof nsecs)
- || (bfd_read ((void *)&cheadoffs, 1, sizeof cheadoffs, abfd)
- != sizeof cheadoffs)
- || (bfd_seek (abfd, cheadoffs, SEEK_SET) != 0)
- || (bfd_read ((void *)&chead, 1, sizeof chead, abfd) != sizeof chead)
+ || (bfd_bread ((void *) &nsecs, (bfd_size_type) sizeof nsecs, abfd)
+ != sizeof nsecs)
+ || (bfd_bread ((void *) &cheadoffs, (bfd_size_type) sizeof cheadoffs,
+ abfd) != sizeof cheadoffs)
+ || (bfd_seek (abfd, (file_ptr) cheadoffs, SEEK_SET) != 0)
+ || (bfd_bread ((void *) &chead, (bfd_size_type) sizeof chead, abfd)
+ != sizeof chead)
|| (chead.cs_stype != CORES_OFFSETS)
|| (chead.cs_x.csx_magic != COREMAGIC_NUMBER))
{
@@ -227,8 +232,9 @@ sco5_core_file_p (abfd)
nsecs--; /* We've seen CORES_OFFSETS already */
for (; nsecs; nsecs--)
{
- if ((bfd_seek (abfd, chead.cs_hseek, SEEK_SET) != 0)
- || bfd_read ((void *)&chead, 1, sizeof chead, abfd) != sizeof chead)
+ if ((bfd_seek (abfd, (file_ptr) chead.cs_hseek, SEEK_SET) != 0)
+ || (bfd_bread ((void *) &chead, (bfd_size_type) sizeof chead, abfd)
+ != sizeof chead))
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
@@ -351,7 +357,8 @@ sco5_core_file_failing_signal (ignore_abfd)
/* ARGSUSED */
boolean
sco5_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
{
return true; /* FIXME, We have no way of telling at this point */
}