-
-/* bfd back-end for ieee-695 objects.
- Copyright (C) 1990-1992 Free Software Foundation, Inc.
+/* BFD back-end for ieee-695 objects.
+ Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#define KEEPMINUSPCININST 1
+#define KEEPMINUSPCININST 0
/* IEEE 695 format is a stream of records, which we parse using a simple one-
token (which is one byte in this lexicon) lookahead recursive decent
#include "obstack.h"
-#define obstack_chunk_alloc bfd_xmalloc
+#define obstack_chunk_alloc bfd_xmalloc_by_size_t
#define obstack_chunk_free free
/* Functions for writing to ieee files in the strange way that the
bfd_vma value)
{
if (((unsigned)value) <= 127) {
- ieee_write_byte(abfd, value);
+ ieee_write_byte(abfd, (bfd_byte)value);
}
else {
unsigned int length;
}
else length = 1;
- ieee_write_byte(abfd, (int)ieee_number_repeat_start_enum + length);
+ ieee_write_byte(abfd,
+ (bfd_byte)((int)ieee_number_repeat_start_enum + length));
switch (length) {
case 4:
- ieee_write_byte(abfd, value >> 24);
+ ieee_write_byte(abfd, (bfd_byte)(value >> 24));
case 3:
- ieee_write_byte(abfd, value >> 16);
+ ieee_write_byte(abfd, (bfd_byte)(value >> 16));
case 2:
- ieee_write_byte(abfd, value >> 8);
+ ieee_write_byte(abfd, (bfd_byte)(value >> 8));
case 1:
- ieee_write_byte(abfd, value);
+ ieee_write_byte(abfd, (bfd_byte)(value));
}
}
}
{
size_t length = strlen(id);
if (length >= 0 && length <= 127) {
- ieee_write_byte(abfd, length);
+ ieee_write_byte(abfd, (bfd_byte)length);
}
else if (length < 255) {
ieee_write_byte(abfd, ieee_extension_length_1_enum);
- ieee_write_byte(abfd, length);
+ ieee_write_byte(abfd, (bfd_byte)length);
}
else if (length < 65535) {
ieee_write_byte(abfd, ieee_extension_length_2_enum);
- ieee_write_byte(abfd, length >> 8);
- ieee_write_byte(abfd, length & 0xff);
+ ieee_write_byte(abfd, (bfd_byte)(length >> 8));
+ ieee_write_byte(abfd, (bfd_byte)(length & 0xff));
}
else {
BFD_FAIL();
- if (symbol->section == &bfd_com_section
+ if (bfd_is_com_section (symbol->section)
|| symbol->section == &bfd_und_section)
{
/* Def of a common symbol */
/* Ref to defined symbol - */
ieee_write_byte(abfd, ieee_variable_R_enum);
- ieee_write_byte(abfd, symbol->section->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd,
+ (bfd_byte) (symbol->section->index + IEEE_SECTION_NUMBER_BASE));
term_count++;
if (symbol->flags & BSF_GLOBAL)
{
/* This is a reference to a defined local symbol,
We can easily do a local as a section+offset */
ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
- ieee_write_byte(abfd, symbol->section->index +
- IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd,
+ (bfd_byte)(symbol->section->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_int(abfd, symbol->value);
term_count++;
if(pcrel) {
/* subtract the pc from here by asking for PC of this section*/
ieee_write_byte(abfd, ieee_variable_P_enum);
- ieee_write_byte(abfd, index +IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd, (bfd_byte)(index+IEEE_SECTION_NUMBER_BASE));
ieee_write_byte(abfd, ieee_function_minus_enum);
}
#define ieee_pos(abfd) IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte
static unsigned int last_index;
-
+static char last_type; /* is the index for an X or a D */
static ieee_symbol_type *
DEFUN(get_symbol,(abfd,
ieee,
last_symbol,
symbol_count,
-pptr,
-max_index
+ pptr,
+ max_index,
+ this_type
),
bfd *abfd AND
ieee_data_type *ieee AND
ieee_symbol_type *last_symbol AND
unsigned int *symbol_count AND
ieee_symbol_type *** pptr AND
- unsigned int *max_index
+ unsigned int *max_index AND
+ char this_type
)
{
/* Need a new symbol */
unsigned int new_index = must_parse_int(&(ieee->h));
- if (new_index != last_index) {
+ if (new_index != last_index || this_type != last_type) {
ieee_symbol_type * new_symbol = (ieee_symbol_type *)bfd_alloc(ieee->h.abfd,
sizeof(ieee_symbol_type));
if (new_index > *max_index) {
*max_index = new_index;
}
+ last_type = this_type;
return new_symbol;
}
return last_symbol;
switch (this_byte(&(ieee->h))) {
case ieee_nn_record:
next_byte(&(ieee->h));
+
symbol = get_symbol(abfd, ieee, symbol, &symbol_count,
&prev_symbols_ptr,
- &ieee->external_symbol_max_index);
+ &ieee->external_symbol_max_index,'D');
+
symbol->symbol.the_bfd = abfd;
symbol->symbol.name = read_id(&(ieee->h));
symbol = get_symbol(abfd, ieee, symbol, &symbol_count,
&prev_symbols_ptr,
- &ieee->external_symbol_max_index);
+ &ieee->external_symbol_max_index,'D');
BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
symbol = get_symbol(abfd, ieee, symbol, &symbol_count,
&prev_reference_ptr,
- &ieee->external_reference_max_index);
+ &ieee->external_reference_max_index,'X');
symbol->symbol.the_bfd = abfd;
ieee_symbol_type *symp;
static bfd dummy_bfd;
static asymbol empty_symbol =
- { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING , &bfd_abs_section};
+ /* the_bfd, name, value, attr, section */
+ { &dummy_bfd, " ieee empty", (symvalue)0, BSF_DEBUGGING, &bfd_abs_section};
if (abfd->symcount)
{
}
- location[abfd->symcount] = (asymbol *)NULL;
+ if (abfd->symcount) {
+ location[abfd->symcount] = (asymbol *)NULL;
+ }
return abfd->symcount;
}
static asection *
unsigned int index)
{
if (ieee->section_table[index] == (asection *)NULL) {
- asection *section = bfd_make_section(abfd, " tempname");
+ char *tmp = bfd_alloc(abfd,11);
+ asection *section;
+ sprintf(tmp," fsec%4d", index);
+ section = bfd_make_section(abfd, tmp);
ieee->section_table[index] = section;
section->flags = SEC_NO_FLAGS;
section->target_index = index;
{
ieee_data_type *ieee = IEEE_DATA(abfd);
file_ptr offset = ieee->w.r.section_part;
-
asection *section = (asection *)NULL;
+ char *name;
if (offset != 0) {
bfd_byte section_type[3];
section_type[1] = this_byte(&(ieee->h));
section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
switch(section_type[1]) {
- case 0xD3:
+ case 0xD3: /* AS Absolute section attributes */
next_byte(&(ieee->h));
section_type[2] = this_byte(&(ieee->h));
switch (section_type[2])
}
}
break;
- case 0xC3:
+ case 0xC3: /* Named relocatable sections (type C) */
section_type[1] = this_byte(&(ieee->h));
section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
switch (section_type[1]) {
- case 0xD0:
- /* Normal code */
+ case 0xD0: /* Normal code (CP) */
next_byte(&(ieee->h));
section->flags |= SEC_LOAD | SEC_CODE;
break;
- case 0xC4:
+ case 0xC4: /* Normal data (CD) */
next_byte(&(ieee->h));
section->flags |= SEC_LOAD | SEC_DATA;
- /* Normal data */
break;
- case 0xD2:
+ case 0xD2: /* Normal rom data (CR) */
next_byte(&(ieee->h));
- /* Normal rom data */
section->flags |= SEC_LOAD | SEC_ROM | SEC_DATA;
break;
default:
break;
}
}
- section->name = read_id(&(ieee->h));
- { bfd_vma parent, brother, context;
+
+ /* Read section name, use it if non empty. */
+ name = read_id (&ieee->h);
+ if (name[0])
+ section->name = name;
+
+ /* Skip these fields, which we don't care about */
+ {
+ bfd_vma parent, brother, context;
parse_int(&(ieee->h), &parent);
parse_int(&(ieee->h), &brother);
parse_int(&(ieee->h), &context);
- }
-
-
+ }
}
break;
case ieee_section_alignment_enum:
boolean loop;
unsigned int i;
-uint8e_type buffer[512];
+ unsigned char buffer[512];
struct obstack ob;
file_ptr buffer_offset = 0;
ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
return (bfd_target *)NULL;
}
/* Throw away the filename */
- free( read_id(&(ieee->h)));
+ read_id(&(ieee->h));
/* This must be an IEEE archive, so we'll buy some space to do
things */
}
}
+/* abfd->has_armap = ;*/
return abfd->xvec;
}
char *processor;
unsigned int part;
ieee_data_type *ieee;
- uint8e_type buffer[300];
+ unsigned char buffer[300];
ieee_data_type *save = IEEE_DATA(abfd);
+
abfd->tdata.ieee_data = 0;
ieee_mkobject(abfd);
quickly. We can work out how big the file is from the trailer
record */
- IEEE_DATA(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+ IEEE_DATA(abfd)->h.first_byte = (unsigned char *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+ 50);
bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd);
return (bfd_target *)NULL;
}
+void
+DEFUN(ieee_get_symbol_info,(ignore_abfd, symbol, ret),
+ bfd *ignore_abfd AND
+ asymbol *symbol AND
+ symbol_info *ret)
+{
+ bfd_symbol_info (symbol, ret);
+ if (symbol->name[0] == ' ')
+ ret->name = "* empty table entry ";
+ if (!symbol->section)
+ ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
+}
void
DEFUN(ieee_print_symbol,(ignore_abfd, afile, symbol, how),
#endif
BFD_FAIL();
break;
- case bfd_print_symbol_nm:
case bfd_print_symbol_all:
{
CONST char *section_name = symbol->section == (asection *)NULL ?
DEFUN(do_one,(ieee, current_map, location_ptr,s),
ieee_data_type *ieee AND
ieee_per_section_type *current_map AND
- uint8e_type *location_ptr AND
+ unsigned char *location_ptr AND
asection *s)
{
switch (this_byte(&(ieee->h)))
r->next = (ieee_reloc_type *)NULL;
next_byte(&(ieee->h));
/* abort();*/
-
+ r->relent.sym_ptr_ptr = 0;
parse_expression(ieee,
&r->relent.addend,
&r->symbol,
case ieee_set_current_pc_enum & 0xff:
{
bfd_vma value;
- asection *dsection;
ieee_symbol_index_type symbol;
unsigned int extra;
boolean pcrel;
*/
unsigned int iterations ;
- uint8e_type *start ;
+ unsigned char *start ;
next_byte(&(ieee->h));
iterations = must_parse_int(&(ieee->h));
start = ieee->h.input_p;
symbols + src->symbol.index + ieee->external_reference_base_offset;
break;
case 0:
- src->relent.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ src->relent.sym_ptr_ptr =
+ src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
break;
default:
{
ieee_write_byte(abfd, ieee_section_type_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE));
if (abfd->flags & EXEC_P)
{
#endif
/* Alignment */
ieee_write_byte(abfd, ieee_section_alignment_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_int(abfd, 1 << s->alignment_power);
/* Size */
ieee_write_2bytes(abfd, ieee_section_size_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_int(abfd, s->_raw_size);
if (abfd->flags & EXEC_P) {
/* Relocateable sections don't have asl records */
/* Vma */
ieee_write_2bytes(abfd, ieee_section_base_address_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd,
+ (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_int(abfd, s->vma);
}
}
/* Output the section preheader */
ieee_write_byte(abfd, ieee_set_current_section_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_twobyte(abfd, ieee_set_current_pc_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_expression(abfd, 0, s->symbol, 0, 0);
if (relocs_to_go == 0)
if ((PTR)stream == (PTR)NULL) {
/* Outputting a section without data, fill it up */
- stream = (uint8e_type *)(bfd_alloc(abfd, s->_raw_size));
+ stream = (unsigned char *)(bfd_alloc(abfd, s->_raw_size));
memset((PTR)stream, 0, s->_raw_size);
}
while (current_byte_index < s->_raw_size) {
BFD_FAIL();
}
ieee_write_byte(abfd, ieee_function_either_open_b_enum);
- abort();
+/* abort();*/
if (r->sym_ptr_ptr != (asymbol **)NULL) {
ieee_write_expression(abfd, r->addend + ov,
bfd *abfd AND
asection *s)
{
- ieee_write_byte(abfd, ieee_set_current_section_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
- ieee_write_byte(abfd, ieee_set_current_pc_enum >> 8);
- ieee_write_byte(abfd, ieee_set_current_pc_enum & 0xff);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
- ieee_write_int(abfd, s->vma );
-
- ieee_write_byte(abfd,ieee_repeat_data_enum);
- ieee_write_int(abfd, s->_raw_size);
- ieee_write_byte(abfd, ieee_load_constant_bytes_enum);
- ieee_write_byte(abfd, 1);
- ieee_write_byte(abfd, 0);
+ if (s->_raw_size) {
+ ieee_write_byte(abfd, ieee_set_current_section_enum);
+ ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
+ ieee_write_byte(abfd, ieee_set_current_pc_enum >> 8);
+ ieee_write_byte(abfd, ieee_set_current_pc_enum & 0xff);
+ ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
+ ieee_write_int(abfd, s->vma );
+
+ ieee_write_byte(abfd,ieee_repeat_data_enum);
+ ieee_write_int(abfd, s->_raw_size);
+ ieee_write_byte(abfd, ieee_load_constant_bytes_enum);
+ ieee_write_byte(abfd, 1);
+ ieee_write_byte(abfd, 0);
+ }
}
static void
p->value = reference_index;
reference_index++;
}
- else if(p->section == &bfd_com_section) {
+ else if (bfd_is_com_section (p->section)) {
/* This is a weak reference */
ieee_write_byte(abfd, ieee_external_reference_enum);
ieee_write_int(abfd, reference_index);
}
-CONST static unsigned char exten[] =
+static CONST unsigned char exten[] =
{
0xf0, 0x20, 0x00,
0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
};
-CONST static unsigned char envi[] =
+static CONST unsigned char envi[] =
{
0xf0, 0x21, 0x00,
ieee_write_byte(abfd, ieee_address_descriptor_enum);
/* Bits per MAU */
- ieee_write_byte(abfd, bfd_arch_bits_per_byte(abfd));
+ ieee_write_byte(abfd, (bfd_byte) (bfd_arch_bits_per_byte(abfd)));
/* MAU's per address */
- ieee_write_byte(abfd, bfd_arch_bits_per_address(abfd) /
- bfd_arch_bits_per_byte(abfd));
+ ieee_write_byte(abfd,
+ (bfd_byte) (bfd_arch_bits_per_address(abfd) / bfd_arch_bits_per_byte(abfd)));
old = bfd_tell(abfd);
bfd_seek(abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR);
for (i= 0; i < N_W_VARIABLES; i++) {
ieee_write_2bytes(abfd,ieee_assign_value_to_variable_enum);
- ieee_write_byte(abfd, i);
+ ieee_write_byte(abfd, (bfd_byte) i);
ieee_write_int5_out(abfd, ieee->w.offset[i]);
}
return true;
#define ieee_set_arch_mach bfd_default_set_arch_mach
#define ieee_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
#define ieee_bfd_relax_section bfd_generic_relax_section
+#define ieee_bfd_seclet_link bfd_generic_seclet_link
+#define ieee_bfd_reloc_type_lookup \
+ ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
+#define ieee_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
/*SUPPRESS 460 */
bfd_target ieee_vec =
{
' ', /* ar_pad_char */
16, /* ar_max_namelen */
1, /* minimum alignment */
-_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
-_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
+_do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16, /* data */
+_do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16, /* hdrs */
{ _bfd_dummy_target,
ieee_object_p, /* bfd_check_format */
_bfd_write_archive_contents,
bfd_false,
},
- JUMP_TABLE(ieee)
+ JUMP_TABLE(ieee),
+ (PTR) 0
};
+