obstack_alloc fails.
(bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
fails.
* libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
* Many files: don't set bfd_error_no_memory if one of the above
routines fails.
Wed Nov 29 12:42:36 1995 Ian Lance Taylor <ian@cygnus.com>
+ * opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
+ obstack_alloc fails.
+ (bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
+ fails.
+ * libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
+ * Many files: don't set bfd_error_no_memory if one of the above
+ routines fails.
+
* elf.c (assign_file_positions_for_segments): Don't adjust p_paddr
if p_paddr_valid is set.
(copy_private_bfd_data): New static function.
/* BFD back-end for AIX on PS/2 core files.
This was based on trad-core.c, which was written by John Gilmore of
Cygnus Support.
- Copyright 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
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. */
-
-/* To use this file on a particular host, configure the host with these
- parameters in the config/h-HOST file:
-
- HDEFINES=-DAIX386_CORE=1
- HDEPFILES=aix386-core.o
- */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
asection *sections[MAX_CORE_SEGS];
};
-static bfd_target *
+static const bfd_target *
aix386_core_file_p (abfd)
bfd *abfd;
{
mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
if (mergem == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return 0;
- }
+ return 0;
core = &mergem->internal_core;
if (core_regsec (abfd) == NULL)
{
loser:
- bfd_set_error (bfd_error_no_memory);
bfd_release (abfd, (char *)mergem);
return 0;
}
core_regsec (abfd)->name = ".reg";
core_reg2sec (abfd)->name = ".reg2";
- core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
- core_reg2sec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+ core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
+ core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
-bfd_target aix386_core_vec =
+const bfd_target aix386_core_vec =
{
"aix386-core",
bfd_target_unknown_flavour,
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment power */
NO_GET, NO_GETS, NO_PUT,
NO_GET, NO_GETS, NO_PUT,
NO_GET, NO_GETS, NO_PUT, /* data */
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (_bfd_generic),
BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
(PTR) 0
};
goto no_more_sections;
default:
- fprintf (stderr, "Unknown section type in a.out.adobe file: %x\n",
- ext->e_type[0]);
+ (*_bfd_error_handler)
+ ("%s: Unknown section type in a.out.adobe file: %x\n",
+ bfd_get_filename (abfd), ext->e_type[0]);
goto no_more_sections;
}
/* Fix the name, if it is a sprintf'd name. */
if (sect->name == try_again) {
newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
- if (newname == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (newname == NULL)
return 0;
- }
strcpy (newname, sect->name);
sect->name = newname;
}
struct bout_data_struct *rawptr;
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
- if (rawptr == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (rawptr == NULL)
return false;
- }
abfd->tdata.bout_data = rawptr;
exec_hdr (abfd) = &rawptr->e;
#define aout_32_sizeof_headers aout_adobe_sizeof_headers
#define aout_32_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
+#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
#define aout_32_bfd_relax_section bfd_generic_relax_section
#define aout_32_bfd_link_hash_table_create \
_bfd_generic_link_hash_table_create
const bfd_target *result;
rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
- if (rawptr == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (rawptr == NULL)
return 0;
- }
oldrawptr = abfd->tdata.aout_data;
abfd->tdata.aout_data = rawptr;
/* Use an intermediate variable for clarity */
rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
- if (rawptr == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (rawptr == NULL)
return false;
- }
abfd->tdata.aout_data = rawptr;
exec_hdr (abfd) = &(rawptr->e);
copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
if (copy == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
strcpy (copy, cache_ptr->symbol.name);
section = bfd_make_section (abfd, copy);
reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
if (reloc == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Build a relocation entry for the constructor. */
switch (cache_ptr->type & N_TYPE)
aout_symbol_type *new =
(aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
new->symbol.the_bfd = abfd;
return &new->symbol;
each_size = obj_reloc_entry_size (abfd);
natsize = each_size * count;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
- if (!native) {
- bfd_set_error (bfd_error_no_memory);
+ if (!native)
return false;
- }
generic = section->orelocation;
ret = ((struct aout_link_hash_entry *)
bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
if (ret == (struct aout_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct aout_link_hash_entry *)
ret = ((struct aout_link_hash_table *)
bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_link_hash_table *) NULL;
- }
+ return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (ret, abfd,
NAME(aout,link_hash_newfunc)))
{
((size_t) sym_count
* sizeof (struct aout_link_hash_entry *))));
if (sym_hash == NULL && sym_count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_aout_sym_hashes (abfd) = sym_hash;
add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
and call get_reloc_upper_bound and canonicalize_reloc to
work out the number of relocs needed, and then multiply
by the reloc size. */
- abort ();
+ (*_bfd_error_handler)
+ ("%s: relocateable link from %s to %s not supported",
+ bfd_get_filename (abfd),
+ sub->xvec->name, abfd->xvec->name);
+ bfd_set_error (bfd_error_invalid_operation);
+ goto error_return;
}
}
size = bfd_get_reloc_size (howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
r = MY_relocate_contents (howto, finfo->output_bfd,
pr->addend, buf);
switch (r)
bfd_zalloc (abfd, sizeof (struct artdata)));
if (bfd_ardata (abfd) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
bfd_ardata (abfd)->cache = NULL;
bfd_ardata (abfd)->archive_head = NULL;
_bfd_create_empty_archive_element_shell (obfd)
bfd *obfd;
{
- bfd *nbfd;
-
- nbfd = _bfd_new_bfd_contained_in (obfd);
- if (nbfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
- return nbfd;
+ return _bfd_new_bfd_contained_in (obfd);
}
/*
sizeof (struct ar_cache)));
if (new_cache == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
new_cache->ptr = filepos;
new_cache->arelt = new_elt;
allocptr = bfd_zalloc (abfd, allocsize);
if (allocptr == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
filename = (allocptr
+ sizeof (struct areltdata)
+ sizeof (struct ar_hdr));
{
allocptr = bfd_zalloc (abfd, allocsize);
if (allocptr == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
}
ared = (struct areltdata *) allocptr;
bfd_generic_archive_p (abfd)
bfd *abfd;
{
+ struct artdata *tdata_hold;
char armag[SARMAG + 1];
+ tdata_hold = abfd->tdata.aout_ar_data;
+
if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_zalloc (abfd, sizeof (struct artdata)));
if (bfd_ardata (abfd) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
bfd_ardata (abfd)->first_file_filepos = SARMAG;
bfd_ardata (abfd)->cache = NULL;
if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
{
bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = NULL;
+ abfd->tdata.aout_ar_data = tdata_hold;
return NULL;
}
if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
{
bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = NULL;
+ abfd->tdata.aout_ar_data = tdata_hold;
return NULL;
}
err = bfd_get_error ();
(void) bfd_close (first);
bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = NULL;
+ abfd->tdata.aout_ar_data = tdata_hold;
bfd_set_error (err);
return NULL;
}
raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
if (raw_armap == (bfd_byte *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
{
(ardata->symdef_count
* sizeof (carsym)));
if (!ardata->symdefs)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (counter = 0, set = ardata->symdefs;
counter < ardata->symdef_count;
ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
if (ardata->symdefs == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
carsyms = ardata->symdefs;
stringbase = ((char *) ardata->symdefs) + carsym_size;
/* Allocate and read in the raw offsets. */
raw_armap = (int *) bfd_alloc (abfd, ptrsize);
if (raw_armap == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto release_symdefs;
- }
+ goto release_symdefs;
if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
|| bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
{
raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
if (raw_armap == NULL)
{
- bfd_set_error (bfd_error_no_memory);
byebye:
bfd_release (abfd, (PTR) mapdata);
return false;
(ardata->symdef_count
* BSD_SYMDEF_SIZE));
if (!ardata->symdefs)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (counter = 0, set = ardata->symdefs;
counter < ardata->symdef_count;
bfd_zalloc (abfd, namedata->parsed_size);
if (bfd_ardata (abfd)->extended_names == NULL)
{
- bfd_set_error (bfd_error_no_memory);
byebye:
bfd_release (abfd, (PTR) namedata);
return false;
copy = (char *) bfd_alloc (abfd, last - first + 1);
if (copy == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
memcpy (copy, first, last - first);
copy[last - first] = 0;
*tabloc = bfd_zalloc (abfd, total_namelen);
if (*tabloc == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
*tablen = total_namelen;
strptr = *tabloc;
ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
sizeof (struct areltdata));
if (ared == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
/* ar headers are space padded, not null padded! */
them when done. */
first_name = bfd_alloc (arch, 1);
if (first_name == NULL)
- goto no_memory_return;
+ goto error_return;
/* Drop all the files called __.SYMDEF, we're going to make our
own */
bfd_alloc (arch,
sizeof (char *)));
if (map[orl_count].name == NULL)
- goto no_memory_return;
+ goto error_return;
*(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
if (*(map[orl_count].name) == NULL)
- goto no_memory_return;
+ goto error_return;
strcpy (*(map[orl_count].name), syms[src_count]->name);
(map[orl_count]).pos = (file_ptr) current;
(map[orl_count]).namidx = stridx;
buf = (char *) bfd_alloc (abfd, size);
if (buf == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return "";
sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
if (syms == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Start symbol. */
syms[0].the_bfd = abfd;
binary_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *ret;
-
- ret = (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
- if (ret == NULL)
- bfd_set_error (bfd_error_no_memory);
- return ret;
+ return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
}
#define binary_print_symbol _bfd_nosymbols_print_symbol
#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define binary_bfd_final_link _bfd_generic_final_link
#define binary_bfd_link_split_section _bfd_generic_link_split_section
+#define binary_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
const bfd_target binary_vec =
{
struct bout_data_struct *rawptr;
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
- if (rawptr == NULL) {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ if (rawptr == NULL)
+ return false;
abfd->tdata.bout_data = rawptr;
exec_hdr (abfd) = &rawptr->e;
#define b_out_bfd_final_link _bfd_generic_final_link
#define b_out_bfd_link_split_section _bfd_generic_link_split_section
+#define aout_32_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
const bfd_target b_out_vec_big_host =
{
'_', /* symbol leading char */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 2, /* minumum alignment power */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
'_', /* symbol leading char */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 2, /* minum align */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
int sig;
};
\f
-static bfd_target *
+static const bfd_target *
cisco_core_file_p (abfd)
bfd *abfd;
{
((struct cisco_core_struct *)
bfd_zmalloc (sizeof (struct cisco_core_struct)));
if (abfd->tdata.cisco_core_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
{
asect = (asection *) bfd_zmalloc (sizeof (asection));
if (asect == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
asect->name = ".reg";
- asect->flags = SEC_ALLOC | SEC_HAS_CONTENTS;
+ asect->flags = SEC_HAS_CONTENTS;
/* This can be bigger than the real size. Set it to the size of the whole
core file. */
asect->_raw_size = statbuf.st_size;
We call it .data. */
asect = (asection *) bfd_zmalloc (sizeof (asection));
if (asect == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
asect->name = ".data";
asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
/* The size of memory is the size of the core file itself. */
return true;
}
\f
-bfd_target cisco_core_vec =
+const bfd_target cisco_core_vec =
{
"trad-core",
bfd_target_unknown_flavour,
0, /* symbol prefix */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment power */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (_bfd_generic),
BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
(PTR) 0 /* backend_data */
};
(NUM_RELOC_SECTIONS
* sizeof (asection *))));
if (!symndx_to_section)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
symndx_to_section[RELOC_SECTION_NONE] = NULL;
symndx_to_section[RELOC_SECTION_TEXT] =
((PTR) bfd_zalloc (abfd,
sizeof (struct coff_section_tdata)));
if (osec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return bfd_reloc_overflow;
- }
+ return bfd_reloc_overflow;
}
coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
}
{
struct coff_link_hash_entry *h;
+ *adjustedp = false;
+
h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
if (h == NULL
|| (h->root.type != bfd_link_hash_defined
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 3, /* minimum alignment power */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 3, /* minimum alignment power */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
(NUM_RELOC_SECTIONS
* sizeof (asection *))));
if (!symndx_to_section)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
symndx_to_section[RELOC_SECTION_NONE] = NULL;
symndx_to_section[RELOC_SECTION_TEXT] =
sec->used_by_bfd =
(PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
if (sec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
section_tdata = ecoff_section_data (abfd, sec);
section_tdata->external_relocs = NULL;
section_tdata->external_relocs =
(PTR) bfd_alloc (abfd, external_relocs_size);
if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
|| (bfd_read (section_tdata->external_relocs, 1,
size = sec->reloc_count * sizeof (long);
offsets = (long *) bfd_alloc_by_size_t (abfd, size);
if (offsets == (long *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
memset (offsets, 0, size);
section_tdata->offsets = offsets;
}
adjust = ((struct ecoff_value_adjust *)
bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));
if (adjust == (struct ecoff_value_adjust *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
adjust->start = int_rel.r_vaddr;
adjust->end = sec->vma + sec->_raw_size;
relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
if (relsec->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
p = relsec->contents;
mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
_bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
_bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
/* Supported architecture. */
bfd_arch_mips,
#define _bfd_ecoff_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
+/* Handling file windows is generic. */
+#define _bfd_ecoff_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
/* Relaxing sections is MIPS specific. */
#define _bfd_ecoff_bfd_relax_section mips_relax_section
ret = ((struct ppc_coff_link_hash_table *)
bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (! ppc_coff_link_hash_table_init (ret, abfd,
ppc_coff_link_hash_newfunc))
{
toc_64
};
+enum ref_category
+{
+ priv,
+ pub,
+ data
+};
+
struct list_ele
{
struct list_ele *next;
bfd_vma addr;
+ enum ref_category cat;
int offset;
const char *name;
};
extern struct list_ele *tail;
static void
-record_toc(toc_section, our_toc_offset, name)
+record_toc(toc_section, our_toc_offset, cat, name)
asection *toc_section;
int our_toc_offset;
+ enum ref_category cat;
const char *name;
{
/* add this entry to our toc addr-offset-name list */
t->next = 0;
t->offset = our_toc_offset;
t->name = name;
+ t->cat = cat;
t->addr = toc_section->output_offset + our_toc_offset;
if (head == 0)
(int *) bfd_zalloc (abfd,
obj_raw_syment_count(abfd) * sizeof(int));
if (local_syms == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_coff_local_toc_table(abfd) = local_syms;
for (i = 0; i < obj_raw_syment_count(abfd); ++i)
local_syms[i] = 1;
local_syms[sym] = global_toc_size;
ret_val = global_toc_size;
global_toc_size += 4;
+
+ /* The size must fit in a 16bit displacment */
+ if (global_toc_size >= 65535)
+ {
+ fprintf(stderr,
+ "Exceeded toc size of 65535\n");
+ abort();
+ }
+
#ifdef TOC_DEBUG
fprintf(stderr,
"Setting toc_offset for local sym %d to %d\n",
h->toc_offset = global_toc_size;
ret_val = global_toc_size;
global_toc_size += 4;
+
+ /* The size must fit in a 16bit displacment */
+ if (global_toc_size >= 65535)
+ {
+ fprintf(stderr,
+ "Exceeded toc size of 65535\n");
+ abort();
+ }
+
#ifdef TOC_DEBUG
fprintf(stderr,
"Setting toc_offset for sym %d (%s) [h=%p] to %d\n",
(int *) bfd_zalloc (abfd,
obj_raw_syment_count(abfd) * sizeof(int));
if (local_syms == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_coff_local_toc_table(abfd) = local_syms;
for (i = 0; i < obj_raw_syment_count(abfd); ++i)
local_syms[i] = 1;
#ifdef TOC_DEBUG
fprintf(stderr,
- "Not writing out toc_offset of %d for %s\n", our_toc_offset, name);
+ "Not writing out toc_offset of %d for %s\n",
+ our_toc_offset, name);
#endif
}
else
{
/* write out the toc entry */
- record_toc(toc_section, our_toc_offset, strdup(name));
+ record_toc(toc_section, our_toc_offset, priv, strdup(name));
#ifdef TOC_DEBUG
fprintf(stderr,
- "Writing out toc_offset toc_section (%p,%p)+%d val %d for %s\n",
+ "Writing out toc_offset "
+ "toc_section (%p,%p)+%d val %d for %s\n",
toc_section,
toc_section->contents,
our_toc_offset,
const char *name = h->root.root.root.string;
our_toc_offset = h->toc_offset;
- if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) == IMAGE_REL_PPC_TOCDEFN &&
- our_toc_offset == 1)
+ if ((r_flags & IMAGE_REL_PPC_TOCDEFN)
+ == IMAGE_REL_PPC_TOCDEFN
+ && our_toc_offset == 1)
{
- /* This is unbelievable cheese. Some knowledgable asm hacker has decided to
- use r2 as a base for loading a value. He/She does this by setting the
- tocdefn bit, and not supplying a toc definition. The behaviour is then
- to use the value of the symbol as a toc index. Good Grief.
+ /* This is unbelievable cheese. Some knowledgable asm
+ hacker has decided to use r2 as a base for loading
+ a value. He/She does this by setting the tocdefn bit,
+ and not supplying a toc definition. The behaviour is
+ then to use the difference between the value of the
+ symbol and the actual location of the toc as the toc
+ index.
+
+ In fact, what is usually happening is, because the
+ Import Address Table is mapped immediately following
+ the toc, some trippy library code trying for speed on
+ dll linkage, takes advantage of that and considers
+ the IAT to be part of the toc, thus saving a load.
*/
- our_toc_offset = val - (toc_section->output_section->vma + toc_section->output_offset);
+ our_toc_offset = val -
+ (toc_section->output_section->vma +
+ toc_section->output_offset);
+
+ /* The size must still fit in a 16bit displacment */
+ if (our_toc_offset >= 65535)
+ {
+ fprintf(stderr,
+ "TOCDEFN Relocation exceeded "
+ "displacment of 65535\n");
+ abort();
+ }
+
+ record_toc(toc_section, our_toc_offset, pub, strdup(name));
}
else if ((our_toc_offset & 1) != 0)
{
our_toc_offset &= ~1;
#ifdef TOC_DEBUG
fprintf(stderr,
- "Not writing out toc_offset of %d for %s\n", our_toc_offset, name);
+ "Not writing out toc_offset of %d for %s\n",
+ our_toc_offset, name);
#endif
}
else
{
- record_toc(toc_section, our_toc_offset, strdup(name));
+ record_toc(toc_section, our_toc_offset, pub, strdup(name));
#ifdef TOC_DEBUG
/* write out the toc entry */
fprintf(stderr,
- "Writing out toc_offset toc_section (%p,%p)+%d val %d for %s\n",
+ "Writing out toc_offset "
+ "toc_section (%p,%p)+%d val %d for %s\n",
toc_section,
toc_section->contents,
our_toc_offset,
false, false, true);
if (myh == 0)
{
- fprintf(stderr, "Missing idata magic cookies, this cannot work anyway...\n");
+ fprintf(stderr, "Missing idata magic cookies, "
+ "this cannot work anyway...\n");
abort();
}
struct list_ele *head;
struct list_ele *tail;
+static char *
+h1 = "\n\t\t\tTOC MAPPING\n\n";
+static char *
+h2 = " TOC disassembly Comments Name\n";
+static char *
+h3 = " Offset spelling (if present)\n";
+
void
dump_toc(vfile)
void *vfile;
FILE *file = vfile;
struct list_ele *t;
- fprintf(file,
- " Offset Offset Name if present\n");
+ fprintf(file, h1);
+ fprintf(file, h2);
+ fprintf(file, h3);
for(t = head; t != 0; t=t->next)
{
+ char *cat;
+
+ if (t->cat == priv)
+ cat = "private ";
+ else if (t->cat == pub)
+ cat = "public ";
+ else if (t->cat == data)
+ cat = "data-in-toc ";
+
+ if (t->offset > global_toc_size)
+ {
+ if (t->offset <= global_toc_size + thunk_size)
+ cat = "IAT reference ";
+ else
+ cat = "Out of bounds!";
+ }
+
fprintf(file,
- " %2x %04lx %s\n",
- t->offset - 32768, t->offset, t->name);
+ " %04lx (%d)", t->offset, t->offset - 32768);
+ fprintf(file,
+ " %s %s\n",
+ cat, t->name);
+
}
+
+ fprintf(file, "\n");
}
boolean
asection *sec;
struct internal_reloc *i, *rel;
-#if 0
+#if DEBUG_RELOC
fprintf(stderr,
"ppc_process_before_allocation: BFD %s\n",
bfd_get_filename(abfd));
for (; sec != 0; sec = sec->next)
{
int toc_offset;
+
#ifdef DEBUG_RELOC
fprintf(stderr,
" section %s reloc count %d\n",
switch(r_type)
{
case IMAGE_REL_PPC_TOCREL16:
+#if 0
+ /* FIXME:
+ This remains unimplemented for now, as it currently adds
+ un-necessary elements to the toc. All we need to do today
+ is not do anything if TOCDEFN is on.
+ */
if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
toc_offset = ppc_record_data_in_toc_entry(abfd, info, sec,
rel->r_symndx,
else
toc_offset = ppc_record_toc_entry(abfd, info, sec,
rel->r_symndx, default_toc);
+#endif
+ if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN )
+ toc_offset = ppc_record_toc_entry(abfd, info, sec,
+ rel->r_symndx, default_toc);
break;
case IMAGE_REL_PPC_IMGLUE:
ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);
unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
unsigned short junk = EXTRACT_JUNK (rel->r_type);
-fprintf(stderr,
- "coff_ppc_rtype_to_howto\n");
-
/* the masking process only slices off the bottom byte for r_type. */
if ( r_type > MAX_RELOC_INDEX )
{
\f
#ifndef COFF_IMAGE_WITH_PE
+/* FIXME:
+ What we're trying to do here is allocate a toc section (early), and attach
+ it to the last bfd to be processed. This avoids the problem of having a toc
+ written out before all files have been processed. This code allocates
+ a toc section for every file, and records the last one seen. There are
+ at least two problems with this approach:
+ 1. We allocate whole bunches of toc sections that are ignored, but at
+ at least we will not allocate a toc if no .toc is present.
+ 2. It's not clear to me that being the last bfd read necessarily means
+ that you are the last bfd closed.
+ 3. Doing it on a "swap in" hook depends on when the "swap in" is called,
+ and how often, etc. It's not clear to me that there isn't a hole here.
+*/
+
static void
ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
bfd *abfd;
((struct xcoff_tdata *)
bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
if (abfd->tdata.xcoff_obj_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
coff = coff_data (abfd);
coff->symbols = (coff_symbol_type *) NULL;
coff->conversion_table = (unsigned int *) NULL;
sz = strtol (hdr.size, (char **) NULL, 10);
contents = (bfd_byte *) bfd_alloc (abfd, sz);
if (contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
return false;
bfd_ardata (abfd)->symdefs = ((carsym *)
bfd_alloc (abfd, c * sizeof (carsym)));
if (bfd_ardata (abfd)->symdefs == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* After the count comes a list of four byte file offsets. */
for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
(struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
if (bfd_ardata (abfd) == (struct artdata *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
(char **) NULL, 10);
bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
if (bfd_ardata (abfd)->tdata == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
namlen = strtol (hdr.namlen, (char **) NULL, 10);
hdrp = bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
if (hdrp == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
return NULL;
ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
ret->arch_header = (char *) hdrp;
ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
}
offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
if (offsets == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
return false;
sub->arelt_data = ((struct areltdata *)
bfd_alloc (sub, sizeof (struct areltdata)));
if (sub->arelt_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
arch_eltdata (sub)->parsed_size = s.st_size;
return true;
}
\f
+/* We can't use the usual coff_sizeof_headers routine, because AIX
+ always uses an a.out header. */
+
+/*ARGSUSED*/
+static int
+_bfd_xcoff_sizeof_headers (abfd, reloc)
+ bfd *abfd;
+ boolean reloc;
+{
+ int size;
+
+ size = FILHSZ;
+ if (xcoff_data (abfd)->full_aouthdr)
+ size += AOUTSZ;
+ else
+ size += SMALL_AOUTSZ;
+ size += abfd->section_count * SCNHSZ;
+ return size;
+}
+\f
#define CORE_FILE_P _bfd_dummy_target
#define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
#endif /* LYNX_CORE */
-#define _bfd_xcoff_sizeof_headers coff_sizeof_headers
#define _bfd_xcoff_bfd_get_relocated_section_contents \
coff_bfd_get_relocated_section_contents
#define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
/* The transfer vector that leads the outside world to all of the above. */
-const bfd_target rs6000coff_vec =
+const bfd_target
+#ifdef TARGET_SYM
+ TARGET_SYM =
+#else
+ rs6000coff_vec =
+#endif
{
+#ifdef TARGET_NAME
+ TARGET_NAME,
+#else
"aixcoff-rs6000", /* name */
+#endif
bfd_target_coff_flavour,
true, /* data byte order is big */
true, /* header byte order is big */
sec->used_by_bfd =
((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
if (sec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
}
coff_section_data (abfd, sec)->relocs = internal_relocs;
sec->used_by_bfd =
((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
if (sec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
coff_section_data (abfd, sec)->relocs = NULL;
}
coff_section_data (abfd, sec)->contents = contents;
'_', /* leading symbol underscore */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 2, /* minimum section alignment */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
'_', /* leading symbol underscore */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 2, /* minimum section alignment */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
- /* Note that we use a special archive recognizer.
- This is so that we only use one archive format for both
- object file types */
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- _bfd_dummy_target, _bfd_dummy_target},
+ bfd_generic_archive_p, _bfd_dummy_target},
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
bfd_false},
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
if (abfd->tdata.coff_obj_data == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
coff = coff_data (abfd);
coff->symbols = (coff_symbol_type *) NULL;
coff->conversion_table = (unsigned int *) NULL;
nsyms += need_text + need_data + need_bss + need_file;
sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *));
if (!sympp2)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memcpy (sympp2, sympp, i * sizeof (asymbol *));
if (need_file)
{
{
PTR area = (PTR) bfd_alloc (abfd, size);
if (!area)
- {
- bfd_set_error (bfd_error_no_memory);
- return (NULL);
- }
+ return (NULL);
if (bfd_seek (abfd, where, seek_direction) != 0
|| bfd_read (area, 1, size, abfd) != size)
return (NULL);
lineno_cache =
(alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
if (lineno_cache == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
else
{
unsigned int counter = 0;
* sizeof (coff_symbol_type))));
if (cached_area == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- } /* on error */
+ return false;
table_ptr = ((unsigned int *)
bfd_alloc (abfd,
(obj_raw_syment_count (abfd)
* sizeof (unsigned int))));
if (table_ptr == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
else
{
coff_symbol_type *dst = cached_area;
bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
if (reloc_cache == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (idx = 0; idx < asect->reloc_count; idx++)
/* Assorted wastage to null-terminate the name, thanks AT&T! */
name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
if (name == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
name[sizeof (hdr->s_name)] = 0;
readsize = nscns * scnhsz;
external_sections = (char *) bfd_alloc (abfd, readsize);
if (!external_sections)
- {
- bfd_set_error (bfd_error_no_memory);
- goto fail;
- }
+ goto fail;
if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
goto fail;
(PTR) bfd_zalloc (abfd,
sizeof (struct coff_section_tdata));
if (sec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
coff_section_data (abfd, sec)->contents = NULL;
}
coff_section_data (abfd, sec)->relocs = free_internal;
sizeof (asymbol *)
* (symbol_count + 1));
if (!newsyms)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
bfd_ptr->outsymbols = newsyms;
for (i = 0; i < symbol_count; i++)
if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
symesz = bfd_coff_symesz (abfd);
buf = bfd_alloc (abfd, symesz);
if (!buf)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
if (bfd_write (buf, 1, symesz, abfd) != symesz)
return false;
auxesz = bfd_coff_auxesz (abfd);
buf = bfd_alloc (abfd, auxesz);
if (!buf)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (j = 0; j < native->u.syment.n_numaux; j++)
{
bfd_coff_swap_aux_out (abfd,
linesz = bfd_coff_linesz (abfd);
buff = bfd_alloc (abfd, linesz);
if (!buff)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
if (s->lineno_count)
debug_section = (PTR) bfd_alloc (abfd,
bfd_get_section_size_before_reloc (sect));
if (debug_section == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* Seek to the beginning of the `.debug' section and read it.
Save the current position first; it is needed by our caller.
}
if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (NULL);
- }
+ return (NULL);
strncpy (newname, name, len);
newname[len] = '\0';
return newname;
size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
internal = (combined_entry_type *) bfd_alloc (abfd, size);
if (internal == NULL && size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
internal_end = internal + obj_raw_syment_count (abfd);
if (! _bfd_coff_get_external_symbols (abfd))
} /* possible lengths of this string. */
if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (NULL);
- } /* on error */
+ return (NULL);
memset (newstring, 0, i);
strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
{
coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
if (new == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (NULL);
- } /* on error */
+ return (NULL);
memset (new, 0, sizeof *new);
new->symbol.section = 0;
new->native = 0;
{
coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
if (new == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (NULL);
- } /* on error */
+ return (NULL);
/* @@ This shouldn't be using a constant multiplier. */
new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
if (!new->native)
- {
- bfd_set_error (bfd_error_no_memory);
- return (NULL);
- } /* on error */
+ return (NULL);
new->symbol.section = bfd_abs_section_ptr;
new->symbol.flags = BSF_DEBUGGING;
new->lineno = (alent *) NULL;
ret = ((struct coff_link_hash_entry *)
bfd_hash_allocate (table, sizeof (struct coff_link_hash_entry)));
if (ret == (struct coff_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct coff_link_hash_entry *)
ret->numaux = 0;
ret->auxbfd = NULL;
ret->aux = NULL;
- ret->toc_offset = 1; /* invalid toc address, sets the high bit */
}
return (struct bfd_hash_entry *) ret;
ret = ((struct coff_link_hash_table *)
bfd_alloc (abfd, sizeof (struct coff_link_hash_table)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (! _bfd_coff_link_hash_table_init (ret, abfd,
_bfd_coff_link_hash_newfunc))
{
bfd_hash_allocate (table,
sizeof (struct coff_debug_merge_hash_entry)));
if (ret == (struct coff_debug_merge_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct coff_debug_merge_hash_entry *)
((size_t) symcount
* sizeof (struct coff_link_hash_entry *))));
if (sym_hash == NULL && symcount != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_coff_sym_hashes (abfd) = sym_hash;
memset (sym_hash, 0,
(size_t) symcount * sizeof (struct coff_link_hash_entry *));
(*sym_hash)->type = sym.n_type;
(*sym_hash)->numaux = sym.n_numaux;
(*sym_hash)->auxbfd = abfd;
- (*sym_hash)->toc_offset = 1;
if (sym.n_numaux != 0)
{
union internal_auxent *alloc;
(sym.n_numaux
* sizeof (*alloc))));
if (alloc == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (i = 0, eaux = esym + symesz, iaux = alloc;
i < sym.n_numaux;
i++, eaux += symesz, iaux++)
}
/* Write out the string table. */
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
- return false;
+ if (obj_raw_syment_count (abfd) != 0)
+ {
+ if (bfd_seek (abfd,
+ (obj_sym_filepos (abfd)
+ + obj_raw_syment_count (abfd) * symesz),
+ SEEK_SET) != 0)
+ return false;
#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
+ bfd_h_put_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ (bfd_byte *) strbuf);
#else
#error Change bfd_h_put_32
#endif
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
- return false;
+ if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ return false;
- if (! _bfd_stringtab_emit (abfd, finfo.strtab))
- return false;
+ if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+ return false;
+ }
_bfd_stringtab_free (finfo.strtab);
bfd_alloc (input_bfd,
sizeof (struct coff_debug_merge_type)));
if (mt == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
mt->class = isym.n_sclass;
/* Pick up the aux entry, which points to the end of the tag
bfd_alloc (input_bfd,
sizeof (struct coff_debug_merge_element)));
if (*epp == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
elename = _bfd_coff_internal_syment_name (input_bfd, islp,
elebuf);
copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1);
if (copy == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
strcpy (copy, elename);
(*epp)->name = copy;
size = bfd_get_reloc_size (howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
rstat = _bfd_relocate_contents (howto, output_bfd,
link_order->u.reloc.p->addend, buf);
abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
bfd_zalloc (abfd, sizeof (ecoff_data_type)));
if (abfd->tdata.ecoff_obj_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
return true;
}
}
raw = (PTR) bfd_alloc (abfd, raw_size);
if (raw == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_seek (abfd,
(ecoff_data (abfd)->sym_filepos
+ backend->debug_swap.external_hdr_size),
(internal_symhdr->ifdMax *
sizeof (struct fdr)));
if (debug->fdr == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
external_fdr_size = backend->debug_swap.external_fdr_size;
fdr_ptr = debug->fdr;
fraw_src = (char *) debug->external_fdr;
new = (ecoff_symbol_type *) bfd_alloc (abfd, sizeof (ecoff_symbol_type));
if (new == (ecoff_symbol_type *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (asymbol *) NULL;
- }
+ return (asymbol *) NULL;
memset ((PTR) new, 0, sizeof *new);
new->symbol.section = (asection *) NULL;
new->fdr = (FDR *) NULL;
copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
if (!copy)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
strcpy (copy, name);
section = bfd_make_section (abfd, copy);
}
reloc_chain =
(arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
if (!reloc_chain)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
reloc_chain->relent.sym_ptr_ptr =
bfd_get_section (asym)->symbol_ptr_ptr;
reloc_chain->relent.address = section->_raw_size;
internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type);
internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
if (internal == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
internal_ptr = internal;
eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext;
external_relocs = (char *) bfd_alloc (abfd, external_relocs_size);
if (internal_relocs == (arelent *) NULL
|| external_relocs == (char *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
return false;
if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
((struct ecoff_find_line *)
bfd_alloc (abfd, sizeof (struct ecoff_find_line)));
if (ecoff_data (abfd)->find_line_info == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
ecoff_data (abfd)->find_line_info->find_buffer = NULL;
ecoff_data (abfd)->find_line_info->fdrtab_len = 0;
ecoff_data (abfd)->find_line_info->fdrtab = NULL;
reloc_buff =
bfd_alloc (abfd, current->reloc_count * external_reloc_size);
if (reloc_buff == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
reloc_ptr_ptr = current->orelocation;
reloc_end = reloc_ptr_ptr + current->reloc_count;
raw_armap = (char *) bfd_alloc (abfd, parsed_size);
if (raw_armap == (char *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
{
bfd_alloc (abfd,
ardata->symdef_count * sizeof (struct symdef)));
if (!symdef_ptr)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
ardata->symdefs = (carsym *) symdef_ptr;
hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
if (!hashtable)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
current = abfd->archive_head;
last_elt = current;
(struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
if (bfd_ardata (abfd) == (struct artdata *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (const bfd_target *) NULL;
- }
+ return (const bfd_target *) NULL;
bfd_ardata (abfd)->first_file_filepos = SARMAG;
bfd_ardata (abfd)->cache = NULL;
ret = ((struct ecoff_link_hash_entry *)
bfd_hash_allocate (table, sizeof (struct ecoff_link_hash_entry)));
if (ret == (struct ecoff_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* Call the allocation method of the superclass. */
ret = ((struct ecoff_link_hash_entry *)
ret = ((struct ecoff_link_hash_table *)
bfd_alloc (abfd, sizeof (struct ecoff_link_hash_table)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (! _bfd_link_hash_table_init (&ret->root, abfd,
ecoff_link_hash_newfunc))
{
bfd_alloc (abfd,
ext_count * sizeof (struct bfd_link_hash_entry *)));
if (!sym_hash)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
ecoff_data (abfd)->sym_hashes = sym_hash;
ext_ptr = (char *) external_ext;
size = bfd_get_reloc_size (rel.howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
rstat = _bfd_relocate_contents (rel.howto, output_bfd, addend, buf);
switch (rstat)
{
ret = ((struct string_hash_entry *)
bfd_hash_allocate (table, sizeof (struct string_hash_entry)));
if (ret == (struct string_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* Call the allocation method of the superclass. */
ret = ((struct string_hash_entry *)
return false;
symbols = (asymbol **) bfd_alloc (output_bfd, symsize);
if (symbols == (asymbol **) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
symcount = bfd_canonicalize_symtab (input_bfd, symbols);
if (symcount < 0)
return false;
bfd_zalloc (abfd,
len * sizeof (struct ecoff_fdrtab_entry)));
if (line_info->fdrtab == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
line_info->fdrtab_len = len;
tab = line_info->fdrtab;
char *buf;
if ((buf = bfd_alloc (abfd, size)) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (bfd_seek (abfd, offset, SEEK_SET) == -1)
return NULL;
if (bfd_read ((PTR) buf, size, 1, abfd) != size)
elf_tdata (abfd) = (struct elf_obj_tdata *)
bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
if (elf_tdata (abfd) == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* since everything is done at close time, do we need any
initialization? */
ret = ((struct elf_link_hash_entry *)
bfd_hash_allocate (table, sizeof (struct elf_link_hash_entry)));
if (ret == (struct elf_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct elf_link_hash_entry *)
ret = ((struct elf_link_hash_table *)
bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
if (ret == (struct elf_link_hash_table *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
{
sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
if (!sdata)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
sec->used_by_bfd = (PTR) sdata;
memset (sdata, 0, sizeof (*sdata));
return true;
sprintf (namebuf, split ? "segment%da" : "segment%d", index);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
strcpy (name, namebuf);
newsect = bfd_make_section (abfd, name);
if (newsect == NULL)
sprintf (namebuf, "segment%db", index);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
strcpy (name, namebuf);
newsect = bfd_make_section (abfd, name);
if (newsect == NULL)
name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name));
if (name == NULL)
{
- bfd_set_error (bfd_error_no_memory);
*failedptr = true;
return;
}
i_shdrp = ((Elf_Internal_Shdr **)
bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *)));
if (i_shdrp == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
i_shdrp[0] = ((Elf_Internal_Shdr *)
bfd_alloc (abfd, sizeof (Elf_Internal_Shdr)));
if (i_shdrp[0] == NULL)
{
bfd_release (abfd, i_shdrp);
- bfd_set_error (bfd_error_no_memory);
return false;
}
memset (i_shdrp[0], 0, sizeof (Elf_Internal_Shdr));
max_index++;
sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
if (sect_syms == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
elf_section_syms (abfd) = sect_syms;
for (idx = 0; idx < symcount; idx++)
bfd_alloc (abfd,
(num_locals + num_globals) * sizeof (asymbol *)));
if (new_syms == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (idx = 0; idx < symcount; idx++)
{
(sizeof (struct elf_segment_map)
+ (to - from - 1) * sizeof (asection *))));
if (m == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
m->next = NULL;
m->p_type = PT_LOAD;
for (i = from, hdrpp = sections + from; i < to; i++, hdrpp++)
m = ((struct elf_segment_map *)
bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
if (m == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
m->next = NULL;
m->p_type = PT_PHDR;
/* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
m = ((struct elf_segment_map *)
bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
if (m == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
m->next = NULL;
m->p_type = PT_INTERP;
m->count = 1;
m = ((struct elf_segment_map *)
bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
if (m == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
m->next = NULL;
m->p_type = PT_DYNAMIC;
m->count = 1;
phdrs = ((Elf_Internal_Phdr *)
bfd_alloc (abfd, alloc * sizeof (Elf_Internal_Phdr)));
if (phdrs == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
off = bed->s->sizeof_ehdr;
off += alloc * bed->s->sizeof_phdr;
(sizeof (struct elf_segment_map)
+ (csecs - 1) * sizeof (asection *))));
if (m == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
m->next = NULL;
m->p_type = p->p_type;
outbound_syms = bfd_alloc (abfd,
(1 + symcount) * bed->s->sizeof_sym);
if (outbound_syms == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
symtab_hdr->contents = (PTR) outbound_syms;
/* now generate the data (for "contents") */
newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
if (!newsym)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
else
{
newsym->symbol.the_bfd = abfd;
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "obstack.h"
-#include "libelf.h"
+#include "elf-bfd.h"
/* The internal type of a symbol table extension entry. */
typedef unsigned long symext_entryS;
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
static boolean elf32_hppa_backend_symbol_table_processing
- PARAMS ((bfd *, elf_symbol_type *, int));
+ PARAMS ((bfd *, elf_symbol_type *, unsigned int));
static void elf32_hppa_backend_begin_write_processing
PARAMS ((bfd *, struct bfd_link_info *));
bfd_hash_allocate (table,
sizeof (struct elf32_hppa_stub_hash_entry)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* Call the allocation method of the superclass. */
ret = ((struct elf32_hppa_stub_hash_entry *)
bfd_hash_allocate (table,
sizeof (struct elf32_hppa_args_hash_entry)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* Call the allocation method of the superclass. */
ret = ((struct elf32_hppa_args_hash_entry *)
ret = ((struct elf32_hppa_link_hash_table *)
bfd_alloc (abfd, sizeof (struct elf32_hppa_link_hash_table)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
_bfd_elf_link_hash_newfunc))
{
{
int r_type;
reloc_howto_type *howto;
- long r_symndx;
+ unsigned long r_symndx;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
asection *sym_sec;
relocation with modifications based on format and field. */
elf32_hppa_reloc_type **
-hppa_elf_gen_reloc_type (abfd, base_type, format, field)
+hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore)
bfd *abfd;
elf32_hppa_reloc_type base_type;
int format;
int field;
+ int ignore;
{
elf32_hppa_reloc_type *finaltype;
elf32_hppa_reloc_type **final_types;
/* Allocate memory and initialize this entry. */
symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
if (!symextP)
- {
- bfd_set_error (bfd_error_no_memory);
- abort(); /* FIXME */
- }
+ abort(); /* FIXME */
symextP[0].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_SYMNDX, sym_idx);
symextP[0].next = &symextP[1];
symextn_contents = (bfd_byte *) bfd_zalloc (abfd,
symextn_sec->_raw_size);
if (!symextn_contents)
- {
- bfd_set_error (bfd_error_no_memory);
- abort(); /* FIXME */
- }
+ abort(); /* FIXME */
/* Fill in the contents of the symbol extension chain. */
for (i = 0, symextP = symext_root; symextP; symextP = symextP->next, ++i)
elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
bfd *abfd;
elf_symbol_type *esyms;
- int symcnt;
+ unsigned int symcnt;
{
Elf32_Internal_Shdr *symextn_hdr =
bfd_elf_find_section (abfd, SYMEXTN_SECTION_NAME);
/* Allocate a buffer of the appropriate size for the symextn section. */
symextn_hdr->contents = bfd_zalloc(abfd,symextn_hdr->sh_size);
if (!symextn_hdr->contents)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Read in the symextn section. */
if (bfd_seek (abfd, symextn_hdr->sh_offset, SEEK_SET) == -1)
return true;
}
- contents = (bfd_byte *) malloc (symextn_sec->_raw_size);
+ contents = (bfd_byte *) malloc ((size_t) symextn_sec->_raw_size);
if (contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
size = bfd_section_size (stub_bfd, stub_sec);
stub_sec->contents = (unsigned char *) bfd_zalloc (stub_bfd, size);
if (stub_sec->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
table = elf32_hppa_hash_table(info)->stub_hash_table;
table->location = stub_sec->contents;
irelaend = irela + section->reloc_count;
for (; irela < irelaend; irela++)
{
- long r_type, callee_args, caller_args, r_index, size_of_stub;
+ long r_type, callee_args, caller_args, size_of_stub;
+ unsigned long r_index;
struct elf_link_hash_entry *hash;
struct elf32_hppa_stub_hash_entry *stub_hash;
struct elf32_hppa_args_hash_entry *args_hash;
stub_name, true, true);
if (stub_hash == NULL)
{
- bfd_set_error (bfd_error_no_memory);
free (stub_name);
free (internal_relocs);
for (i = 0; i < bfd_count; i++)
bfd_alloc (abfd, sizeof (struct mips_elf_find_line)));
if (fi == NULL)
{
- bfd_set_error (bfd_error_no_memory);
msec->flags = origflags;
return false;
}
sizeof (struct fdr))));
if (fi->d.fdr == NULL)
{
- bfd_set_error (bfd_error_no_memory);
msec->flags = origflags;
return false;
}
bfd_hash_allocate (table,
sizeof (struct mips_elf_link_hash_entry)));
if (ret == (struct mips_elf_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct mips_elf_link_hash_entry *)
ret = ((struct mips_elf_link_hash_table *)
bfd_alloc (abfd, sizeof (struct mips_elf_link_hash_table)));
if (ret == (struct mips_elf_link_hash_table *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
mips_elf_link_hash_newfunc))
gptab_bss_sec = o;
else
{
+ (*_bfd_error_handler)
+ ("%s: illegal section name `%s'",
+ bfd_get_filename (abfd), o->name);
bfd_set_error (bfd_error_nonrepresentable_section);
return false;
}
bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
if (ext_tab == NULL)
{
- bfd_set_error (bfd_error_no_memory);
free (tab);
return false;
}
size = symtab_hdr->sh_info * sizeof (bfd_vma);
local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
if (local_got_offsets == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
elf_local_got_offsets (abfd) = local_got_offsets;
for (i = 0; i < symtab_hdr->sh_info; i++)
local_got_offsets[i] = (bfd_vma) -1;
/* Allocate memory for the section contents. */
s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
if (s->contents == NULL && s->_raw_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
if (elf_hash_table (info)->dynamic_sections_created)
new_tdata = ((struct elf_obj_tdata *)
bfd_zalloc (abfd, sizeof (struct elf_obj_tdata)));
if (new_tdata == NULL)
- goto got_no_memory_error;
+ goto got_no_match;
elf_tdata (abfd) = new_tdata;
/* Now that we know the byte order, swap in the rest of the header */
bfd_alloc (abfd,
sizeof (i_shdrp) * i_ehdrp->e_shnum));
if (!i_shdrp || !elf_elfsections (abfd))
- goto got_no_memory_error;
+ goto got_no_match;
if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) != 0)
goto got_no_match;
for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
goto got_no_match;
}
+ /* Read in the program headers. */
+ if (i_ehdrp->e_phnum == 0)
+ elf_tdata (abfd)->phdr = NULL;
+ else
+ {
+ Elf_Internal_Phdr *i_phdr;
+ unsigned int i;
+
+ elf_tdata (abfd)->phdr = ((Elf_Internal_Phdr *)
+ bfd_alloc (abfd,
+ (i_ehdrp->e_phnum
+ * sizeof (Elf_Internal_Phdr))));
+ if (elf_tdata (abfd)->phdr == NULL)
+ goto got_no_match;
+ if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
+ goto got_no_match;
+ i_phdr = elf_tdata (abfd)->phdr;
+ for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
+ {
+ Elf_External_Phdr x_phdr;
+
+ if (bfd_read ((PTR) &x_phdr, sizeof x_phdr, 1, abfd)
+ != sizeof x_phdr)
+ goto got_no_match;
+ elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
+ }
+ }
+
/* Read in the string table containing the names of the sections. We
will need the base pointer to this table later. */
/* We read this inline now, so that we don't have to go through
got_wrong_format_error:
bfd_set_error (bfd_error_wrong_format);
goto got_no_match;
-got_no_memory_error:
- bfd_set_error (bfd_error_no_memory);
- goto got_no_match;
got_no_match:
if (new_tdata != NULL
&& new_tdata->elf_sect_ptr != NULL)
rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
if (rela_hdr->contents == NULL)
{
- bfd_set_error (bfd_error_no_memory);
*failedp = true;
return;
}
x_shdrp = (Elf_External_Shdr *)
bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
if (!x_shdrp)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (count = 0; count < i_ehdrp->e_shnum; count++)
{
symbase = ((elf_symbol_type *)
bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
if (symbase == (elf_symbol_type *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
sym = symbase;
/* Temporarily allocate room for the raw ELF symbols. */
relents = ((arelent *)
bfd_alloc (abfd, asect->reloc_count * sizeof (arelent)));
if (relents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
entsize = d->rel_hdr.sh_entsize;
BFD_ASSERT (entsize == sizeof (Elf_External_Rel)
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Core file support */
-#ifdef HAVE_PROCFS /* Some core file support requires host /proc files */
+#ifdef HAVE_SYS_PROCFS_H /* Some core file support requires host /proc files */
#include <sys/procfs.h>
#else
#define bfd_prstatus(abfd, descdata, descsz, filepos) true
#define bfd_prpsinfo(abfd, descdata, descsz, filepos) true
#endif
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
static boolean
bfd_prstatus (abfd, descdata, descsz, filepos)
if (descsz == sizeof (prpsinfo_t))
{
if ((core_prpsinfo (abfd) = bfd_alloc (abfd, descsz)) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memcpy (core_prpsinfo (abfd), descdata, descsz);
}
return true;
return true;
}
-#endif /* HAVE_PROCFS */
+#endif /* HAVE_SYS_PROCFS_H */
/* Return a pointer to the args (including the command name) that were
seen by the program that generated the core dump. Note that for
elf_core_file_failing_command (abfd)
bfd *abfd;
{
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
if (core_prpsinfo (abfd))
{
prpsinfo_t *p = core_prpsinfo (abfd);
elf_core_file_failing_signal (abfd)
bfd *abfd;
{
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
if (core_prstatus (abfd))
{
return ((prstatus_t *) (core_prstatus (abfd)))->pr_cursig;
bfd *core_bfd;
bfd *exec_bfd;
{
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
char *corename;
char *execname;
#endif
return false;
}
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
/* If no prpsinfo, just return true. Otherwise, grab the last component
of the exec'd pathname from the prpsinfo. */
return true;
-#endif /* HAVE_PROCFS */
+#endif /* HAVE_SYS_PROCFS_H */
}
/* ELF core files contain a segment of type PT_NOTE, that holds much of
the bfd client will have to interpret the structures itself. Even with
/proc support, it might want these full structures for it's own reasons.
- In the second level of support, where HAVE_PROCFS is defined, bfd will
- pick apart the structures to gather some additional information that
- clients may want, such as the general register set, the name of the
- exec'ed file and its arguments, the signal (if any) that caused the
- core dump, etc.
+ In the second level of support, where HAVE_SYS_PROCFS_H is defined,
+ bfd will pick apart the structures to gather some additional
+ information that clients may want, such as the general register
+ set, the name of the exec'ed file and its arguments, the signal (if
+ any) that caused the core dump, etc.
*/
asection *newsect;
if (hdr->p_filesz > 0
- && (buf = (char *) malloc (hdr->p_filesz)) != NULL
+ && (buf = (char *) malloc ((size_t) hdr->p_filesz)) != NULL
&& bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
&& bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
{
elf_tdata (abfd) =
(struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
if (elf_tdata (abfd) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* FIXME, `wrong' returns from this point onward, leak memory. */
i_phdrp = (Elf_Internal_Phdr *)
bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
if (!i_phdrp)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
return NULL;
for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
sz = bfd_section_size (abfd, s);
msg = (char *) bfd_alloc (abfd, sz);
if (msg == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
goto error_return;
bfd_alloc (abfd,
extsymcount * sizeof (struct elf_link_hash_entry *)));
if (sym_hash == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
elf_sym_hashes (abfd) = sym_hash;
if (elf_elfheader (abfd)->e_type != ET_DYN)
s->_raw_size = dynsymcount * sizeof (Elf_External_Sym);
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL && s->_raw_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* The first entry in .dynsym is a dummy symbol. */
isym.st_value = 0;
s->_raw_size = (2 + bucketcount + dynsymcount) * (ARCH_SIZE / 8);
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memset (s->contents, 0, (size_t) s->_raw_size);
put_word (output_bfd, bucketcount, s->contents);
so we allocate it with bfd_alloc rather than malloc. */
rel_hdr->contents = (PTR) bfd_alloc (abfd, rel_hdr->sh_size);
if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
p = ((struct elf_link_hash_entry **)
malloc (o->reloc_count
size = bfd_get_reloc_size (howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
rstat = _bfd_relocate_contents (howto, output_bfd,
link_order->u.reloc.p->addend, buf);
switch (rstat)
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
. {* Allocate the structure if it has not already been allocated by a
. derived class. *}
. if (ret == (@var{entry_type} *) NULL)
-. ret = ((@var{entry_type} *)
-. bfd_hash_allocate (table, sizeof (@var{entry_type})));
+. {
+. ret = ((@var{entry_type} *)
+. bfd_hash_allocate (table, sizeof (@var{entry_type})));
+. if (ret == (@var{entry_type} *) NULL)
+. return NULL;
+. }
.
. {* Call the allocation method of the base class. *}
. ret = ((@var{entry_type} *)
alloc = size * sizeof (struct bfd_hash_entry *);
if (!obstack_begin (&table->memory, alloc))
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
table->table = ((struct bfd_hash_entry **)
obstack_alloc (&table->memory, alloc));
if (!table->table)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
memset ((PTR) table->table, 0, alloc);
new = (char *) obstack_alloc (&table->memory, len + 1);
if (!new)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (struct bfd_hash_entry *) NULL;
}
strcpy (new, string);
return hashp;
}
+/* Replace an entry in a hash table. */
+
+void
+bfd_hash_replace (table, old, nw)
+ struct bfd_hash_table *table;
+ struct bfd_hash_entry *old;
+ struct bfd_hash_entry *nw;
+{
+ unsigned int index;
+ struct bfd_hash_entry **pph;
+
+ index = old->hash % table->size;
+ for (pph = &table->table[index];
+ (*pph) != (struct bfd_hash_entry *) NULL;
+ pph = &(*pph)->next)
+ {
+ if (*pph == old)
+ {
+ *pph = nw;
+ return;
+ }
+ }
+
+ abort ();
+}
+
/* Base method for creating a new hash table entry. */
/*ARGSUSED*/
struct bfd_hash_table *table;
unsigned int size;
{
- return obstack_alloc (&table->memory, size);
+ PTR ret;
+
+ ret = obstack_alloc (&table->memory, size);
+ if (ret == NULL && size != 0)
+ bfd_set_error (bfd_error_no_memory);
+ return ret;
}
/* Traverse a hash table. */
}
}
}
+\f
+/* A few different object file formats (a.out, COFF, ELF) use a string
+ table. These functions support adding strings to a string table,
+ returning the byte offset, and writing out the table.
+
+ Possible improvements:
+ + look for strings matching trailing substrings of other strings
+ + better data structures? balanced trees?
+ + look at reducing memory use elsewhere -- maybe if we didn't have
+ to construct the entire symbol table at once, we could get by
+ with smaller amounts of VM? (What effect does that have on the
+ string table reductions?) */
+
+/* An entry in the strtab hash table. */
+
+struct strtab_hash_entry
+{
+ struct bfd_hash_entry root;
+ /* Index in string table. */
+ bfd_size_type index;
+ /* Next string in strtab. */
+ struct strtab_hash_entry *next;
+};
+
+/* The strtab hash table. */
+
+struct bfd_strtab_hash
+{
+ struct bfd_hash_table table;
+ /* Size of strtab--also next available index. */
+ bfd_size_type size;
+ /* First string in strtab. */
+ struct strtab_hash_entry *first;
+ /* Last string in strtab. */
+ struct strtab_hash_entry *last;
+ /* Whether to precede strings with a two byte length, as in the
+ XCOFF .debug section. */
+ boolean xcoff;
+};
+
+static struct bfd_hash_entry *strtab_hash_newfunc
+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+/* Routine to create an entry in a strtab. */
+
+static struct bfd_hash_entry *
+strtab_hash_newfunc (entry, table, string)
+ struct bfd_hash_entry *entry;
+ struct bfd_hash_table *table;
+ const char *string;
+{
+ struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a
+ subclass. */
+ if (ret == (struct strtab_hash_entry *) NULL)
+ ret = ((struct strtab_hash_entry *)
+ bfd_hash_allocate (table, sizeof (struct strtab_hash_entry)));
+ if (ret == (struct strtab_hash_entry *) NULL)
+ return NULL;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct strtab_hash_entry *)
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret)
+ {
+ /* Initialize the local fields. */
+ ret->index = (bfd_size_type) -1;
+ ret->next = NULL;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Look up an entry in an strtab. */
+
+#define strtab_hash_lookup(t, string, create, copy) \
+ ((struct strtab_hash_entry *) \
+ bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
+
+/* Create a new strtab. */
+
+struct bfd_strtab_hash *
+_bfd_stringtab_init ()
+{
+ struct bfd_strtab_hash *table;
+
+ table = (struct bfd_strtab_hash *) malloc (sizeof (struct bfd_strtab_hash));
+ if (table == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
+ if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc))
+ {
+ free (table);
+ return NULL;
+ }
+
+ table->size = 0;
+ table->first = NULL;
+ table->last = NULL;
+ table->xcoff = false;
+
+ return table;
+}
+
+/* Create a new strtab in which the strings are output in the format
+ used in the XCOFF .debug section: a two byte length precedes each
+ string. */
+
+struct bfd_strtab_hash *
+_bfd_xcoff_stringtab_init ()
+{
+ struct bfd_strtab_hash *ret;
+
+ ret = _bfd_stringtab_init ();
+ if (ret != NULL)
+ ret->xcoff = true;
+ return ret;
+}
+
+/* Free a strtab. */
+
+void
+_bfd_stringtab_free (table)
+ struct bfd_strtab_hash *table;
+{
+ bfd_hash_table_free (&table->table);
+ free (table);
+}
+
+/* Get the index of a string in a strtab, adding it if it is not
+ already present. If HASH is false, we don't really use the hash
+ table, and we don't eliminate duplicate strings. */
+
+bfd_size_type
+_bfd_stringtab_add (tab, str, hash, copy)
+ struct bfd_strtab_hash *tab;
+ const char *str;
+ boolean hash;
+ boolean copy;
+{
+ register struct strtab_hash_entry *entry;
+
+ if (hash)
+ {
+ entry = strtab_hash_lookup (tab, str, true, copy);
+ if (entry == NULL)
+ return (bfd_size_type) -1;
+ }
+ else
+ {
+ entry = ((struct strtab_hash_entry *)
+ bfd_hash_allocate (&tab->table,
+ sizeof (struct strtab_hash_entry)));
+ if (entry == NULL)
+ return (bfd_size_type) -1;
+ if (! copy)
+ entry->root.string = str;
+ else
+ {
+ char *n;
+
+ n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
+ if (n == NULL)
+ return (bfd_size_type) -1;
+ entry->root.string = n;
+ }
+ entry->index = (bfd_size_type) -1;
+ entry->next = NULL;
+ }
+
+ if (entry->index == (bfd_size_type) -1)
+ {
+ entry->index = tab->size;
+ tab->size += strlen (str) + 1;
+ if (tab->xcoff)
+ {
+ entry->index += 2;
+ tab->size += 2;
+ }
+ if (tab->first == NULL)
+ tab->first = entry;
+ else
+ tab->last->next = entry;
+ tab->last = entry;
+ }
+
+ return entry->index;
+}
+
+/* Get the number of bytes in a strtab. */
+
+bfd_size_type
+_bfd_stringtab_size (tab)
+ struct bfd_strtab_hash *tab;
+{
+ return tab->size;
+}
+
+/* Write out a strtab. ABFD must already be at the right location in
+ the file. */
+
+boolean
+_bfd_stringtab_emit (abfd, tab)
+ register bfd *abfd;
+ struct bfd_strtab_hash *tab;
+{
+ register boolean xcoff;
+ register struct strtab_hash_entry *entry;
+
+ xcoff = tab->xcoff;
+
+ for (entry = tab->first; entry != NULL; entry = entry->next)
+ {
+ register const char *str;
+ register size_t len;
+
+ str = entry->root.string;
+ len = strlen (str) + 1;
+
+ if (xcoff)
+ {
+ bfd_byte buf[2];
+
+ /* The output length includes the null byte. */
+ bfd_put_16 (abfd, len, buf);
+ if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
+ return false;
+ }
+
+ if (bfd_write ((PTR) str, 1, len, abfd) != len)
+ return false;
+ }
+
+ return true;
+}
/* BFD back-end for HPPA BSD core files.
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
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.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Written by the Center for Software Science at the University of Utah
and by Cygnus Support.
/* This file can only be compiled on systems which use HPPA-BSD style
- core files. In the config/XXXXXX.mh file for such a system add
- HDEFINES=-DHPPABSD_CORE
- HDEPFILES=hppabsd-core.o
+ core files.
I would not expect this to be of use to any other host/target, but
you never know. */
static asection *make_bfd_asection PARAMS ((bfd *, CONST char *,
flagword, bfd_size_type,
- bfd_vma, unsigned int));
+ file_ptr, unsigned int));
static asymbol *hppabsd_core_make_empty_symbol PARAMS ((bfd *));
-static bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
+static const bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
static char *hppabsd_core_core_file_failing_command PARAMS ((bfd *));
static int hppabsd_core_core_file_failing_signal PARAMS ((bfd *));
static boolean hppabsd_core_core_file_matches_executable_p
#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
+make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power)
bfd *abfd;
CONST char *name;
flagword flags;
bfd_size_type _raw_size;
- bfd_vma vma;
+ file_ptr offset;
unsigned int alignment_power;
{
asection *asect;
asect->flags = flags;
asect->_raw_size = _raw_size;
- asect->vma = vma;
- asect->filepos = bfd_tell (abfd);
+ asect->filepos = offset;
asect->alignment_power = alignment_power;
return asect;
return new;
}
-static bfd_target *
+static const bfd_target *
hppabsd_core_core_file_p (abfd)
bfd *abfd;
{
for PA 1.0 machines and PA 1.1 machines. Yuk! */
clicksz = u.u_pcb.pcb_pgsz;
+ /* clicksz must be a power of two >= 2k. */
+ if (clicksz < 0x800
+ || clicksz != (clicksz & -clicksz))
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+
/* Sanity checks. Make sure the size of the core file matches the
the size computed from information within the core itself. */
{
coredata = (struct hppabsd_core_struct *)
bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
if (!coredata)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* Make the core data and available via the tdata part of the BFD. */
abfd->tdata.hppabsd_core_data = coredata;
core_datasec (abfd)->vma = UDATASEG;
core_regsec (abfd) = make_bfd_asection (abfd, ".reg",
- SEC_ALLOC + SEC_HAS_CONTENTS,
+ SEC_HAS_CONTENTS,
KSTAKSIZE * NBPG,
NBPG * USIZE, 2);
core_regsec (abfd)->vma = 0;
#define hppabsd_core_get_lineno _bfd_nosymbols_get_lineno
#define hppabsd_core_find_nearest_line _bfd_nosymbols_find_nearest_line
#define hppabsd_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define hppabsd_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define hppabsd_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
/* If somebody calls any byte-swapping routines, shoot them. */
static void
#define NO_SIGNED_GET \
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-bfd_target hppabsd_core_vec =
+const bfd_target hppabsd_core_vec =
{
"hppabsd-core",
bfd_target_unknown_flavour,
true, /* target headers byte order */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
0, /* symbol prefix */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment power */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (_bfd_generic),
BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
(PTR) 0 /* backend_data */
};
#define MY(OP) CAT(i386linux_,OP)
#define TARGETNAME "a.out-i386-linux"
+extern const bfd_target MY(vec);
+
/* We always generate QMAGIC files in preference to ZMAGIC files. It
would be possible to make this a linker option, if that ever
becomes important. */
ret = ((struct linux_link_hash_table *)
bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
if (ret == (struct linux_link_hash_table *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_link_hash_table *) NULL;
- }
+ return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
linux_link_hash_newfunc))
{
s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memset (s->contents, 0, (size_t) s->_raw_size);
}
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define BYTES_IN_WORD 4
-#define ARCH 32
#define N_SHARED_LIB(x) 0
#define TEXT_START_ADDR 0
-#define PAGE_SIZE 4096
-#define SEGMENT_SIZE PAGE_SIZE
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
#define DEFAULT_ARCH bfd_arch_i386
#define MY(OP) CAT(i386lynx_aout_,OP)
#include "libaout.h"
#include "aout/aout64.h"
-#ifdef HOST_LYNX
+#ifdef LYNX_CORE
char *lynx_core_file_failing_command ();
int lynx_core_file_failing_signal ();
#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
#define MY_core_file_p lynx_core_file_p
-#endif /* HOST_LYNX */
+#endif /* LYNX_CORE */
\f
#define KEEPIT flags
if (bfd_is_com_section (output_section)
- || output_section == &bfd_abs_section
- || output_section == &bfd_und_section)
+ || bfd_is_abs_section (output_section)
+ || bfd_is_und_section (output_section))
{
- if (bfd_abs_section.symbol == sym)
+ if (bfd_abs_section_ptr->symbol == sym)
{
/* Whoops, looked like an abs symbol, but is really an offset
from the abs section */
*/
if (bfd_is_com_section (output_section)
- || output_section == &bfd_abs_section
- || output_section == &bfd_und_section)
+ || bfd_is_abs_section (output_section)
+ || bfd_is_und_section (output_section))
{
- if (bfd_abs_section.symbol == sym)
+ if (bfd_abs_section_ptr->symbol == sym)
{
/* Whoops, looked like an abs symbol, but is really an offset
from the abs section */
default: \
case N_ABS: \
case N_ABS | N_EXT: \
- cache_ptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr; \
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; \
cache_ptr->addend = ad; \
break; \
} \
} \
void
-NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
+NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
bfd *abfd;
struct reloc_ext_external *bytes;
arelent *cache_ptr;
asymbol **symbols;
+ bfd_size_type symcount;
{
int r_index;
int r_extern;
}
void
-NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
bfd *abfd;
struct reloc_std_external *bytes;
arelent *cache_ptr;
asymbol **symbols;
+ bfd_size_type symcount;
{
int r_index;
int r_extern;
reloc_cache = (arelent *) malloc (count * sizeof (arelent));
if (!reloc_cache && count != 0)
{
- nomem:
bfd_set_error (bfd_error_no_memory);
return false;
}
if (!relocs && reloc_size != 0)
{
free (reloc_cache);
- goto nomem;
+ return false;
}
if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
for (; counter < count; counter++, rptr++, cache_ptr++)
{
- NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols);
+ NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
}
}
else
for (; counter < count; counter++, rptr++, cache_ptr++)
{
- NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols);
+ NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
+ bfd_get_symcount (abfd));
}
}
natsize = each_size * count;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
generic = section->orelocation;
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "libaout.h" /* BFD a.out internal data structures */
#include "os9k.h"
-static bfd_target *os9k_callback PARAMS ((bfd *));
+static const bfd_target *os9k_callback PARAMS ((bfd *));
/* Swaps the information in an executable header taken from a raw byte
stream memory image, into the internal exec_header structure. */
#endif /* 0 */
-static bfd_target *
+static const bfd_target *
os9k_object_p (abfd)
bfd *abfd;
{
/* Finish up the opening of a b.out file for reading. Fill in all the
fields that are not handled by common code. */
-static bfd_target *
+static const bfd_target *
os9k_callback (abfd)
bfd *abfd;
{
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
if (rawptr == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
abfd->tdata.bout_data = rawptr;
exec_hdr (abfd) = &rawptr->e;
- /* For simplicity's sake we just make all the sections right here. */
obj_textsec (abfd) = (asection *) NULL;
obj_datasec (abfd) = (asection *) NULL;
obj_bsssec (abfd) = (asection *) NULL;
- bfd_make_section (abfd, ".text");
- bfd_make_section (abfd, ".data");
- bfd_make_section (abfd, ".bss");
-
return true;
}
{
struct external_exec swapped_hdr;
+ if (! aout_32_make_sections (abfd))
+ return false;
+
exec_hdr (abfd)->a_info = BMAGIC;
exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
if (abfd->output_has_begun == false)
{ /* set by bfd.c handler */
- if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*||
- (obj_textsec (abfd)->_cooked_size == 0) || (obj_datasec (abfd)->_cooked_size == 0)*/ )
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
+ if (! aout_32_make_sections (abfd))
+ return false;
obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
obj_datasec (abfd)->filepos = obj_textsec (abfd)->filepos
#define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+#define aout_32_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
#define os9k_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define os9k_bfd_relax_section bfd_generic_relax_section
#define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define os9k_bfd_final_link _bfd_generic_final_link
+#define os9k_bfd_link_split_section _bfd_generic_link_split_section
-bfd_target i386os9k_vec =
+const bfd_target i386os9k_vec =
{
"i386os9k", /* name */
bfd_target_os9k_flavour,
0, /* symbol leading char */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 2, /* minumum alignment power */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
/* Buy memory and read string */
string = bfd_alloc (ieee->abfd, length + 1);
if (!string)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
bfd_get_string (ieee, string, length);
string[length] = 0;
return string;
ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
sizeof (ieee_symbol_type));
if (!new_symbol)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
new_symbol->index = new_index;
last_index = new_index;
asection *section;
if (!tmp)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
sprintf (tmp, " fsec%4d", index);
section = bfd_make_section (abfd, tmp);
ieee->section_table[index] = section;
ieee_ar_data_type *ieee;
abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
if (!abfd->tdata.ieee_ar_data)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
ieee = IEEE_AR_DATA (abfd);
/* FIXME: Check return value. I'm not sure whether it needs to read
/* Determine the architecture and machine type of the object file.
*/
{
- bfd_arch_info_type *arch = bfd_scan_arch (processor);
+ const bfd_arch_info_type *arch = bfd_scan_arch (processor);
if (arch == 0)
goto got_wrong_format;
abfd->arch_info = arch;
IEEE_DATA (abfd)->h.first_byte = (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record
+ 50);
if (!IEEE_DATA (abfd)->h.first_byte)
- {
- bfd_set_error (bfd_error_no_memory);
- goto fail;
- }
+ goto fail;
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
goto fail;
/* FIXME: Check return value. I'm not sure whether it needs to read
(ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
sizeof (ieee_reloc_type));
if (!r)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
*(current_map->reloc_tail_ptr) = r;
current_map->reloc_tail_ptr = &r->next;
ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
if (!per->data)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/*SUPPRESS 68*/
per->reloc_tail_ptr =
(ieee_reloc_type **) & (s->relocation);
newsect->used_by_bfd = (PTR)
bfd_alloc (abfd, sizeof (ieee_per_section_type));
if (!newsect->used_by_bfd)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
ieee_per_section (newsect)->data = (bfd_byte *) NULL;
ieee_per_section (newsect)->section = newsect;
return true;
/* Outputting a section without data, fill it up */
stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
if (!stream)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memset ((PTR) stream, 0, (size_t) s->_raw_size);
}
while (current_byte_index < s->_raw_size)
{
ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
if (!ieee_per_section (s)->data)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
}
return true;
{
bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
if (!n)
- {
- bfd_set_error (bfd_error_no_memory);
- abort (); /* FIXME */
- }
+ abort (); /* FIXME */
n->this = section->owner;
n->next = (bfd_chain_type *) NULL;
((boolean (*) \
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
bfd_true)
+#define ieee_read_ar_hdr bfd_nullvoidptr
#define ieee_update_armap_timestamp bfd_true
#define ieee_bfd_is_local_label bfd_generic_is_local_label
#define ieee_set_arch_mach _bfd_generic_set_arch_mach
+#define ieee_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
#define ieee_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define ieee_bfd_relax_section bfd_generic_relax_section
{
char *ptr = (char *) malloc ((size_t) size);
- if (ptr && size)
- memset(ptr, 0, (size_t) size);
+ if (size != 0)
+ {
+ if (ptr == NULL)
+ bfd_set_error (bfd_error_no_memory);
+ else
+ memset (ptr, 0, (size_t) size);
+ }
return ptr;
}
#undef HAVE_MPROTECT /* code's not tested yet */
-#if HAVE_MMAP || HAVE_MPROTECT
+#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
#include <sys/types.h>
#include <sys/mman.h>
#endif
static int debug_windows;
+/* Currently, if USE_MMAP is undefined, none if the window stuff is
+ used. Okay, so it's mis-named. At least the command-line option
+ "--without-mmap" is more obvious than "--without-windows" or some
+ such. */
+#ifdef USE_MMAP
+
void
bfd_free_window (windowp)
bfd_window *windowp;
/* There should be no more references to i at this point. */
free (i);
}
+#endif
static int ok_to_map = 1;
bfd_window_internal *i = windowp->i;
size_t size_to_alloc = size;
+#ifndef USE_MMAP
+ abort ();
+#endif
+
if (debug_windows)
fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
abfd, (long) offset, (long) size,
fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
(long) real_size, i->data, (long) offset2);
i->size = real_size;
- windowp->data = i->data + offset2;
+ windowp->data = (PTR) ((bfd_byte *) i->data + offset2);
windowp->size = size;
i->mapped = 1;
return true;
file_ptr offset;
bfd_size_type count;
{
+#ifdef USE_MMAP
if (count == 0)
return true;
if (abfd->xvec->_bfd_get_section_contents != _bfd_generic_get_section_contents)
== false))
return false;
return true;
+#else
+ abort ();
+#endif
}
/* This generic function can only be used in implementations where creating
ret = ((struct generic_link_hash_table *)
bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));
if (ret == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_link_hash_table *) NULL;
- }
+ return (struct bfd_link_hash_table *) NULL;
if (! _bfd_link_hash_table_init (&ret->root, abfd,
generic_link_hash_newfunc))
{
return false;
abfd->outsymbols = (asymbol **) bfd_alloc (abfd, symsize);
if (abfd->outsymbols == NULL && symsize != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
symcount = bfd_canonicalize_symtab (abfd, abfd->outsymbols);
if (symcount < 0)
return false;
struct generic_link_hash_entry *h;
name = bfd_asymbol_name (p);
- if ((p->flags & BSF_INDIRECT) != 0
- || bfd_is_ind_section (p->section))
- string = bfd_asymbol_name ((asymbol *) p->value);
- else if ((p->flags & BSF_WARNING) != 0)
+ if (((p->flags & BSF_INDIRECT) != 0
+ || bfd_is_ind_section (p->section))
+ && pp + 1 < ppend)
+ {
+ pp++;
+ string = bfd_asymbol_name (*pp);
+ }
+ else if ((p->flags & BSF_WARNING) != 0
+ && pp + 1 < ppend)
{
/* The name of P is actually the warning string, and the
- value is actually a pointer to the symbol to warn
- about. */
+ next symbol is the one to warn about. */
string = name;
- name = bfd_asymbol_name ((asymbol *) p->value);
+ pp++;
+ name = bfd_asymbol_name (*pp);
}
else
string = NULL;
case DEF:
case DEFW:
{
- enum bfd_link_order_type oldtype;
+ enum bfd_link_hash_type oldtype;
/* Define a symbol. */
oldtype = h->type;
(o->reloc_count
* sizeof (arelent *))));
if (!o->orelocation)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
o->flags |= SEC_RELOC;
/* Reset the count so that it can be used as an index
when putting in the output relocs. */
r = (arelent *) bfd_alloc (abfd, sizeof (arelent));
if (r == (arelent *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
r->address = link_order->offset;
r->howto = bfd_reloc_type_lookup (abfd, link_order->u.reloc.p->reloc);
size = bfd_get_reloc_size (r->howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
rstat = _bfd_relocate_contents (r->howto, abfd,
link_order->u.reloc.p->addend, buf);
switch (rstat)
new = ((struct bfd_link_order *)
bfd_alloc_by_size_t (abfd, sizeof (struct bfd_link_order)));
if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
new->type = bfd_undefined_link_order;
new->offset = 0;
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This file describes the 32 bit Alpha NLM format. You might think
that an Alpha chip would use a 64 bit format, but, for some reason,
|| r_type == ALPHA_R_GPDISP
|| r_type == ALPHA_R_IGNORE)
{
- rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
rel->addend = 0;
}
else if (r_symndx == ALPHA_RELOC_SECTION_TEXT)
else
{
BFD_ASSERT (0);
- rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
rel->addend = 0;
}
}
addend, but they do use a special code. Put this code in the
addend field. */
rel->addend = r_symndx;
- rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
break;
case ALPHA_R_OP_STORE:
some reason the address of this reloc type is not adjusted by
the section vma. We record the gp value for this object file
here, for convenience when doing the GPDISP relocation. */
- rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
rel->address = r_vaddr;
rel->addend = gp_value;
break;
}
else
BFD_ASSERT (0);
- rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
break;
default:
bfd_size_type rcount; /* number of relocs */
bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
unsigned char symlength; /* length of symbol name */
+ char *name;
if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
!= sizeof (symlength))
return false;
sym -> symbol.the_bfd = abfd;
- sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
- if (!sym -> symbol.name)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
- != symlength)
+ name = bfd_alloc (abfd, symlength + 1);
+ if (name == NULL)
+ return false;
+ if (bfd_read (name, symlength, 1, abfd) != symlength)
return false;
+ name[symlength] = '\0';
+ sym -> symbol.name = name;
sym -> symbol.flags = 0;
sym -> symbol.value = 0;
- sym -> symbol.section = &bfd_und_section;
+ sym -> symbol.section = bfd_und_section_ptr;
if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
return false;
rcount = bfd_h_get_32 (abfd, temp);
nlm_relocs = ((struct nlm_relent *)
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
if (!nlm_relocs)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
sym -> relocs = nlm_relocs;
sym -> rcnt = 0;
while (sym -> rcnt < rcount)
r_vaddr += bfd_section_size (abfd,
bfd_get_section_by_name (abfd,
NLM_CODE_NAME));
- if (bfd_get_section (sym) == &bfd_und_section)
+ if (bfd_is_und_section (bfd_get_section (sym)))
{
r_extern = 1;
r_symndx = 0;
/* The first two relocs for each external symbol are the .lita
address and the GP value. */
- r.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ r.sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
r.howto = &nlm32_alpha_nw_howto;
r.address = nlm_alpha_backend_data (abfd)->lita_address;
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. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <string.h> /* For strrchr and friends */
#include "bfd.h"
/* Read in the fixed length portion of the NLM header in external format. */
- x_fxdhdr = (PTR) malloc (nlm_fixed_header_size (abfd));
+ x_fxdhdr = (PTR) malloc ((size_t) nlm_fixed_header_size (abfd));
if (x_fxdhdr == NULL)
{
bfd_set_error (bfd_error_no_memory);
new_tdata = ((struct nlm_obj_tdata *)
bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata)));
if (new_tdata == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto got_no_match;
- }
+ goto got_no_match;
nlm_tdata (abfd) = new_tdata;
if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
nlm_variable_header (abfd)->descriptionLength + 1,
1, abfd) !=
- nlm_variable_header (abfd)->descriptionLength + 1)
+ (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
return (false);
/* Read and convert the stackSize field. */
if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
nlm_variable_header (abfd)->screenNameLength + 1,
1, abfd) !=
- nlm_variable_header (abfd)->screenNameLength + 1)
+ (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
return (false);
/* Read the thread name length and text members. */
if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
nlm_variable_header (abfd)->threadNameLength + 1,
1, abfd) !=
- nlm_variable_header (abfd)->threadNameLength + 1)
+ (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
return (false);
return (true);
}
if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
nlm_variable_header (abfd)->descriptionLength + 1,
1, abfd) !=
- nlm_variable_header (abfd)->descriptionLength + 1)
+ (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
return (false);
/* Convert and write the stackSize field. */
if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
nlm_variable_header (abfd)->screenNameLength + 1,
1, abfd) !=
- nlm_variable_header (abfd)->screenNameLength + 1)
+ (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
return (false);
/* Write the thread name length and text members. */
if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
nlm_variable_header (abfd)->threadNameLength + 1,
1, abfd) !=
- nlm_variable_header (abfd)->threadNameLength + 1)
+ (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
return (false);
return (true);
}
if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
nlm_copyright_header (abfd)->copyrightMessageLength + 1,
1, abfd) !=
- nlm_copyright_header (abfd)->copyrightMessageLength + 1)
+ ((bfd_size_type)
+ nlm_copyright_header (abfd)->copyrightMessageLength + 1))
return (false);
}
else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
hdrLength -= 2 * NLM_TARGET_LONG_SIZE + 8;
hdr = bfd_alloc (abfd, hdrLength);
if (hdr == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read (hdr, 1, hdrLength, abfd) != hdrLength)
return false;
}
return false;
contents = (bfd_byte *) bfd_alloc (abfd, dataLength);
if (contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read (contents, 1, dataLength, abfd) != dataLength)
return false;
if (bfd_seek (abfd, pos, SEEK_SET) != 0)
if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
nlm_copyright_header (abfd)->copyrightMessageLength + 1,
1, abfd) !=
- nlm_copyright_header (abfd)->copyrightMessageLength + 1)
+ ((bfd_size_type)
+ nlm_copyright_header (abfd)->copyrightMessageLength + 1))
return false;
}
sym = ((nlm_symbol_type *)
bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
if (!sym)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
nlm_set_symbols (abfd, sym);
/* We use the bfd's symcount directly as the control count, so that early
sym->symbol.the_bfd = abfd;
sym->symbol.name = bfd_alloc (abfd, symlength + 1);
if (!sym->symbol.name)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
!= symlength)
return (false);
sym->symbol.the_bfd = abfd;
sym->symbol.name = bfd_alloc (abfd, symlength + 1);
if (!sym->symbol.name)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
!= symlength)
return (false);
}
else
{
- sym->symbol.section = &bfd_abs_section;
+ sym->symbol.section = bfd_abs_section_ptr;
}
sym->rcnt = 0;
abfd->symcount++;
rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *));
if ((rels == NULL || secs == NULL) && count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
nlm_relocation_fixups (abfd) = rels;
nlm_relocation_fixup_secs (abfd) = secs;
asection *sec;
bfd_vma text, data, bss;
bfd_vma text_low, data_low;
- int text_align, data_align, other_align;
+ unsigned int text_align, data_align, other_align;
file_ptr text_ptr, data_ptr, other_ptr;
asection *bss_sec;
asymbol **sym_ptr_ptr;
boolean (*write_prefix_func) PARAMS ((bfd *));
unsigned char *fixed_header = NULL;
- fixed_header = (unsigned char *) malloc (nlm_fixed_header_size (abfd));
+ fixed_header = ((unsigned char *)
+ malloc ((size_t) nlm_fixed_header_size (abfd)));
if (fixed_header == NULL)
{
bfd_set_error (bfd_error_no_memory);
rel = *rel_ptr_ptr;
sym = *rel->sym_ptr_ptr;
- if (bfd_get_section (sym) != &bfd_und_section)
+ if (! bfd_is_und_section (bfd_get_section (sym)))
{
++internal_reloc_count;
if ((*write_import_func) (abfd, sec, rel) == false)
(external_reloc_count
* sizeof (struct reloc_and_sec)));
if (external_relocs == (struct reloc_and_sec *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
i = 0;
for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
{
rel = *rel_ptr_ptr;
sym = *rel->sym_ptr_ptr;
- if (bfd_get_section (sym) != &bfd_und_section)
+ if (! bfd_is_und_section (bfd_get_section (sym)))
continue;
external_relocs[i].rel = rel;
sym = *sym_ptr_ptr;
if ((sym->flags & (BSF_EXPORT | BSF_GLOBAL)) == 0
- || bfd_get_section (sym) == &bfd_und_section)
+ || bfd_is_und_section (bfd_get_section (sym)))
continue;
++c;
debugging symbol NLM does not understand at all. */
if ((sym->flags & (BSF_LOCAL | BSF_GLOBAL | BSF_EXPORT)) == 0
|| (sym->flags & BSF_DEBUGGING) != 0
- || bfd_get_section (sym) == &bfd_und_section)
+ || bfd_is_und_section (bfd_get_section (sym)))
continue;
++c;
goto error_return;
}
- BFD_ASSERT (bfd_tell (abfd) == nlm_optional_prefix_size (abfd));
+ BFD_ASSERT ((bfd_size_type) bfd_tell (abfd)
+ == nlm_optional_prefix_size (abfd));
nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)
data->strings = bfd_alloc (abfd, data->symbol_string_length);
#endif
if (!data->symbols || !data->strings)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
dest_defined = data->symbols + abfd->symcount - 1;
oasys_module_table_type record;
if (!ar || !module)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
abfd->tdata.oasys_ar_data = ar;
ar->module = module;
module[i].name = bfd_alloc (abfd, 33);
if (!module[i].name)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
memcpy (module[i].name, record_ext.mod_name, 33);
filepos +=
module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
if (!module[i].name)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
abfd)
!= record.module_name_size)
}
buffer = bfd_alloc (abfd, 3);
if (!buffer)
- {
- bfd_set_error (bfd_error_no_memory);
- goto fail;
- }
+ goto fail;
section_number = record.section.relb & RELOCATION_SECT_BITS;
sprintf (buffer, "%u", section_number);
s = bfd_make_section (abfd, buffer);
{
per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size);
if (!per->data)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
per->reloc_tail_ptr = (oasys_reloc_type **) & (section->relocation);
per->had_vma = false;
per->initialized = true;
bfd_alloc (abfd,
sizeof (oasys_reloc_type));
if (!r)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
*(per->reloc_tail_ptr) = r;
per->reloc_tail_ptr = &r->next;
r->next = (oasys_reloc_type *) NULL;
bfd_alloc (abfd,
sizeof (oasys_reloc_type));
if (!r)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
*(per->reloc_tail_ptr) = r;
per->reloc_tail_ptr = &r->next;
r->next = (oasys_reloc_type *) NULL;
newsect->used_by_bfd = (PTR)
bfd_alloc (abfd, sizeof (oasys_per_section_type));
if (!newsect->used_by_bfd)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
oasys_per_section (newsect)->data = (bfd_byte *) NULL;
oasys_per_section (newsect)->section = newsect;
oasys_per_section (newsect)->offset = 0;
{
if (!isdigit (s->name[0]))
{
+ (*_bfd_error_handler)
+ ("%s: can not represent section `%s' in oasys",
+ bfd_get_filename (abfd), s->name);
bfd_set_error (bfd_error_nonrepresentable_section);
return false;
}
oasys_per_section (section)->data =
(bfd_byte *) (bfd_alloc (abfd, section->_cooked_size));
if (!oasys_per_section (section)->data)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
(void) memcpy ((PTR) (oasys_per_section (section)->data + offset),
location,
oasys_symbol_type *new =
(oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
new->symbol.the_bfd = abfd;
return &new->symbol;
}
"Special Directory",
"Thread Storage Directory [.tls]",
"Load Configuration Directory",
- "Reserved",
- "Reserved [first thunk address on PPC]",
+ "Bound Import Directory",
+ "Import Address Table Directory",
"Reserved",
"Reserved",
"Reserved"
static boolean
pe_print_private_bfd_data (abfd, vfile)
bfd *abfd;
- void *vfile;
+ PTR vfile;
{
- FILE *file = vfile;
+ FILE *file = (FILE *) vfile;
int j;
pe_data_type *pe = pe_data (abfd);
struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
(struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type));
if (abfd->tdata.pe_obj_data == 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
pe = pe_data (abfd);
/* BFD backend for core files which use the ptrace_user structure
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994 Free Software Foundation, Inc.
The structure of this file is based on trad-core.c written by John Gilmore
of Cygnus Support.
Modified to work with the ptrace_user structure by Kevin A. Buettner.
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.
-
- To use this file on a particular host, configure the host with these
- parameters in the config/h-HOST file:
-
- HDEFINES=-DPTRACE_CORE
- HDEPFILES=ptrace-core.o
-
-*/
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef PTRACE_CORE
asection *stack_section;
asection *reg_section;
struct ptrace_user u;
- } *rawptr;
+ };
#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
/* forward declarations */
-bfd_target * ptrace_unix_core_file_p PARAMS ((bfd *abfd));
+const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd));
char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
boolean ptrace_unix_core_file_matches_executable_p
PARAMS ((bfd *core_bfd, bfd *exec_bfd));
/* ARGSUSED */
-bfd_target *
+const bfd_target *
ptrace_unix_core_file_p (abfd)
bfd *abfd;
{
int val;
struct ptrace_user u;
+ struct trad_core_struct *rawptr;
val = bfd_read ((void *)&u, 1, sizeof u, abfd);
if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC
rawptr = (struct trad_core_struct *)
bfd_zalloc (abfd, sizeof (struct trad_core_struct));
- if (rawptr == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (rawptr == NULL)
return 0;
- }
abfd->tdata.trad_core_data = rawptr;
/* Create the sections. This is raunchy, but bfd_close wants to free
them separately. */
- core_stacksec(abfd) = (asection *) bfd_zmalloc (sizeof (asection));
- if (core_stacksec (abfd) == NULL) {
- loser:
- bfd_set_error (bfd_error_no_memory);
- free ((void *)rawptr);
- return 0;
- }
- core_datasec (abfd) = (asection *) zalloc (sizeof (asection));
- if (core_datasec (abfd) == NULL) {
- loser1:
- free ((void *)core_stacksec (abfd));
- goto loser;
- }
- core_regsec (abfd) = (asection *) zalloc (sizeof (asection));
- if (core_regsec (abfd) == NULL) {
- free ((void *)core_datasec (abfd));
- goto loser1;
- }
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_stacksec (abfd) == NULL)
+ return NULL;
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_datasec (abfd) == NULL)
+ return NULL;
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_regsec (abfd) == NULL)
+ return NULL;
core_stacksec (abfd)->name = ".stack";
core_datasec (abfd)->name = ".data";
core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
- core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+ core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
core_datasec (abfd)->_raw_size = u.pt_dsize;
core_stacksec (abfd)->_raw_size = u.pt_ssize;
#define NO_SIGNED_GET \
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-bfd_target ptrace_core_vec =
+const bfd_target ptrace_core_vec =
{
"trad-core",
bfd_target_unknown_flavour,
0, /* symbol prefix */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment power */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (_bfd_generic),
BFD_JUMP_TABLE_LINK (_bfd_nolink),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
(PTR) 0 /* backend_data */
};
--- /dev/null
+/* BFD back-end for RISC iX (Acorn, arm) binaries.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+
+/* RISC iX overloads the MAGIC field to indicate more than just the usual
+ [ZNO]MAGIC values. Also included are squeezing information and
+ shared library usage. */
+
+/* The following come from the man page. */
+#define SHLIBLEN 60
+
+#define MF_IMPURE 00200
+#define MF_SQUEEZED 01000
+#define MF_USES_SL 02000
+#define MF_IS_SL 04000
+
+/* Common combinations. */
+#define IMAGIC (MF_IMPURE|ZMAGIC) /* Demand load (impure text) */
+#define SPOMAGIC (MF_USES_SL|OMAGIC) /* OMAGIC with large header */
+ /* -- may contain a ref to a */
+ /* shared lib required by the */
+ /* object. */
+#define SLOMAGIC (MF_IS_SL|OMAGIC) /* A reference to a shared library */
+ /* The text portion of the object */
+ /* contains "overflow text" from */
+ /* the shared library to be linked */
+ /* in with an object */
+#define QMAGIC (MF_SQUEEZED|ZMAGIC) /* Sqeezed demand paged. */
+ /* NOTE: This interpretation of */
+ /* QMAGIC seems to be at variance */
+ /* With that used on other */
+ /* architectures. */
+#define SPZMAGIC (MF_USES_SL|ZMAGIC) /* program which uses sl */
+#define SPQMAGIC (MF_USES_SL|QMAGIC) /* sqeezed ditto */
+#define SLZMAGIC (MF_IS_SL|ZMAGIC) /* shared lib part of prog */
+#define SLPZMAGIC (MF_USES_SL|SLZMAGIC) /* sl which uses another */
+
+#define N_SHARED_LIB(x) ((x).a_info & MF_USES_SL)
+
+/* Only a pure OMAGIC file has the minimal header */
+#define N_TXTOFF(x) \
+ ((x).a_info == OMAGIC ? 32 \
+ : (N_MAGIC(x) == ZMAGIC) ? TARGET_PAGE_SIZE \
+ : 999)
+
+#define N_TXTADDR(x) \
+ (N_MAGIC(x) != ZMAGIC ? 0 /* object file or NMAGIC */ \
+ /* Programs with shared libs are loaded at the first page after all the \
+ text segments of the shared library programs. Without looking this \
+ up we can't know exactly what the address will be. A reasonable guess \
+ is that a_entry will be in the first page of the executable. */ \
+ : N_SHARED_LIB(x) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) \
+ : TEXT_START_ADDR)
+
+#define N_SYMOFF(x) \
+ (N_TXTOFF (x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
+
+#define N_STROFF(x) (N_SYMOFF (x) + (x).a_syms)
+
+#define TEXT_START_ADDR 32768
+#define TARGET_PAGE_SIZE 32768
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_arm
+
+#define MY(OP) CAT(riscix_,OP)
+#define TARGETNAME "a.out-riscix"
+#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
+ (((x).a_info & ~006000) != OMAGIC) && \
+ ((x).a_info != NMAGIC))
+#define N_MAGIC(x) ((x).a_info & ~07200)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "assert.h"
+
+#define WRITE_HEADERS(abfd, execp) \
+ { \
+ bfd_size_type text_size; /* dummy vars */ \
+ file_ptr text_end; \
+ if (adata(abfd).magic == undecided_magic) \
+ NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
+ \
+ execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
+ execp->a_entry = bfd_get_start_address (abfd); \
+ \
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
+ \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
+ if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
+ != EXEC_BYTES_SIZE) \
+ return false; \
+ /* Now write out reloc info, followed by syms and strings */ \
+ \
+ if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
+ && bfd_get_symcount (abfd) != 0) \
+ { \
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (! NAME(aout,write_syms)(abfd)) return false; \
+ \
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \
+ return false; \
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
+ return false; \
+ \
+ if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ return false; \
+ } \
+ }
+
+#include "libaout.h"
+#include "aout/aout64.h"
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
+ asection *, bfd *, char **));
+
+static reloc_howto_type riscix_std_reloc_howto[] = {
+ /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
+ HOWTO( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),
+ HOWTO( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),
+ HOWTO( 3, 2, 3, 26, true, 0, complain_overflow_signed, riscix_fix_pcrel_26 , "ARM26", true, 0x00ffffff,0x00ffffff, false),
+ HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, true),
+ HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, true),
+ HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, true),
+ HOWTO( 7, 2, 3, 26, false, 0, complain_overflow_signed, riscix_fix_pcrel_26_done, "ARM26D",true,0x00ffffff,0x00ffffff, false),
+ {-1},
+ HOWTO( 9, 0, -1, 16, false, 0, complain_overflow_bitfield,0,"NEG16", true, 0x0000ffff,0x0000ffff, false),
+ HOWTO( 10, 0, -2, 32, false, 0, complain_overflow_bitfield,0,"NEG32", true, 0xffffffff,0xffffffff, false)
+};
+
+#define RISCIX_TABLE_SIZE \
+ (sizeof (riscix_std_reloc_howto) / sizeof (reloc_howto_type))
+
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* This is dead simple at present. */
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ bfd_vma relocation;
+ bfd_size_type addr = reloc_entry->address;
+ long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ bfd_reloc_status_type flag = bfd_reloc_ok;
+
+ /* If this is an undefined symbol, return error */
+ if (symbol->section == &bfd_und_section
+ && (symbol->flags & BSF_WEAK) == 0)
+ return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
+
+ /* If the sections are different, and we are doing a partial relocation,
+ just ignore it for now. */
+ if (symbol->section->name != input_section->name
+ && output_bfd != (bfd *)NULL)
+ return bfd_reloc_continue;
+
+ relocation = (target & 0x00ffffff) << 2;
+ relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
+ relocation += symbol->value;
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+ relocation -= input_section->output_section->vma;
+ relocation -= input_section->output_offset;
+ relocation -= addr;
+ if (relocation & 3)
+ return bfd_reloc_overflow;
+
+ /* Check for overflow */
+ if (relocation & 0x02000000)
+ {
+ if ((relocation & ~0x03ffffff) != ~0x03ffffff)
+ flag = bfd_reloc_overflow;
+ }
+ else if (relocation & ~0x03ffffff)
+ flag = bfd_reloc_overflow;
+
+ target &= ~0x00ffffff;
+ target |= (relocation >> 2) & 0x00ffffff;
+ bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+
+ /* Now the ARM magic... Change the reloc type so that it is marked as done.
+ Strictly this is only necessary if we are doing a partial relocation. */
+ reloc_entry->howto = &riscix_std_reloc_howto[7];
+
+ return flag;
+}
+
+reloc_howto_type *
+DEFUN(riscix_reloc_type_lookup,(abfd,code),
+ bfd *abfd AND
+ bfd_reloc_code_real_type code)
+{
+#define ASTD(i,j) case i: return &riscix_std_reloc_howto[j]
+ if (code == BFD_RELOC_CTOR)
+ switch (bfd_get_arch_info (abfd)->bits_per_address)
+ {
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ default: return (reloc_howto_type *) NULL;
+ }
+
+ switch (code)
+ {
+ ASTD (BFD_RELOC_16, 1);
+ ASTD (BFD_RELOC_32, 2);
+ ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
+ ASTD (BFD_RELOC_8_PCREL, 4);
+ ASTD (BFD_RELOC_16_PCREL, 5);
+ ASTD (BFD_RELOC_32_PCREL, 6);
+ default: return (reloc_howto_type *) NULL;
+ }
+}
+
+#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define MY_bfd_final_link _bfd_generic_final_link
+
+#define MY_bfd_reloc_type_lookup riscix_reloc_type_lookup
+#define MY_canonicalize_reloc riscix_canonicalize_reloc
+#define MY_object_p riscix_object_p
+
+static const bfd_target *riscix_callback PARAMS ((bfd *));
+
+void
+riscix_swap_std_reloc_out (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
+{
+ int r_index;
+ asymbol *sym = *(g->sym_ptr_ptr);
+ int r_extern;
+ int r_length;
+ int r_pcrel;
+ int r_neg = 0; /* Negative relocs use the BASEREL bit. */
+ asection *output_section = sym->section->output_section;
+
+ PUT_WORD(abfd, g->address, natptr->r_address);
+
+ r_length = g->howto->size ; /* Size as a power of two */
+ if (r_length < 0)
+ {
+ r_length = -r_length;
+ r_neg = 1;
+ }
+
+ r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
+
+ /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
+ relocation has been done already (Only for the 26-bit one I think)???!!!
+ */
+
+ if (r_length == 3)
+ r_pcrel = r_pcrel ? 0 : 1;
+
+
+#if 0
+ /* For a standard reloc, the addend is in the object file. */
+ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+#endif
+
+ /* name was clobbered by aout_write_syms to be symbol index */
+
+ /* If this relocation is relative to a symbol then set the
+ r_index to the symbols index, and the r_extern bit.
+
+ Absolute symbols can come in in two ways, either as an offset
+ from the abs section, or as a symbol which has an abs value.
+ check for that here
+ */
+
+ if (bfd_is_com_section (output_section)
+ || output_section == &bfd_abs_section
+ || output_section == &bfd_und_section)
+ {
+ if (bfd_abs_section.symbol == sym)
+ {
+ /* Whoops, looked like an abs symbol, but is really an offset
+ from the abs section */
+ r_index = 0;
+ r_extern = 0;
+ }
+ else
+ {
+ /* Fill in symbol */
+ r_extern = 1;
+ r_index = stoi((*(g->sym_ptr_ptr))->flags);
+ }
+ }
+ else
+ {
+ /* Just an ordinary section */
+ r_extern = 0;
+ r_index = output_section->target_index;
+ }
+
+ /* now the fun stuff */
+ if (abfd->xvec->header_byteorder_big_p != false)
+ {
+ natptr->r_index[0] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[2] = r_index;
+ natptr->r_type[0] =
+ ( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
+ | (r_neg ? RELOC_STD_BITS_BASEREL_BIG: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
+ }
+ else
+ {
+ natptr->r_index[2] = r_index >> 16;
+ natptr->r_index[1] = r_index >> 8;
+ natptr->r_index[0] = r_index;
+ natptr->r_type[0] =
+ ( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
+ | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
+ | (r_neg ? RELOC_STD_BITS_BASEREL_LITTLE: 0)
+ | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
+ }
+}
+
+boolean
+riscix_squirt_out_relocs (abfd, section)
+ bfd *abfd;
+ asection *section;
+{
+ arelent **generic;
+ unsigned char *native, *natptr;
+ size_t each_size;
+
+ unsigned int count = section->reloc_count;
+ size_t natsize;
+
+ if (count == 0) return true;
+
+ each_size = obj_reloc_entry_size (abfd);
+ natsize = each_size * count;
+ native = (unsigned char *) bfd_zalloc (abfd, natsize);
+ if (!native)
+ return false;
+
+ generic = section->orelocation;
+
+ for (natptr = native;
+ count != 0;
+ --count, natptr += each_size, ++generic)
+ riscix_swap_std_reloc_out (abfd, *generic,
+ (struct reloc_std_external *) natptr);
+
+ if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ {
+ bfd_release(abfd, native);
+ return false;
+ }
+
+ bfd_release (abfd, native);
+ return true;
+}
+
+
+/*
+ * This is just like the standard aoutx.h version but we need to do our
+ * own mapping of external reloc type values to howto entries.
+ */
+long
+MY(canonicalize_reloc)(abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
+{
+ arelent *tblptr = section->relocation;
+ unsigned int count, c;
+ extern reloc_howto_type NAME(aout,std_howto_table)[];
+
+ /* If we have already read in the relocation table, return the values. */
+ if (section->flags & SEC_CONSTRUCTOR) {
+ arelent_chain *chain = section->constructor_chain;
+
+ for (count = 0; count < section->reloc_count; count++) {
+ *relptr++ = &chain->relent;
+ chain = chain->next;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+ }
+ if (tblptr && section->reloc_count) {
+ for (count = 0; count++ < section->reloc_count;)
+ *relptr++ = tblptr++;
+ *relptr = 0;
+ return section->reloc_count;
+ }
+
+ if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
+ return -1;
+ tblptr = section->relocation;
+
+ /* fix up howto entries */
+ for (count = 0; count++ < section->reloc_count;)
+ {
+ c = tblptr->howto - NAME(aout,std_howto_table);
+ assert (c < RISCIX_TABLE_SIZE);
+ tblptr->howto = &riscix_std_reloc_howto[c];
+
+ *relptr++ = tblptr++;
+ }
+ *relptr = 0;
+ return section->reloc_count;
+}
+
+/* This is the same as NAME(aout,some_aout_object_p), but has different
+ expansions of the macro definitions. */
+
+const bfd_target *
+riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
+ bfd *abfd;
+ struct internal_exec *execp;
+ const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
+{
+ struct aout_data_struct *rawptr, *oldrawptr;
+ const bfd_target *result;
+
+ rawptr = ((struct aout_data_struct *)
+ bfd_zalloc (abfd, sizeof (struct aout_data_struct )));
+
+ if (rawptr == NULL)
+ return 0;
+
+ oldrawptr = abfd->tdata.aout_data;
+ abfd->tdata.aout_data = rawptr;
+
+ /* Copy the contents of the old tdata struct.
+ In particular, we want the subformat, since for hpux it was set in
+ hp300hpux.c:swap_exec_header_in and will be used in
+ hp300hpux.c:callback. */
+ if (oldrawptr != NULL)
+ *abfd->tdata.aout_data = *oldrawptr;
+
+ abfd->tdata.aout_data->a.hdr = &rawptr->e;
+ *(abfd->tdata.aout_data->a.hdr) = *execp; /* Copy in the internal_exec
+ struct */
+ execp = abfd->tdata.aout_data->a.hdr;
+
+ /* Set the file flags */
+ abfd->flags = NO_FLAGS;
+ if (execp->a_drsize || execp->a_trsize)
+ abfd->flags |= HAS_RELOC;
+ /* Setting of EXEC_P has been deferred to the bottom of this function */
+ if (execp->a_syms)
+ abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+ if (N_DYNAMIC(*execp))
+ abfd->flags |= DYNAMIC;
+
+
+ if ((execp->a_info & MF_SQUEEZED) != 0) /* Squeezed files aren't supported
+ (yet)! */
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ else if ((execp->a_info & MF_IS_SL) != 0) /* Nor are shared libraries */
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ else if (N_MAGIC (*execp) == ZMAGIC)
+ {
+ abfd->flags |= D_PAGED | WP_TEXT;
+ adata (abfd).magic = z_magic;
+ }
+ else if (N_MAGIC (*execp) == NMAGIC)
+ {
+ abfd->flags |= WP_TEXT;
+ adata (abfd).magic = n_magic;
+ }
+ else if (N_MAGIC (*execp) == OMAGIC)
+ adata (abfd).magic = o_magic;
+ else
+ {
+ /* Should have been checked with N_BADMAG before this routine
+ was called. */
+ abort ();
+ }
+
+ bfd_get_start_address (abfd) = execp->a_entry;
+
+ obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
+ bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
+
+ /* The default relocation entry size is that of traditional V7 Unix. */
+ obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+ /* The default symbol entry size is that of traditional Unix. */
+ obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
+
+ obj_aout_external_syms (abfd) = NULL;
+ obj_aout_external_strings (abfd) = NULL;
+ obj_aout_sym_hashes (abfd) = NULL;
+
+ if (! NAME(aout,make_sections) (abfd))
+ return NULL;
+
+ obj_datasec (abfd)->_raw_size = execp->a_data;
+ obj_bsssec (abfd)->_raw_size = execp->a_bss;
+
+ obj_textsec (abfd)->flags =
+ (execp->a_trsize != 0
+ ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)
+ : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));
+ obj_datasec (abfd)->flags =
+ (execp->a_drsize != 0
+ ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)
+ : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
+ obj_bsssec (abfd)->flags = SEC_ALLOC;
+
+ result = (*callback_to_real_object_p)(abfd);
+
+#if defined(MACH) || defined(STAT_FOR_EXEC)
+ /* The original heuristic doesn't work in some important cases. The
+ * a.out file has no information about the text start address. For
+ * files (like kernels) linked to non-standard addresses (ld -Ttext
+ * nnn) the entry point may not be between the default text start
+ * (obj_textsec(abfd)->vma) and (obj_textsec(abfd)->vma) + text size
+ * This is not just a mach issue. Many kernels are loaded at non
+ * standard addresses.
+ */
+ {
+ struct stat stat_buf;
+ if (abfd->iostream
+ && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)
+ && ((stat_buf.st_mode & 0111) != 0))
+ abfd->flags |= EXEC_P;
+ }
+#else /* ! MACH */
+ /* Now that the segment addresses have been worked out, take a better
+ guess at whether the file is executable. If the entry point
+ is within the text segment, assume it is. (This makes files
+ executable even if their entry point address is 0, as long as
+ their text starts at zero.)
+
+ At some point we should probably break down and stat the file and
+ declare it executable if (one of) its 'x' bits are on... */
+ if ((execp->a_entry >= obj_textsec(abfd)->vma) &&
+ (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
+ abfd->flags |= EXEC_P;
+#endif /* MACH */
+ if (result)
+ {
+ }
+ else
+ {
+ free (rawptr);
+ abfd->tdata.aout_data = oldrawptr;
+ }
+ return result;
+}
+
+
+static const bfd_target *
+MY(object_p) (abfd)
+ bfd *abfd;
+{
+ struct external_exec exec_bytes; /* Raw exec header from file */
+ struct internal_exec exec; /* Cleaned-up exec header */
+ const bfd_target *target;
+
+ if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE) {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+
+ if (N_BADMAG (exec)) return 0;
+#ifdef MACHTYPE_OK
+ if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
+#endif
+
+ NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+
+ target = riscix_some_aout_object_p (abfd, &exec, MY(callback));
+
+ return target;
+}
+
+
+#include "aout-target.h"
final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 6);
final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types || !final_type)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* The field selector may require additional relocations to be
generated. It's impossible to know at this moment if additional
case e_rtsel:
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0])
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
if (field == e_tsel)
*final_types[0] = R_FSEL;
else if (field == e_ltsel)
case e_rssel:
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0])
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
*final_types[0] = R_S_MODE;
final_types[1] = final_type;
final_types[2] = NULL;
case e_rsel:
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0])
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
*final_types[0] = R_N_MODE;
final_types[1] = final_type;
final_types[2] = NULL;
case e_rdsel:
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0])
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
*final_types[0] = R_D_MODE;
final_types[1] = final_type;
final_types[2] = NULL;
case e_rrsel:
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0])
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
*final_types[0] = R_R_MODE;
final_types[1] = final_type;
final_types[2] = NULL;
final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0] || !final_types[1] || !final_types[2])
- {
- bfd_set_error (bfd_error_no_memory);
return NULL;
- }
if (field == e_fsel)
*final_types[0] = R_FSEL;
else if (field == e_rsel)
final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types[0] || !final_types[1] || !final_types[2])
- {
- bfd_set_error (bfd_error_no_memory);
return NULL;
- }
if (field == e_fsel)
*final_types[0] = R_FSEL;
else if (field == e_rsel)
obj_som_exec_data (abfd) = (struct som_exec_data *)
bfd_zalloc (abfd, sizeof (struct som_exec_data ));
if (obj_som_exec_data (abfd) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
/* The braindamaged OSF1 linker switched exec_flags and exec_entry!
abfd->tdata.som_data = (struct som_data_struct *)
bfd_zalloc (abfd, sizeof (struct som_data_struct));
if (abfd->tdata.som_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
return true;
}
/* Make and attach a file header to the BFD. */
file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
if (file_hdr == NULL)
-
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_som_file_hdr (abfd) = file_hdr;
if (abfd->flags & (EXEC_P | DYNAMIC))
obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *)
bfd_zalloc (abfd, sizeof (struct som_exec_auxhdr));
if (obj_som_exec_hdr (abfd) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (abfd->flags & D_PAGED)
file_hdr->a_magic = DEMAND_MAGIC;
= (struct space_dictionary_record *)
bfd_zalloc (abfd, sizeof (struct space_dictionary_record));
if (som_section_data (section)->space_dict == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Set space attributes. Note most attributes of SOM spaces
are set based on the subspaces it contains. */
som_section_data (section)->space_dict->loader_fix_index = -1;
= (struct subspace_dictionary_record *)
bfd_zalloc (abfd, sizeof (struct subspace_dictionary_record));
if (som_section_data (section)->subspace_dict == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Set subspace attributes. Basic stuff is done here, additional
attributes are filled in later as more information becomes
/* Allocate and read in the string table. */
stringtab = malloc (obj_som_stringtab_size (abfd));
- bzero (stringtab, obj_som_stringtab_size (abfd));
if (stringtab == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
+ memset (stringtab, 0, obj_som_stringtab_size (abfd));
if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
return false;
symbase = (som_symbol_type *)
malloc (symbol_count * sizeof (som_symbol_type));
- bzero (symbase, symbol_count * sizeof (som_symbol_type));
if (symbase == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
+ memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
/* Read in the external SOM representation. */
buf = malloc (symbol_count * symsize);
som_symbol_type *new =
(som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
if (new == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return 0;
- }
+ return 0;
new->symbol.the_bfd = abfd;
return &new->symbol;
internal_relocs = (arelent *)
bfd_zalloc (abfd, (num_relocs * sizeof (arelent)));
if (internal_relocs == (arelent *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Process and internalize the relocations. */
som_set_reloc_info (external_relocs, fixup_stream_size,
newsect->used_by_bfd =
(PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
if (!newsect->used_by_bfd)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
newsect->alignment_power = 3;
/* We allow more than three sections internally */
= (struct som_copyable_section_data_struct *)
bfd_zalloc (obfd, sizeof (struct som_copyable_section_data_struct));
if (som_section_data (osection)->copy_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memcpy (som_section_data (osection)->copy_data,
som_section_data (isection)->copy_data,
obj_som_exec_data (obfd) = (struct som_exec_data *)
bfd_zalloc (obfd, sizeof (struct som_exec_data));
if (obj_som_exec_data (obfd) == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Now copy the data. */
memcpy (obj_som_exec_data (obfd), obj_som_exec_data (ibfd),
bfd_zalloc (section->owner,
sizeof (struct som_copyable_section_data_struct));
if (som_section_data (section)->copy_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
som_section_data (section)->copy_data->sort_key = sort_key;
som_section_data (section)->copy_data->is_defined = defined;
bfd_zalloc (section->owner,
sizeof (struct som_copyable_section_data_struct));
if (som_section_data (section)->copy_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
som_section_data (section)->copy_data->sort_key = sort_key;
som_section_data (section)->copy_data->access_control_bits = access;
bfd_zalloc (abfd, sizeof (struct aux_id)
+ sizeof (unsigned int) + len + pad);
if (!obj_som_version_hdr (abfd))
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
obj_som_version_hdr (abfd)->header_id.length = len + pad;
obj_som_version_hdr (abfd)->header_id.length += sizeof (int);
bfd_zalloc (abfd, sizeof (struct aux_id)
+ sizeof (unsigned int) + len + pad);
if (!obj_som_copyright_hdr (abfd))
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
obj_som_copyright_hdr (abfd)->header_id.length = len + pad;
obj_som_copyright_hdr (abfd)->header_id.length += sizeof (int);
/* Allocate space for the name and null terminate it too. */
set->name = bfd_zalloc (abfd, len + 1);
if (!set->name)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
if (bfd_read (set->name, 1, len, abfd) != len)
goto error_return;
/* Allocate space for the name and null terminate it too. */
set->name = bfd_zalloc (abfd, len + 1);
if (!set->name)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
if (bfd_read (set->name, 1, len, abfd) != len)
goto error_return;
(ardata->symdef_count
* sizeof (carsym)));
if (!ardata->symdefs)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Now fill in the canonical archive symbols. */
if (som_bfd_fill_in_ar_symbols (abfd, &lst_header, &ardata->symdefs)
unsigned int thislen;
if (!normal)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
thislen = strlen (normal);
if (thislen > maxname)
extended_name_length += thislen + 1;
#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#define som_read_minisymbols _bfd_generic_read_minisymbols
#define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+#define som_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
#define som_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define som_bfd_final_link _bfd_generic_final_link
+
const bfd_target som_vec =
{
"som", /* name */
{
tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
if (tdata == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
abfd->tdata.srec_data = tdata;
tdata->type = 1;
tdata->head = NULL;
buf[0] = c;
buf[1] = '\0';
}
- fprintf (stderr, "%s:%d: Unexpected character `%s' in S-record file\n",
- bfd_get_filename (abfd), lineno, buf);
+ (*_bfd_error_handler)
+ ("%s:%d: Unexpected character `%s' in S-record file\n",
+ bfd_get_filename (abfd), lineno, buf);
bfd_set_error (bfd_error_bad_value);
}
}
n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
if (n == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
n->name = name;
n->val = val;
section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
if (section->used_by_bfd == NULL
&& section->_raw_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (! srec_read_section (abfd, section, section->used_by_bfd))
return false;
entry = ((srec_data_list_type *)
bfd_alloc (abfd, sizeof (srec_data_list_type)));
if (entry == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bytes_to_do
&& (section->flags & SEC_ALLOC)
{
bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
if (data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memcpy ((PTR) data, location, (size_t) bytes_to_do);
if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
if (csymbols == NULL && symcount != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
abfd->tdata.srec_data->csymbols = csymbols;
for (s = abfd->tdata.srec_data->symbols, c = csymbols;
((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
#define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+#define srec_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
#define srec_set_arch_mach bfd_default_set_arch_mach
#define srec_bfd_get_relocated_section_contents \
info = ((struct sunos_dynamic_info *)
bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
if (!info)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
info->valid = false;
info->dynsym = NULL;
info->dynstr = NULL;
(info->dynsym_count
* EXTERNAL_NLIST_SIZE)));
if (info->dynsym == NULL && info->dynsym_count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
|| (bfd_read ((PTR) info->dynsym, info->dynsym_count,
EXTERNAL_NLIST_SIZE, abfd)
{
info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0
|| (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size,
abfd)
(info->dynsym_count
* sizeof (aout_symbol_type))));
if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
info->dynsym, info->dynsym_count,
(info->dynrel_count
* obj_reloc_entry_size (abfd)));
if (info->dynrel == NULL && info->dynrel_count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
if (bfd_seek (abfd, info->dyninfo.ld_rel, SEEK_SET) != 0
|| (bfd_read ((PTR) info->dynrel, info->dynrel_count,
obj_reloc_entry_size (abfd), abfd)
(info->dynrel_count
* sizeof (arelent))));
if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
to = info->canonical_dynrel;
ret = ((struct sunos_link_hash_entry *)
bfd_hash_allocate (table, sizeof (struct sunos_link_hash_entry)));
if (ret == (struct sunos_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct sunos_link_hash_entry *)
ret = ((struct sunos_link_hash_table *)
bfd_alloc (abfd, sizeof (struct sunos_link_hash_table)));
if (ret == (struct sunos_link_hash_table *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_link_hash_table *) NULL;
- }
+ return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
sunos_link_hash_newfunc))
{
needed = (struct bfd_link_needed_list *) bfd_alloc (abfd, sizeof (struct bfd_link_needed_list));
if (needed == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
needed->by = abfd;
/* We return the name as [-l]name[.maj][.min]. */
}
needed->name = bfd_alloc_finish (abfd);
if (needed->name == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
needed->next = NULL;
s->_raw_size = dynsymcount * sizeof (struct external_nlist);
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL && s->_raw_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* The number of buckets is just the number of symbols divided by
four. To compute the final size of the hash table, we must
hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
if (s->contents == NULL && dynsymcount > 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
memset (s->contents, 0, hashalloc);
for (i = 0; i < bucketcount; i++)
PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
{
s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
if (s->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
/* Fill in the first entry in the table. */
switch (bfd_get_arch (dynobj))
{
s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
if (s->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
/* We use the reloc_count field to keep track of how many of the
relocs we have output so far. */
s = bfd_get_section_by_name (dynobj, ".got");
s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
if (s->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
*sdynptr = bfd_get_section_by_name (dynobj, ".dynamic");
*sneedptr = bfd_get_section_by_name (dynobj, ".need");
(bfd_get_symcount (abfd)
* sizeof (bfd_vma)));
if (adata (abfd).local_got_offsets == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
if (adata (abfd).local_got_offsets[r_index] != 0)
extern const bfd_target m68klynx_aout_vec;
extern const bfd_target m68klynx_coff_vec;
extern const bfd_target m68knetbsd_vec;
+extern const bfd_target m68k4knetbsd_vec;
extern const bfd_target m88kbcs_vec;
extern const bfd_target m88kmach3_vec;
extern const bfd_target newsos3_vec;
name_ptr = name_list = (CONST char **)
bfd_zmalloc ((vec_length + 1) * sizeof (char **));
- if (name_list == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (name_list == NULL)
return NULL;
- }
for (target = &bfd_target_vector[0]; *target != NULL; target++)
*(name_ptr++) = (*target)->name;
bfd_alloc (abfd, sizeof (struct data_struct));
if (!sname || !d)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
memset (d->chunk_init, 0, CHUNK_MASK + 1);
memset (d->chunk_data, 0, CHUNK_MASK + 1);
char *n = bfd_alloc (abfd, len + 1);
if (!n)
- {
- bfd_set_error (bfd_error_no_memory);
- abort(); /* FIXME */
- }
+ abort(); /* FIXME */
memcpy (n, sym, len + 1);
section = bfd_make_section (abfd, n);
}
char type = (*src);
if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- abort(); /* FIXME */
- }
+ abort(); /* FIXME */
new->symbol.the_bfd = abfd;
src++;
abfd->symcount++;
len = getsym (sym, &src);
new->symbol.name = bfd_alloc (abfd, len + 1);
if (!new->symbol.name)
- {
- bfd_set_error (bfd_error_no_memory);
- abort(); /* FIXME */
- }
+ abort(); /* FIXME */
memcpy ((char *) (new->symbol.name), sym, len + 1);
new->symbol.section = section;
if (type <= '4')
tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
if (!tdata)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
abfd->tdata.tekhex_data = tdata;
tdata->type = 1;
tdata->head = (tekhex_data_list_type *) NULL;
(tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));
if (!new)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
+ return NULL;
new->symbol.the_bfd = abfd;
new->prev = (struct tekhex_symbol_struct *) NULL;
return &(new->symbol);
#define tekhex_bfd_final_link _bfd_generic_final_link
#define tekhex_bfd_link_split_section _bfd_generic_link_split_section
+#define tekhex_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
const bfd_target tekhex_vec =
{
"tekhex", /* name */
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 1, /* minimum alignment */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
asection *stack_section;
asection *reg_section;
struct user u;
- } *rawptr;
+ };
#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
{
int val;
struct user u;
+ struct trad_core_struct *rawptr;
#ifdef TRAD_CORE_USER_OFFSET
/* If defined, this macro is the file position of the user struct. */
a single free() will free them both. */
rawptr = (struct trad_core_struct *)
bfd_zmalloc (sizeof (struct trad_core_struct));
- if (rawptr == NULL) {
- bfd_set_error (bfd_error_no_memory);
+ if (rawptr == NULL)
return 0;
- }
abfd->tdata.trad_core_data = rawptr;
/* Create the sections. This is raunchy, but bfd_close wants to free
them separately. */
- core_stacksec(abfd) = (asection *) bfd_zmalloc (sizeof (asection));
- if (core_stacksec (abfd) == NULL) {
- loser:
- bfd_set_error (bfd_error_no_memory);
- free ((void *)rawptr);
- return 0;
- }
- core_datasec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
- if (core_datasec (abfd) == NULL) {
- loser1:
- free ((void *)core_stacksec (abfd));
- goto loser;
- }
- core_regsec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
- if (core_regsec (abfd) == NULL) {
- free ((void *)core_datasec (abfd));
- goto loser1;
- }
+ core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_stacksec (abfd) == NULL)
+ return NULL;
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_datasec (abfd) == NULL)
+ return NULL;
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ if (core_regsec (abfd) == NULL)
+ return NULL;
core_stacksec (abfd)->name = ".stack";
core_datasec (abfd)->name = ".data";
0 is at the place pointed to by u_ar0 (by setting the vma of the start
of the section to -u_ar0). GDB uses this info to locate the regs,
using minor trickery to get around the offset-or-absolute-addr problem. */
- core_regsec (abfd)->vma = 0 - (int) u.u_ar0;
+ core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;
core_datasec (abfd)->filepos = NBPG * UPAGES;
core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize
0, /* symbol prefix */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment power */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
{
tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
if (tdata == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
abfd->tdata.versados_data = tdata;
tdata->symbols = NULL;
VDATA (abfd)->alert = 0x12345678;
return true;
}
+#define versados_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+
static boolean
versados_set_section_contents (abfd, section, location, offset, bytes_to_do)
bfd *abfd;
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 1, /* minimum alignment */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
ret = ((struct xcoff_link_hash_entry *)
bfd_hash_allocate (table, sizeof (struct xcoff_link_hash_entry)));
if (ret == (struct xcoff_link_hash_entry *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_hash_entry *) ret;
- }
+ return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct xcoff_link_hash_entry *)
ret = ((struct xcoff_link_hash_table *)
bfd_alloc (abfd, sizeof (struct xcoff_link_hash_table)));
if (ret == (struct xcoff_link_hash_table *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_link_hash_table *) NULL;
- }
+ return (struct bfd_link_hash_table *) NULL;
if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
{
bfd_release (abfd, ret);
(symcount
* sizeof (struct xcoff_link_hash_entry *))));
if (sym_hash == NULL && symcount != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
memset (sym_hash, 0,
(size_t) symcount * sizeof (struct xcoff_link_hash_entry *));
csect_cache = ((asection **)
bfd_alloc (abfd, symcount * sizeof (asection *)));
if (csect_cache == NULL && symcount != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
xcoff_data (abfd)->csects = csect_cache;
memset (csect_cache, 0, (size_t) symcount * sizeof (asection *));
((struct coff_section_tdata *)
bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
if (csect->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
coff_section_data (abfd, csect)->tdata =
bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
if (coff_section_data (abfd, csect)->tdata == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
xcoff_section_data (abfd, csect)->enclosing = enclosing;
xcoff_section_data (abfd, csect)->lineno_count =
enclosing->lineno_count;
((struct coff_section_tdata *)
bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
if (csect->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
coff_section_data (abfd, csect)->tdata =
bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
if (coff_section_data (abfd, csect)->tdata == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
xcoff_section_data (abfd, csect)->first_symndx = csect_index;
if (first_csect == NULL)
n = ((struct xcoff_import_file *)
bfd_alloc (abfd, sizeof (struct xcoff_import_file)));
if (n == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
n->next = NULL;
/* For some reason, the path entry in the import file list for a
n = ((struct xcoff_link_size_list *)
bfd_alloc (output_bfd, sizeof (struct xcoff_link_size_list)));
if (n == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
n->next = xcoff_hash_table (info)->size_list;
n->h = h;
n->size = size;
h->ldsym = ((struct internal_ldsym *)
bfd_zalloc (output_bfd, sizeof (struct internal_ldsym)));
if (h->ldsym == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
}
if (imppath == NULL)
n = ((struct xcoff_import_file *)
bfd_alloc (output_bfd, sizeof (struct xcoff_import_file)));
if (n == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
n->next = NULL;
n->path = imppath;
n->file = impfile;
lsec->_raw_size = stoff + ldhdr->l_stlen;
lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->_raw_size);
if (lsec->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
/* Set up the header. */
xcoff_swap_ldhdr_out (output_bfd, ldhdr,
{
sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
if (sec->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
}
sec = xcoff_hash_table (info)->toc_section;
if (sec->_raw_size > 0)
{
sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
if (sec->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
}
sec = xcoff_hash_table (info)->descriptor_section;
if (sec->_raw_size > 0)
{
sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
if (sec->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
}
/* Now that we've done garbage collection, figure out the contents
debug_index = ((unsigned long *)
bfd_zalloc (sub, symcount * sizeof (unsigned long)));
if (debug_index == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
xcoff_data (sub)->debug_indices = debug_index;
/* Grab the contents of the .debug section. We use malloc and
if (h->ldsym == NULL)
{
ldinfo->failed = true;
- bfd_set_error (bfd_error_no_memory);
return false;
}
}
bfd_alloc (finfo->output_bfd,
sizeof (struct xcoff_toc_rel_hash)));
if (n == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
si = finfo->section_info + target_index;
n->next = si->toc_rel_hashes;
n->h = h;
size = bfd_get_reloc_size (howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
switch (rstat)