aboutsummaryrefslogtreecommitdiff
path: root/bfd/aoutf1.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2001-09-18 09:57:26 +0000
committerAlan Modra <amodra@gmail.com>2001-09-18 09:57:26 +0000
commitdc810e3900d47ab2eea86d50231ff2e70b596847 (patch)
tree13fc3d267fb99c450380f08a0775b2dff076b8d7 /bfd/aoutf1.h
parent417412a27c87b0e738a21122a38d48aa35317eb8 (diff)
downloadgdb-dc810e3900d47ab2eea86d50231ff2e70b596847.zip
gdb-dc810e3900d47ab2eea86d50231ff2e70b596847.tar.gz
gdb-dc810e3900d47ab2eea86d50231ff2e70b596847.tar.bz2
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/aoutf1.h')
-rw-r--r--bfd/aoutf1.h141
1 files changed, 66 insertions, 75 deletions
diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h
index 5dbcdda..ff02136 100644
--- a/bfd/aoutf1.h
+++ b/bfd/aoutf1.h
@@ -1,5 +1,6 @@
/* A.out "format 1" file handling code for BFD.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
+ 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -75,7 +76,7 @@ The name put into the target vector.
#endif
static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-static void sunos_set_arch_mach PARAMS ((bfd *, int));
+static void sunos_set_arch_mach PARAMS ((bfd *, enum machine_type));
static void choose_reloc_size PARAMS ((bfd *));
static boolean sunos_write_object_contents PARAMS ((bfd *));
static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));
@@ -113,11 +114,11 @@ sunos_merge_private_bfd_data (ibfd, obfd)
static void
sunos_set_arch_mach (abfd, machtype)
bfd *abfd;
- int machtype;
+ enum machine_type machtype;
{
/* Determine the architecture and machine type of the object file. */
enum bfd_architecture arch;
- long machine;
+ unsigned long machine;
switch (machtype)
{
@@ -422,8 +423,8 @@ swapcore_sun3 (abfd, ext, intcore)
{
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
- intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
- intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+ intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
#if ARCH_SIZE == 64
@@ -432,20 +433,21 @@ swapcore_sun3 (abfd, ext, intcore)
aout_32_swap_exec_header_in
#endif
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
- intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
- intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
- intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+ intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+ intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
/* FP stuff takes up whole rest of struct, except c_ucode. */
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
(file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
/* Ucode is the last thing in the struct -- just before the end */
- intcore->c_ucode =
- bfd_h_get_32 (abfd,
- intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_ucode = H_GET_32 (abfd,
+ (intcore->c_len
+ - sizeof (extcore->c_ucode)
+ + (unsigned char *) extcore));
intcore->c_stacktop = 0x0E000000; /* By experimentation */
}
@@ -458,8 +460,8 @@ swapcore_sparc (abfd, ext, intcore)
{
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
- intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
- intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+ intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
#if ARCH_SIZE == 64
@@ -468,20 +470,21 @@ swapcore_sparc (abfd, ext, intcore)
aout_32_swap_exec_header_in
#endif
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
- intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
- intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
- intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+ intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+ intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
/* FP stuff takes up whole rest of struct, except c_ucode. */
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
(file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
/* Ucode is the last thing in the struct -- just before the end */
- intcore->c_ucode =
- bfd_h_get_32 (abfd,
- intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_ucode = H_GET_32 (abfd,
+ (intcore->c_len
+ - sizeof (extcore->c_ucode)
+ + (unsigned char *) extcore));
/* Supposedly the user stack grows downward from the bottom of kernel memory.
Presuming that this remains true, this definition will work. */
@@ -499,8 +502,7 @@ swapcore_sparc (abfd, ext, intcore)
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
{
- bfd_vma sp = bfd_h_get_32
- (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+ bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
if (sp < SPARC_USRSTACK_SPARC10)
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
else
@@ -518,8 +520,8 @@ swapcore_solaris_bcp (abfd, ext, intcore)
struct external_solaris_bcp_core *extcore =
(struct external_solaris_bcp_core *) ext;
- intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
- intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+ intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
@@ -534,12 +536,11 @@ swapcore_solaris_bcp (abfd, ext, intcore)
the data section is written from address zero instead of the data
start address. */
memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
- intcore->c_data_addr =
- bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
- intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
- intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
- intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
+ intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+ intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+ intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
+ intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
intcore->fp_stuff_pos =
(long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
@@ -547,9 +548,10 @@ swapcore_solaris_bcp (abfd, ext, intcore)
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
(file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
/* Ucode is the last thing in the struct -- just before the end */
- intcore->c_ucode =
- bfd_h_get_32 (abfd,
- intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_ucode = H_GET_32 (abfd,
+ (intcore->c_len
+ - sizeof (extcore->c_ucode)
+ + (unsigned char *) extcore));
/* Supposedly the user stack grows downward from the bottom of kernel memory.
Presuming that this remains true, this definition will work. */
@@ -567,8 +569,7 @@ swapcore_solaris_bcp (abfd, ext, intcore)
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
{
- bfd_vma sp = bfd_h_get_32
- (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+ bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
if (sp < SPARC_USRSTACK_SPARC10)
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
else
@@ -598,7 +599,7 @@ sunos4_core_file_p (abfd)
bfd *abfd;
{
unsigned char longbuf[4]; /* Raw bytes of various header fields */
- bfd_size_type core_size;
+ bfd_size_type core_size, amt;
unsigned long core_mag;
struct internal_sunos_core *core;
char *extcore;
@@ -607,37 +608,38 @@ sunos4_core_file_p (abfd)
struct sun_core_struct suncoredata;
struct internal_sunos_core internal_sunos_core;
char external_core[1];
- }
- *mergem;
+ } *mergem;
- if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
- sizeof (longbuf))
+ if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
+ != sizeof (longbuf))
return 0;
- core_mag = bfd_h_get_32 (abfd, longbuf);
+ core_mag = H_GET_32 (abfd, longbuf);
if (core_mag != CORE_MAGIC)
return 0;
/* SunOS core headers can vary in length; second word is size; */
- if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
- sizeof (longbuf))
+ if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
+ != sizeof (longbuf))
return 0;
- core_size = bfd_h_get_32 (abfd, longbuf);
+ core_size = H_GET_32 (abfd, longbuf);
/* Sanity check */
if (core_size > 20000)
return 0;
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return 0;
- mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
+ amt = core_size + sizeof (struct mergem);
+ mergem = (struct mergem *) bfd_zalloc (abfd, amt);
if (mergem == NULL)
return 0;
extcore = mergem->external_core;
- if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
+ if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size)
{
+ loser:
bfd_release (abfd, (char *) mergem);
return 0;
}
@@ -659,8 +661,7 @@ sunos4_core_file_p (abfd)
break;
default:
bfd_set_error (bfd_error_system_call); /* FIXME */
- bfd_release (abfd, (char *) mergem);
- return 0;
+ goto loser;
}
abfd->tdata.sun_core_data = &mergem->suncoredata;
@@ -668,33 +669,23 @@ sunos4_core_file_p (abfd)
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
- core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_stacksec (abfd) == NULL)
- {
- loser:
- bfd_release (abfd, (char *) mergem);
- return 0;
- }
- core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ /* bfd_release frees everything allocated after it's arg. */
+ goto loser;
+
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_datasec (abfd) == NULL)
- {
- loser1:
- bfd_release (abfd, core_stacksec (abfd));
- goto loser;
- }
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ goto loser;
+
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_regsec (abfd) == NULL)
- {
- loser2:
- bfd_release (abfd, core_datasec (abfd));
- goto loser1;
- }
- core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ goto loser;
+
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_reg2sec (abfd) == NULL)
- {
- bfd_release (abfd, core_regsec (abfd));
- goto loser2;
- }
+ goto loser;
core_stacksec (abfd)->name = ".stack";
core_datasec (abfd)->name = ".data";
@@ -822,7 +813,7 @@ sunos4_set_sizes (abfd)
#define MY_finish_dynamic_link 0
#endif
-static CONST struct aout_backend_data sunos4_aout_backend =
+static const struct aout_backend_data sunos4_aout_backend =
{
0, /* zmagic files are not contiguous */
1, /* text includes header */