-/* bfd back-end for ieee-695 objects.
- Copyright (C) 1990-1991 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 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
parser. */
#include "ieee.h"
#include "libieee.h"
+
+#include "obstack.h"
+#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
standard requires. */
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();
}
static void
-DEFUN(ieee_write_expression,(abfd, value,/* section,*/ symbol, pcrel, index),
+DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
bfd*abfd AND
bfd_vma value AND
-/* asection *section AND*/
asymbol *symbol AND
boolean pcrel AND
unsigned int index)
{
- asection *section;
-
- unsigned int plus_count = 0;
- if (value != 0)
- ieee_write_int(abfd, value);
+ unsigned int term_count = 0;
- if (section != &bfd_abs_section) {
- plus_count++;
- ieee_write_byte(abfd, ieee_variable_R_enum);
- ieee_write_byte(abfd, section->index +IEEE_SECTION_NUMBER_BASE);
+ if (value != 0)
+ {
+ ieee_write_int(abfd, value);
+ term_count++;
}
+
+
-
-
- if (symbol != (asymbol *)NULL) {
- plus_count++;
- if ((symbol->section == &bfd_und_section) ||
- (symbol->section == &bfd_com_section)) {
- ieee_write_byte(abfd, ieee_variable_X_enum);
- ieee_write_int(abfd, symbol->value);
- }
- else if (symbol->flags & BSF_GLOBAL) {
+ if (bfd_is_com_section (symbol->section)
+ || symbol->section == &bfd_und_section)
+ {
+ /* Def of a common symbol */
+ ieee_write_byte(abfd, ieee_variable_X_enum);
+ ieee_write_int(abfd, symbol->value);
+ term_count++;
+ }
+ else if (symbol->section != &bfd_abs_section)
+ {
+ /* Ref to defined symbol - */
+
+ ieee_write_byte(abfd, ieee_variable_R_enum);
+ ieee_write_byte(abfd,
+ (bfd_byte) (symbol->section->index + IEEE_SECTION_NUMBER_BASE));
+ term_count++;
+ if (symbol->flags & BSF_GLOBAL)
+ {
ieee_write_byte(abfd, ieee_variable_I_enum);
ieee_write_int(abfd, symbol->value);
+ term_count++;
}
- else if (symbol->flags & BSF_LOCAL) {
+ else if (symbol->flags & ( BSF_LOCAL | BSF_SECTION_SYM))
+ {
/* This is a reference to a defined local symbol,
We can easily do a local as a section+offset */
- if (bfd_symbol_is_absolute(symbol) == false) {
- /* If this symbol is not absolute, add the base of it */
- ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
- ieee_write_byte(abfd, symbol->section->index +
- IEEE_SECTION_NUMBER_BASE);
- plus_count++;
- }
-
+ ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
+ ieee_write_byte(abfd,
+ (bfd_byte)(symbol->section->index + IEEE_SECTION_NUMBER_BASE));
ieee_write_int(abfd, symbol->value);
- }
- else {
+ term_count++;
- BFD_FAIL();
}
+ else {
+ BFD_FAIL();
+ }
+
}
+
+
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, ieee_function_minus_enum);
+ /* subtract the pc from here by asking for PC of this section*/
+ ieee_write_byte(abfd, ieee_variable_P_enum);
+ ieee_write_byte(abfd, (bfd_byte)(index+IEEE_SECTION_NUMBER_BASE));
+ ieee_write_byte(abfd, ieee_function_minus_enum);
+ }
+
+ if (term_count == 1)
+ {
+ ieee_write_byte(abfd,0);
}
+ else {
+ while (term_count > 1) {
+ ieee_write_byte(abfd, ieee_function_plus_enum);
+ term_count--;
+ }
- if (value != 0){
- while (plus_count > 0) {
- ieee_write_byte(abfd, ieee_function_plus_enum);
- plus_count--;
}
- }
- else {
- if (!plus_count)
- ieee_write_byte(abfd,0);
- }
}
-
/*****************************************************************************/
/*
static
reloc_howto_type rel32_howto
- = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff, 0xffffffff,true);
+ = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff,
+ 0xffffffff,false);
+
static
reloc_howto_type rel16_howto
- = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,true);
+ = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,false);
static
reloc_howto_type rel8_howto
- = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,true);
+ = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,false);
static ieee_symbol_index_type NOSYMBOL = { 0, 0};
static void
-DEFUN(parse_expression,(ieee, value,/* section,*/ symbol, pcrel, extra),
+DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra, section),
ieee_data_type *ieee AND
bfd_vma *value AND
-/* asection **section AND*/
ieee_symbol_index_type *symbol AND
boolean *pcrel AND
- unsigned int *extra)
+ unsigned int *extra AND
+ asection **section)
{
#define POS sp[1]
#define NOS sp[-1]
#define INC sp++;
#define DEC sp--;
- asection **section;
+
boolean loop = true;
ieee_value_type stack[10];
next_byte(&(ieee->h));
*pcrel = true;
section_n = must_parse_int(&(ieee->h));
- PUSH(NOSYMBOL, 0,
+ PUSH(NOSYMBOL, &bfd_abs_section,
TOS.value = ieee->section_table[section_n]->vma +
ieee_per_section(ieee->section_table[section_n])->pc);
break;
next_byte(&(ieee->h));
PUSH(NOSYMBOL,
0,
- ieee->section_table[must_parse_int(&(ieee->h))]->_cooked_size);
+ ieee->section_table[must_parse_int(&(ieee->h))]->_raw_size);
break;
case ieee_variable_I_enum:
case ieee_variable_X_enum:
sy.index = (int)(must_parse_int(&(ieee->h))) ;
sy.letter = 'X';
- PUSH(sy, 0, 0);
+ PUSH(sy, &bfd_und_section, 0);
}
break;
case ieee_function_minus_enum:
POP(sy1, section1, value1);
POP(sy2, section2, value2);
- PUSH(sy1.letter ? sy1 : sy2, section1 ? section1: section2, value1+value2);
+ PUSH(sy1.letter ? sy1 : sy2, section1!=&bfd_abs_section ? section1: section2, value1+value2);
}
break;
default:
|| this_byte(&(ieee->h)) > (int)ieee_variable_Z_enum);
if (parse_int(&(ieee->h), &va))
{
- PUSH(NOSYMBOL,0, va);
+ PUSH(NOSYMBOL, &bfd_abs_section, va);
}
else {
/*
ieee_symbol_index_type sy1;
POP(sy1, section1, *extra);
}
+ {
+ asection *dummy;
- POP(*symbol, *section, *value);
+ POP(*symbol, dummy, *value);
+ if (section) *section = dummy;
+ }
+
loop = false;
}
}
#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_name_index = must_parse_int(&(ieee->h));
parse_expression(ieee,
&symbol->symbol.value,
-/* &symbol->symbol.section,*/
&symbol_ignore,
&pcrel_ignore,
- &extra);
+ &extra,
+ &symbol->symbol.section);
symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
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 };
+ /* the_bfd, name, value, attr, section */
+ { &dummy_bfd, " ieee empty", (symvalue)0, BSF_DEBUGGING, &bfd_abs_section};
-if (abfd->symcount) {
+ if (abfd->symcount)
+{
+ ieee_data_type *ieee = IEEE_DATA(abfd);
+ dummy_bfd.xvec= &ieee_vec;
+ ieee_slurp_symbol_table(abfd);
+ if (ieee->symbol_table_full == false) {
+ /* Arrgh - there are gaps in the table, run through and fill them */
+ /* up with pointers to a null place */
+ unsigned int i;
+ for (i= 0; i < abfd->symcount; i++) {
+ location[i] = &empty_symbol;
+ }
+ }
+ ieee->external_symbol_base_offset= - ieee->external_symbol_min_index;
+ for (symp = IEEE_DATA(abfd)->external_symbols;
+ symp != (ieee_symbol_type *)NULL;
+ symp = symp->next) {
+ /* Place into table at correct index locations */
+ location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
- ieee_data_type *ieee = IEEE_DATA(abfd);
- dummy_bfd.xvec= &ieee_vec;
- ieee_slurp_symbol_table(abfd);
-
- if (ieee->symbol_table_full == false) {
- /* Arrgh - there are gaps in the table, run through and fill them */
- /* up with pointers to a null place */
- unsigned int i;
- for (i= 0; i < abfd->symcount; i++) {
- location[i] = &empty_symbol;
}
- }
+ /* The external refs are indexed in a bit */
+ ieee->external_reference_base_offset =
+ - ieee->external_reference_min_index +ieee->external_symbol_count ;
- ieee->external_symbol_base_offset= - ieee->external_symbol_min_index;
- for (symp = IEEE_DATA(abfd)->external_symbols;
- symp != (ieee_symbol_type *)NULL;
- symp = symp->next) {
- /* Place into table at correct index locations */
- location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
+ for (symp = IEEE_DATA(abfd)->external_reference;
+ symp != (ieee_symbol_type *)NULL;
+ symp = symp->next) {
+ location[symp->index + ieee->external_reference_base_offset] =
+ &symp->symbol;
- }
-
- /* The external refs are indexed in a bit */
- ieee->external_reference_base_offset =
- - ieee->external_reference_min_index +ieee->external_symbol_count ;
+ }
- for (symp = IEEE_DATA(abfd)->external_reference;
- symp != (ieee_symbol_type *)NULL;
- symp = symp->next) {
- location[symp->index + ieee->external_reference_base_offset] =
- &symp->symbol;
- }
-
- 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];
-
- int buffer_offset = 0;
- ieee_ar_data_type *save = IEEE_AR_DATA(abfd);
+ unsigned char buffer[512];
+ struct obstack ob;
+ file_ptr buffer_offset = 0;
+ ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
ieee_ar_data_type *ieee ;
abfd->tdata.ieee_ar_data = (ieee_ar_data_type *)bfd_alloc(abfd, sizeof(ieee_ar_data_type));
ieee= IEEE_AR_DATA(abfd);
+
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.abfd = abfd;
- if (this_byte(&(ieee->h)) != Module_Beginning) return (bfd_target*)NULL;
+ if (this_byte(&(ieee->h)) != Module_Beginning) {
+ abfd->tdata.ieee_ar_data = save;
+ return (bfd_target*)NULL;
+ }
+
next_byte(&(ieee->h));
library= read_id(&(ieee->h));
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 */
+
+ obstack_begin(&ob, 128);
+
+
ieee->element_count = 0;
ieee->element_index = 0;
t.file_offset = must_parse_int(&(ieee->h));
t.abfd = (bfd *)NULL;
ieee->element_count++;
- bfd_alloc_grow(abfd, (PTR)&t, sizeof(t));
+
+ obstack_grow(&ob, (PTR)&t, sizeof(t));
/* Make sure that we don't go over the end of the buffer */
else loop = false;
}
- ieee->elements = (ieee_ar_obstack_type *)bfd_alloc_finish(abfd);
+ ieee->elements = (ieee_ar_obstack_type *)obstack_finish(&ob);
/* Now scan the area again, and replace BB offsets with file */
/* offsets */
}
}
+/* 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);
- ieee = IEEE_DATA(abfd);
+ ieee = IEEE_DATA(abfd);
+ bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
/* Read the first few bytes in to see if it makes sense */
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
}
abfd->flags = HAS_SYMS;
-
/* By now we know that this is a real IEEE file, we're going to read
the whole thing into memory so that we can run up and down it
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, 0, 0);
+ 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);
ieee_slurp_sections(abfd);
return (bfd_target *)NULL;
}
+void
+DEFUN(ieee_get_symbol_info,(ignore_abfd, symbol, ret),
+ bfd *ignore_abfd AND
+ asymbol *symbol AND
+ symbol_info *ret)
+{
+ bfd_symbol_info (symbol, ret);
+ if (symbol->name[0] == ' ')
+ ret->name = "* empty table entry ";
+ if (!symbol->section)
+ ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
+}
void
DEFUN(ieee_print_symbol,(ignore_abfd, afile, symbol, how),
#endif
BFD_FAIL();
break;
- case bfd_print_symbol_nm:
case bfd_print_symbol_all:
{
CONST char *section_name = symbol->section == (asection *)NULL ?
DEFUN(do_one,(ieee, current_map, location_ptr,s),
ieee_data_type *ieee AND
ieee_per_section_type *current_map AND
- uint8e_type *location_ptr AND
+ unsigned char *location_ptr AND
asection *s)
{
switch (this_byte(&(ieee->h)))
{
unsigned int extra = 4;
boolean pcrel = false;
-
+asection *section;
ieee_reloc_type *r =
(ieee_reloc_type *) bfd_alloc(ieee->h.abfd,
sizeof(ieee_reloc_type));
current_map->reloc_tail_ptr= &r->next;
r->next = (ieee_reloc_type *)NULL;
next_byte(&(ieee->h));
- abort();
-
+/* abort();*/
+ r->relent.sym_ptr_ptr = 0;
parse_expression(ieee,
&r->relent.addend,
-/* &r->relent.section,*/
&r->symbol,
- &pcrel, &extra);
+ &pcrel, &extra, §ion);
r->relent.address = current_map->pc;
s->reloc_count++;
+if (r->relent.sym_ptr_ptr == 0) {
+ r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
+}
if (this_byte(&(ieee->h)) == (int)ieee_comma) {
next_byte(&(ieee->h));
case ieee_set_current_pc_enum & 0xff:
{
bfd_vma value;
- asection *dsection;
ieee_symbol_index_type symbol;
unsigned int extra;
boolean pcrel;
next_byte(&(ieee->h));
must_parse_int(&(ieee->h)); /* Thow away section #*/
parse_expression(ieee, &value,
-/* &dsection, */
-&symbol,
- &pcrel, &extra);
+ &symbol,
+ &pcrel, &extra,
+ 0);
current_map->pc = value;
BFD_ASSERT((unsigned)(value - s->vma) <= s->_raw_size);
}
*/
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 = (asymbol **)NULL;
+ 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_int(abfd, s->_cooked_size);
+ 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_expression(abfd, 0,/* s,!!!!*/ 0, 0, 0);
+ 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 there arn't any relocations then output the load constant byte
opcode rather than the load with relocation opcode */
- while (current_byte_index < s->_cooked_size) {
+ while (current_byte_index < s->_raw_size) {
bfd_size_type run;
unsigned int MAXRUN = 32;
run = MAXRUN;
- if (run > s->_cooked_size - current_byte_index) {
- run = s->_cooked_size - current_byte_index;
+ if (run > s->_raw_size - current_byte_index) {
+ run = s->_raw_size - current_byte_index;
}
if (run != 0) {
if ((PTR)stream == (PTR)NULL) {
/* Outputting a section without data, fill it up */
- stream = (uint8e_type *)(bfd_alloc(abfd, s->_cooked_size));
- memset((PTR)stream, 0, s->_cooked_size);
+ stream = (unsigned char *)(bfd_alloc(abfd, s->_raw_size));
+ memset((PTR)stream, 0, s->_raw_size);
}
- while (current_byte_index < s->_cooked_size) {
+ while (current_byte_index < s->_raw_size) {
bfd_size_type run;
unsigned int MAXRUN = 32;
if (relocs_to_go) {
else {
run = MAXRUN;
}
- if (run > s->_cooked_size - current_byte_index) {
- run = s->_cooked_size - current_byte_index;
+ if (run > s->_raw_size - current_byte_index) {
+ run = s->_raw_size - current_byte_index;
}
if (run != 0) {
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,
-/* !!! r->section,*/
*(r->sym_ptr_ptr),
r->howto->pc_relative, s->index);
}
else {
ieee_write_expression(abfd, r->addend + ov,
-/*!!! r->section,*/
(asymbol *)NULL,
r->howto->pc_relative, s->index);
}
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->_cooked_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
else
{
unsigned int i;
- for (i = 0; i < s->_cooked_size; i++) {
+ for (i = 0; i < s->_raw_size; i++) {
if (stream[i] != 0) {
do_with_relocs(abfd, s);
return;
ieee_write_byte(abfd, 0);
ieee_write_byte(abfd, 1);
ieee_write_byte(abfd, i + IEEE_SECTION_NUMBER_BASE);
- ieee_write_expression(abfd, 0, s, 0, 0, 0);
+ ieee_write_expression(abfd, 0, s->symbol, 0, 0, 0);
ieee_write_byte(abfd,0);
ieee_write_byte(abfd, 0xf9);
- ieee_write_expression(abfd, s->size, 0, 0, 0, 0);
+ ieee_write_expression(abfd, s->size,
+ bfd_abs_section.symbol, 0, 0, 0);
i++;
}
{
asection *s;
for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
- if (s->_cooked_size != 0) {
- ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->_cooked_size));
+ if (s->_raw_size != 0) {
+ ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->_raw_size));
}
}
}
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);
else {
ieee_write_expression(abfd,
p->value + p->section->output_offset,
-/*!!! p->section->output_section,*/
- (asymbol *)NULL, false, 0);
+ p->section->output_section->symbol
+ , false, 0);
}
}
else
{
ieee_write_expression(abfd,
p->value,
-/*!!! (asection *)NULL,*/
- (asymbol *)NULL, false, 0);
+ bfd_abs_section.symbol,
+ false, 0);
}
p->value = public_index;
public_index++;
}
-CONST static 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 char envi[] =
+static CONST unsigned char envi[] =
{
0xf0, 0x21, 0x00,
unsigned int i;
file_ptr old;
/* Fast forward over the header area */
- bfd_seek(abfd, 0, 0);
+ bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
ieee_write_byte(abfd, ieee_module_beginning_enum);
ieee_write_id(abfd, bfd_printable_name(abfd));
ieee_write_id(abfd, abfd->filename);
-
-
-
/* Fast forward over the variable bits */
-
-
-
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, 8 * N_W_VARIABLES, 1);
-
+ bfd_seek(abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR);
ieee->w.r.extension_record = bfd_tell(abfd);
- bfd_write(exten, 1, sizeof(exten), abfd);
+ bfd_write((char *)exten, 1, sizeof(exten), abfd);
if (abfd->flags & EXEC_P)
ieee_write_byte(abfd, 0x1); /* Absolute */
else
ieee_write_byte(abfd, 0x2); /* Relocateable */
ieee->w.r.environmental_record = bfd_tell(abfd);
- bfd_write(envi, 1, sizeof(envi), abfd);
+ bfd_write((char *)envi, 1, sizeof(envi), abfd);
output_bfd = abfd;
flush();
/* Generate the header */
- bfd_seek(abfd, old, false);
+ bfd_seek(abfd, old, SEEK_SET);
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;
bfd *abfd;
struct stat *buf;
{
- ieee_ar_data_type *ar = IEEE_AR_DATA(abfd);
+ ieee_ar_data_type *ar = abfd->my_archive->tdata.ieee_ar_data;
if (ar == (ieee_ar_data_type *)NULL) {
bfd_error = invalid_operation;
return -1;
else {
buf->st_size = 0x1;
buf->st_mode = 0666;
- return 0;
+ return ! ieee_object_p(abfd);
}
}
static int
#define ieee_close_and_cleanup bfd_generic_close_and_cleanup
#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 =
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
( SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ 0, /* leading underscore */
' ', /* 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
};
+