diff options
author | John Gilmore <gnu@cygnus> | 1991-05-02 04:11:40 +0000 |
---|---|---|
committer | John Gilmore <gnu@cygnus> | 1991-05-02 04:11:40 +0000 |
commit | fc7233808a1d88db99a5181e1ee0f6865f8f5206 (patch) | |
tree | 2f0626920d2d237a52aae12eccd0d5b8dd54ec1c /bfd/opncls.c | |
parent | ff37ea550b842cdb18aca531e5e705c03d4eed72 (diff) | |
download | gdb-fc7233808a1d88db99a5181e1ee0f6865f8f5206.zip gdb-fc7233808a1d88db99a5181e1ee0f6865f8f5206.tar.gz gdb-fc7233808a1d88db99a5181e1ee0f6865f8f5206.tar.bz2 |
Merge devo/bfd with GDB's bfd.
Remove obstack.h to ../include and obstack.c to ../libiberty.
Move COFF symbol swapping code to coffswap.c where GDB can call it but it
won't be duplicated if we have N different COFF targets.
Add support for traditional Unix core files (with a upage). This support
is from an Ultrix port, but is probably slightly broken now.
Improve bfd_release's of obstack'd items on error returns.
gcc -Wall fixes.
Handle section alignment slightly better in coff, and comment where it
needs more work (on page-aligning virtual vs file addresses for DPAGED).
Use set_tdata everywhere that tdata is set, to avoid "cast to the left
of assignment" problems with some compilers.
Move bfd_alloc, bfd_zalloc, bfd_realloc, and bfd_release into libbfd.h
(from bfd.h) since they are internal routines.
Remove the redundant suffix "_struct" from struct tags.
Set symbol count early in file reading, before slurping in the syms,
for GDB's use.
Diffstat (limited to 'bfd/opncls.c')
-rw-r--r-- | bfd/opncls.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/bfd/opncls.c b/bfd/opncls.c index 8b656bb..9b91c2f 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1,3 +1,5 @@ +/* opncls.c -- open and close a bfd. */ + /* Copyright (C) 1990, 1991 Free Software Foundation, Inc. This file is part of BFD, the Binary File Diddler. @@ -18,14 +20,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* $Id$ */ -/*** opncls.c -- open and close a bfd. */ - #include "sysdep.h" #include "bfd.h" #include "libbfd.h" - - extern void bfd_cache_init(); FILE *bfd_open_file(); @@ -52,11 +50,12 @@ FILE *bfd_open_file(); Perhaps, since unix has so many different kinds of locking anyway, we should use the emacs lock scheme?... */ - #define obstack_chunk_alloc malloc #define obstack_chunk_free free +/* Return a new BFD. All BFD's are allocated through this routine. */ + bfd *new_bfd() { struct obstack tmp; @@ -64,6 +63,8 @@ bfd *new_bfd() obstack_begin(&tmp,128); nbfd = (bfd *)obstack_alloc(&tmp,sizeof(bfd)); + memset((PTR)nbfd, 0, sizeof (bfd)); /* Clear it */ + nbfd->memory = tmp; nbfd->direction = no_direction; @@ -80,8 +81,12 @@ bfd *new_bfd() nbfd->sections = (asection *)NULL; nbfd->cacheable = false; nbfd->flags = NO_FLAGS; + nbfd->mtime_set = 0; return nbfd; } + +/* Allocate a new BFD as a member of archive OBFD. */ + bfd *new_bfd_contained_in(obfd) bfd *obfd; { @@ -179,7 +184,7 @@ DEFUN(bfd_fdopenr,(filename, target, fd), /* if the fd were open for read only, this still would not hurt: */ nbfd->iostream = (char *) fdopen (fd, "r+"); if (nbfd->iostream == NULL) { - free (nbfd); + (void) obstack_free (&nbfd->memory, (PTR)0); return NULL; } @@ -240,7 +245,7 @@ DEFUN(bfd_openw,(filename, target), if (bfd_open_file (nbfd) == NULL) { bfd_error = system_call_error; /* File not writeable, etc */ - free (nbfd); + (void) obstack_free (&nbfd->memory, (PTR)0); return NULL; } return nbfd; @@ -264,12 +269,12 @@ bfd_close (abfd) stat(abfd->filename, &buf); chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH); } - obstack_free(&abfd->memory, (PTR)0); + (void) obstack_free (&abfd->memory, (PTR)0); return true; } -/* - called to create a bfd with no ascociated file or target - */ + +/* Create a bfd with no associated file or target. */ + bfd * DEFUN(bfd_create,(filename, template), CONST char *filename AND @@ -287,40 +292,39 @@ DEFUN(bfd_create,(filename, template), nbfd->direction = no_direction; bfd_set_format(nbfd, bfd_object); return nbfd; - - - } +/* Memory allocation */ + DEFUN(PTR bfd_alloc, (abfd, size), bfd *abfd AND - size_t size) + bfd_size_type size) { - PTR res = obstack_alloc(&(abfd->memory),size); + PTR res = obstack_alloc(&(abfd->memory), (int)size); return res; } DEFUN(PTR bfd_zalloc,(abfd, size), bfd *abfd AND - size_t size) + bfd_size_type size) { PTR res = bfd_alloc(abfd, size); - memset(res, 0, size); + memset(res, 0, (size_t)size); return res; } DEFUN(PTR bfd_realloc,(abfd, old, size), bfd *abfd AND PTR old AND - size_t size) + bfd_size_type size) { PTR res = bfd_alloc(abfd, size); - memcpy(res, old, size); + memcpy(res, old, (size_t)size); return res; } -DEFUN(size_t bfd_alloc_size,(abfd), +DEFUN(bfd_size_type bfd_alloc_size,(abfd), bfd *abfd) { struct _obstack_chunk *chunk = abfd->memory.chunk; |