aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@cygnus>1993-07-06 20:20:31 +0000
committerKen Raeburn <raeburn@cygnus>1993-07-06 20:20:31 +0000
commit70e009144e6781fe959c58dbea9e3803ca25cbe4 (patch)
tree7bffc8cd6856339774d10e14f2fae2a2a2fbe4de
parent238ffce0bf7259ae220ac9b4502c145cbd32aa1c (diff)
downloadgdb-70e009144e6781fe959c58dbea9e3803ca25cbe4.zip
gdb-70e009144e6781fe959c58dbea9e3803ca25cbe4.tar.gz
gdb-70e009144e6781fe959c58dbea9e3803ca25cbe4.tar.bz2
Stricter prototyping, to force type conversions between 64-bit target and
32-bit host values. * libbfd.c (bfd_xmalloc_by_size_t): New function. * opncls.c (bfd_cache_init, bfd_open_file): Add prototypes to declarations. (obstack_chunk_alloc): Use bfd_xmalloc_by_size_t. (new_bfd): Prototype-style definition, using DEFUN. (bfd_alloc_grow, bfd_alloc, bfd_zalloc, bfd_realloc): Size argument is type size_t, not bfd_size_type. * ieee.c (obstack_chunk_alloc): Use bfd_xmalloc_by_size_t. * bfd.c (bfd_default_error_trap, bfd_error_trap, bfd_error_nonrepresentabltrap): Prototypes. * libbfd-in.h (bfd_alloc, bfd_zalloc, bfd_realloc, bfd_alloc_grow): Adjusted prototypes for arg type change. * archive.c (get_elt_at_filepos, do_slurp_bsd_armap, normalize, do_slurp_coff_armap, bfd_construct_extended_name_table): Prototypes.
-rw-r--r--bfd/bfd.c11
-rw-r--r--bfd/ieee.c36
-rw-r--r--bfd/opncls.c109
3 files changed, 93 insertions, 63 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 53dee5d..89d74f7 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -157,6 +157,7 @@ CODE_FRAGMENT
. struct trad_core_struct *trad_core_data;
. struct hppa_data_struct *hppa_data;
. struct hppa_core_struct *hppa_core_data;
+. struct sgi_core_struct *sgi_core_data;
. PTR any;
. } tdata;
.
@@ -292,15 +293,15 @@ bfd_errmsg (error_tag)
return bfd_errmsgs [(int)error_tag];
}
-
-void bfd_default_error_trap(error_tag)
-bfd_ec error_tag;
+void
+DEFUN (bfd_default_error_trap, (error_tag),
+ bfd_ec error_tag)
{
printf("bfd assert fail (%s)\n", bfd_errmsg(error_tag));
}
-void (*bfd_error_trap)() = bfd_default_error_trap;
-void (*bfd_error_nonrepresentabltrap)() = bfd_default_error_trap;
+void (*bfd_error_trap) PARAMS ((bfd_ec)) = bfd_default_error_trap;
+void (*bfd_error_nonrepresentabltrap) PARAMS ((bfd_ec)) = bfd_default_error_trap;
void
DEFUN(bfd_perror,(message),
diff --git a/bfd/ieee.c b/bfd/ieee.c
index f294088..3018996 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "obstack.h"
-#define obstack_chunk_alloc bfd_xmalloc
+#define obstack_chunk_alloc bfd_xmalloc_by_size_t
#define obstack_chunk_free free
/* Functions for writing to ieee files in the strange way that the
@@ -1004,7 +1004,7 @@ DEFUN(ieee_archive_p,(abfd),
boolean loop;
unsigned int i;
-uint8e_type buffer[512];
+ unsigned char buffer[512];
struct obstack ob;
file_ptr buffer_offset = 0;
ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
@@ -1122,8 +1122,9 @@ DEFUN(ieee_object_p,(abfd),
char *processor;
unsigned int part;
ieee_data_type *ieee;
- uint8e_type buffer[300];
+ unsigned char buffer[300];
ieee_data_type *save = IEEE_DATA(abfd);
+
abfd->tdata.ieee_data = 0;
ieee_mkobject(abfd);
@@ -1198,7 +1199,7 @@ DEFUN(ieee_object_p,(abfd),
quickly. We can work out how big the file is from the trailer
record */
- IEEE_DATA(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+ IEEE_DATA(abfd)->h.first_byte = (unsigned char *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+ 50);
bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd);
@@ -1211,6 +1212,18 @@ abfd->tdata.ieee_data = save;
return (bfd_target *)NULL;
}
+void
+DEFUN(ieee_get_symbol_info,(ignore_abfd, symbol, ret),
+ bfd *ignore_abfd AND
+ asymbol *symbol AND
+ symbol_info *ret)
+{
+ bfd_symbol_info (symbol, ret);
+ if (symbol->name[0] == ' ')
+ ret->name = "* empty table entry ";
+ if (!symbol->section)
+ ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
+}
void
DEFUN(ieee_print_symbol,(ignore_abfd, afile, symbol, how),
@@ -1232,7 +1245,6 @@ DEFUN(ieee_print_symbol,(ignore_abfd, afile, symbol, how),
#endif
BFD_FAIL();
break;
- case bfd_print_symbol_nm:
case bfd_print_symbol_all:
{
CONST char *section_name = symbol->section == (asection *)NULL ?
@@ -1261,7 +1273,7 @@ static void
DEFUN(do_one,(ieee, current_map, location_ptr,s),
ieee_data_type *ieee AND
ieee_per_section_type *current_map AND
- uint8e_type *location_ptr AND
+ unsigned char *location_ptr AND
asection *s)
{
switch (this_byte(&(ieee->h)))
@@ -1522,7 +1534,7 @@ DEFUN(ieee_slurp_section_data,(abfd),
*/
unsigned int iterations ;
- uint8e_type *start ;
+ unsigned char *start ;
next_byte(&(ieee->h));
iterations = must_parse_int(&(ieee->h));
start = ieee->h.input_p;
@@ -1780,7 +1792,7 @@ DEFUN(do_with_relocs,(abfd, s),
if ((PTR)stream == (PTR)NULL) {
/* Outputting a section without data, fill it up */
- stream = (uint8e_type *)(bfd_alloc(abfd, s->_raw_size));
+ stream = (unsigned char *)(bfd_alloc(abfd, s->_raw_size));
memset((PTR)stream, 0, s->_raw_size);
}
while (current_byte_index < s->_raw_size) {
@@ -2989,8 +3001,12 @@ bfd_target ieee_vec =
' ', /* ar_pad_char */
16, /* ar_max_namelen */
1, /* minimum alignment */
-_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
-_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
+_do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16, /* data */
+_do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16, /* hdrs */
{ _bfd_dummy_target,
ieee_object_p, /* bfd_check_format */
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 3acc1fd..1e6e6ef 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -18,25 +18,23 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* $Id$ */
-
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
-extern void bfd_cache_init();
-FILE *bfd_open_file();
+extern void bfd_cache_init PARAMS ((bfd *));
+FILE *bfd_open_file PARAMS ((bfd *));
/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
if we do that we can't use fcntl. */
-#define obstack_chunk_alloc bfd_xmalloc
+#define obstack_chunk_alloc bfd_xmalloc_by_size_t
#define obstack_chunk_free free
/* Return a new BFD. All BFD's are allocated through this routine. */
-bfd *new_bfd()
+bfd *new_bfd PARAMS ((void))
{
bfd *nbfd;
@@ -55,7 +53,7 @@ bfd *new_bfd()
nbfd->sections = (asection *)NULL;
nbfd->format = bfd_unknown;
nbfd->my_archive = (bfd *)NULL;
- nbfd->origin = 0;
+ nbfd->origin = 0;
nbfd->opened_once = false;
nbfd->output_has_begun = false;
nbfd->section_count = 0;
@@ -65,7 +63,7 @@ bfd *new_bfd()
nbfd->flags = NO_FLAGS;
nbfd->mtime_set = false;
-
+
return nbfd;
}
@@ -124,7 +122,7 @@ DEFUN(bfd_openr, (filename, target),
}
nbfd->filename = filename;
- nbfd->direction = read_direction;
+ nbfd->direction = read_direction;
if (bfd_open_file (nbfd) == NULL) {
bfd_error = system_call_error; /* File didn't exist, or some such */
@@ -153,7 +151,18 @@ SYNOPSIS
DESCRIPTION
bfd_fdopenr is to bfd_fopenr much like fdopen is to fopen.
It opens a BFD on a file already described by the @var{fd}
- supplied.
+ supplied.
+
+ When the file is later bfd_closed, the file descriptor will be closed.
+
+ If the caller desires that this file descriptor be cached by BFD
+ (opened as needed, closed as needed to free descriptors for
+ other opens), with the supplied @var{fd} used as an initial
+ file descriptor (but subject to closure at any time), set
+ bfd->cacheable nonzero in the returned BFD. The default is to
+ assume no cacheing; the file descriptor will remain open until
+ bfd_close, and will not be affected by BFD operations on other
+ files.
Possible errors are no_memory, invalid_target and system_call
error.
@@ -170,7 +179,7 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
int fdflags;
bfd_error = system_call_error;
-
+
#ifdef NO_FCNTL
fdflags = O_RDWR; /* Assume full access */
#else
@@ -190,18 +199,22 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
bfd_error = invalid_target;
return NULL;
}
-
-#ifdef FASCIST_FDOPEN
- nbfd->iostream = (char *) fdopen (fd, FOPEN_RB);
+#if defined(VMS) || defined(__GO32__)
+ nbfd->iostream = (char *)fopen(filename, FOPEN_RB);
#else
- /* if the fd were open for read only, this still would not hurt: */
- nbfd->iostream = (char *) fdopen (fd, FOPEN_RUB);
+ /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
+ switch (fdflags & (O_ACCMODE)) {
+ case O_RDONLY: nbfd->iostream = (char *) fdopen (fd, FOPEN_RB); break;
+ case O_WRONLY: nbfd->iostream = (char *) fdopen (fd, FOPEN_RUB); break;
+ case O_RDWR: nbfd->iostream = (char *) fdopen (fd, FOPEN_RUB); break;
+ default: abort ();
+ }
#endif
if (nbfd->iostream == NULL) {
(void) obstack_free (&nbfd->memory, (PTR)0);
return NULL;
}
-
+
/* OK, put everything where it belongs */
nbfd->filename = filename;
@@ -212,11 +225,11 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
/* (O_ACCMODE) parens are to avoid Ultrix header file bug */
switch (fdflags & (O_ACCMODE)) {
case O_RDONLY: nbfd->direction = read_direction; break;
- case O_WRONLY: nbfd->direction = write_direction; break;
+ case O_WRONLY: nbfd->direction = write_direction; break;
case O_RDWR: nbfd->direction = both_direction; break;
default: abort ();
}
-
+
bfd_cache_init (nbfd);
return nbfd;
@@ -239,7 +252,7 @@ DESCRIPTION
file format @var{target}, and returns a pointer to it.
Possible errors are system_call_error, no_memory,
- invalid_target.
+ invalid_target.
*/
bfd *
@@ -249,7 +262,7 @@ DEFUN(bfd_openw,(filename, target),
{
bfd *nbfd;
bfd_target *target_vec;
-
+
bfd_error = system_call_error;
/* nbfd has to point to head of malloc'ed block so that bfd_close may
@@ -290,7 +303,10 @@ DESCRIPTION
and closed. If the created file is executable, then
<<chmod>> is called to mark it as such.
- All memory attached to the BFD's obstacks is released.
+ All memory attached to the BFD's obstacks is released.
+
+ The file descriptor associated with the BFD is closed (even
+ if it was passed in to BFD by bfd_fdopenr).
RETURNS
<<true>> is returned if all is ok, otherwise <<false>>.
@@ -301,17 +317,20 @@ boolean
DEFUN(bfd_close,(abfd),
bfd *abfd)
{
+ boolean ret;
+
if (!bfd_read_p(abfd))
if (BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)) != true)
return false;
if (BFD_SEND (abfd, _close_and_cleanup, (abfd)) != true) return false;
- bfd_cache_close(abfd);
+ ret = bfd_cache_close(abfd);
/* If the file was open for writing and is now executable,
make it so */
- if (abfd->direction == write_direction
+ if (ret == true
+ && abfd->direction == write_direction
&& abfd->flags & EXEC_P) {
struct stat buf;
stat(abfd->filename, &buf);
@@ -329,7 +348,7 @@ DEFUN(bfd_close,(abfd),
}
(void) obstack_free (&abfd->memory, (PTR)0);
(void) free(abfd);
- return true;
+ return ret;
}
/*
@@ -348,7 +367,7 @@ DESCRIPTION
If the created file is executable, then <<chmod>> is called
to mark it as such.
- All memory attached to the BFD's obstacks is released.
+ All memory attached to the BFD's obstacks is released.
RETURNS
<<true>> is returned if all is ok, otherwise <<false>>.
@@ -359,11 +378,14 @@ boolean
DEFUN(bfd_close_all_done,(abfd),
bfd *abfd)
{
- bfd_cache_close(abfd);
+ boolean ret;
+
+ ret = bfd_cache_close(abfd);
/* If the file was open for writing and is now executable,
make it so */
- if (abfd->direction == write_direction
+ if (ret == true
+ && abfd->direction == write_direction
&& abfd->flags & EXEC_P) {
struct stat buf;
stat(abfd->filename, &buf);
@@ -381,7 +403,7 @@ DEFUN(bfd_close_all_done,(abfd),
}
(void) obstack_free (&abfd->memory, (PTR)0);
(void) free(abfd);
- return true;
+ return ret;
}
@@ -424,7 +446,7 @@ DESCRIPTION
This routine creates a new BFD in the manner of
<<bfd_openw>>, but without opening a file. The new BFD
takes the target from the target used by @var{template}. The
- format is always set to <<bfd_object>>.
+ format is always set to <<bfd_object>>.
*/
@@ -447,7 +469,7 @@ DEFUN(bfd_create,(filename, template),
return nbfd;
}
-/*
+/*
INTERNAL_FUNCTION
bfd_alloc_by_size_t
@@ -460,7 +482,7 @@ DESCRIPTION
*/
-PTR
+PTR
DEFUN(bfd_alloc_by_size_t,(abfd, size),
bfd *abfd AND
size_t size)
@@ -472,9 +494,9 @@ DEFUN(bfd_alloc_by_size_t,(abfd, size),
DEFUN(void bfd_alloc_grow,(abfd, ptr, size),
bfd *abfd AND
PTR ptr AND
- bfd_size_type size)
+ size_t size)
{
- (void) obstack_grow(&(abfd->memory), ptr, size);
+ (void) obstack_grow(&(abfd->memory), ptr, size);
}
DEFUN(PTR bfd_alloc_finish,(abfd),
bfd *abfd)
@@ -484,16 +506,17 @@ DEFUN(PTR bfd_alloc_finish,(abfd),
DEFUN(PTR bfd_alloc, (abfd, size),
bfd *abfd AND
- bfd_size_type size)
+ size_t size)
{
return bfd_alloc_by_size_t(abfd, (size_t)size);
}
DEFUN(PTR bfd_zalloc,(abfd, size),
bfd *abfd AND
- bfd_size_type size)
+ size_t size)
{
- PTR res = bfd_alloc(abfd, size);
+ PTR res;
+ res = bfd_alloc(abfd, size);
memset(res, 0, (size_t)size);
return res;
}
@@ -501,19 +524,9 @@ DEFUN(PTR bfd_zalloc,(abfd, size),
DEFUN(PTR bfd_realloc,(abfd, old, size),
bfd *abfd AND
PTR old AND
- bfd_size_type size)
+ size_t size)
{
PTR res = bfd_alloc(abfd, size);
memcpy(res, old, (size_t)size);
return res;
}
-
-
-
-
-
-
-
-
-
-