#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
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;
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);
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);
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),
#endif
BFD_FAIL();
break;
- case bfd_print_symbol_nm:
case bfd_print_symbol_all:
{
CONST char *section_name = symbol->section == (asection *)NULL ?
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)))
*/
unsigned int iterations ;
- uint8e_type *start ;
+ unsigned char *start ;
next_byte(&(ieee->h));
iterations = must_parse_int(&(ieee->h));
start = ieee->h.input_p;
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) {
' ', /* 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 */
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;
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;
nbfd->flags = NO_FLAGS;
nbfd->mtime_set = false;
-
+
return nbfd;
}
}
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 */
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.
int fdflags;
bfd_error = system_call_error;
-
+
#ifdef NO_FCNTL
fdflags = O_RDWR; /* Assume full access */
#else
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;
/* (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;
file format @var{target}, and returns a pointer to it.
Possible errors are system_call_error, no_memory,
- invalid_target.
+ invalid_target.
*/
bfd *
{
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
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>>.
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);
}
(void) obstack_free (&abfd->memory, (PTR)0);
(void) free(abfd);
- return true;
+ return ret;
}
/*
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>>.
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);
}
(void) obstack_free (&abfd->memory, (PTR)0);
(void) free(abfd);
- return true;
+ return ret;
}
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>>.
*/
return nbfd;
}
-/*
+/*
INTERNAL_FUNCTION
bfd_alloc_by_size_t
*/
-PTR
+PTR
DEFUN(bfd_alloc_by_size_t,(abfd, size),
bfd *abfd AND
size_t 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)
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;
}
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;
}
-
-
-
-
-
-
-
-
-
-