token (which is one byte in this lexicon) lookahead recursive decent
parser. */
-#include <sysdep.h>
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
#include "ieee.h"
#include "libieee.h"
}
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)
{
- unsigned int plus_count = 0;
- if (value != 0)
- ieee_write_int(abfd, value);
+ unsigned int term_count = 0;
- if (section != (asection *)NULL) {
- 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->flags & BSF_UNDEFINED ) ||
- (symbol->flags & BSF_FORT_COMM)) {
- ieee_write_byte(abfd, ieee_variable_X_enum);
- ieee_write_int(abfd, symbol->value);
- }
- else if (symbol->flags & BSF_GLOBAL) {
+ if (symbol->section == &bfd_com_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, 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 (symbol->section != (asection *)NULL) {
- /* 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, 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, 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 void
-DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
+DEFUN(parse_expression,(ieee, value, symbol, pcrel, extra),
ieee_data_type *ieee AND
bfd_vma *value AND
- asection **section AND
ieee_symbol_index_type *symbol AND
boolean *pcrel AND
unsigned int *extra)
#define INC sp++;
#define DEC sp--;
+
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))]->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:
|| 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);
}
-
- POP(*symbol, *section, *value);
+ {
+ asection *dummy;
+
+ POP(*symbol, dummy, *value);
+ }
+
loop = false;
}
}
#define ieee_seek(abfd, offset) \
- ieee_data(abfd)->h.input_p = ieee_data(abfd)->h.first_byte + offset
+ IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
-#define ieee_pos(abfd) ieee_data(abfd)->h.input_p -ieee_data(abfd)->h.first_byte
+#define ieee_pos(abfd) IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte
static unsigned int last_index;
DEFUN(ieee_slurp_external_symbols,(abfd),
bfd *abfd)
{
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
file_ptr offset = ieee->w.r.external_part;
&symbol_ignore,
&pcrel_ignore,
&extra);
- if (symbol->symbol.section != (asection *)NULL) {
+
symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
- }
- else {
- symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT | BSF_ABSOLUTE;
- }
+
}
break;
case ieee_weak_external_reference_enum:
value = 0;
}
/* This turns into a common */
- symbol->symbol.flags = BSF_FORT_COMM;
+ symbol->symbol.section = &bfd_com_section;
symbol->symbol.value = size;
}
break;
symbol->symbol.the_bfd = abfd;
symbol->symbol.name = read_id(&(ieee->h));
symbol->symbol.udata = (PTR)NULL;
- symbol->symbol.section = (asection *)NULL;
+ symbol->symbol.section = &bfd_und_section;
symbol->symbol.value = (bfd_vma)0;
- symbol->symbol.flags = BSF_UNDEFINED;
+ symbol->symbol.flags = 0;
BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
break;
DEFUN(ieee_slurp_symbol_table,(abfd),
bfd *abfd)
{
- if (ieee_data(abfd)->read_symbols == false) {
+ if (IEEE_DATA(abfd)->read_symbols == false) {
ieee_slurp_external_symbols(abfd);
- ieee_data(abfd)->read_symbols= true;
+ IEEE_DATA(abfd)->read_symbols= true;
}
}
ieee_symbol_type *symp;
static bfd dummy_bfd;
static asymbol empty_symbol =
- { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING | BSF_ABSOLUTE};
+ { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING , &bfd_abs_section};
if (abfd->symcount) {
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
dummy_bfd.xvec= &ieee_vec;
ieee_slurp_symbol_table(abfd);
ieee->external_symbol_base_offset= - ieee->external_symbol_min_index;
- for (symp = ieee_data(abfd)->external_symbols;
+ for (symp = IEEE_DATA(abfd)->external_symbols;
symp != (ieee_symbol_type *)NULL;
symp = symp->next) {
/* Place into table at correct index locations */
ieee->external_reference_base_offset =
- ieee->external_reference_min_index +ieee->external_symbol_count ;
- for (symp = ieee_data(abfd)->external_reference;
+ for (symp = IEEE_DATA(abfd)->external_reference;
symp != (ieee_symbol_type *)NULL;
symp = symp->next) {
location[symp->index + ieee->external_reference_base_offset] =
DEFUN(ieee_slurp_sections,(abfd),
bfd *abfd)
{
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
file_ptr offset = ieee->w.r.section_part;
asection *section = (asection *)NULL;
switch (t) {
case ieee_section_size_enum:
section = ieee->section_table[must_parse_int(&(ieee->h))];
- section->size = must_parse_int(&(ieee->h));
+ section->_raw_size = must_parse_int(&(ieee->h));
break;
case ieee_physical_region_size_enum:
section = ieee->section_table[must_parse_int(&(ieee->h))];
- section->size = must_parse_int(&(ieee->h));
+ section->_raw_size = must_parse_int(&(ieee->h));
break;
case ieee_region_base_address_enum:
section = ieee->section_table[must_parse_int(&(ieee->h))];
uint8e_type buffer[512];
int buffer_offset = 0;
- ieee_ar_data_type *save = ieee_ar_data(abfd);
+ ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
ieee_ar_data_type *ieee ;
- set_tdata(abfd, bfd_alloc(abfd, sizeof(ieee_ar_data_type)));
- ieee= ieee_ar_data(abfd);
+ 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.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));
if (strcmp(library , "LIBRARY") != 0) {
bfd_release(abfd, ieee);
- set_tdata (abfd, save);
+ abfd->tdata.ieee_ar_data = save;
return (bfd_target *)NULL;
}
/* Throw away the filename */
DEFUN(ieee_mkobject,(abfd),
bfd *abfd)
{
- set_tdata (abfd, bfd_zalloc(abfd,sizeof(ieee_data_type)));
+abfd->tdata.ieee_data = (ieee_data_type *)bfd_zalloc(abfd,sizeof(ieee_data_type));
return true;
unsigned int part;
ieee_data_type *ieee;
uint8e_type buffer[300];
- ieee_data_type *save = ieee_data(abfd);
- set_tdata (abfd, 0);
+ ieee_data_type *save = IEEE_DATA(abfd);
+ abfd->tdata.ieee_data = 0;
ieee_mkobject(abfd);
- ieee = ieee_data(abfd);
+ ieee = IEEE_DATA(abfd);
/* Read the first few bytes in to see if it makes sense */
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
processor = ieee->mb.processor = read_id(&(ieee->h));
if (strcmp(processor,"LIBRARY") == 0) goto fail;
ieee->mb.module_name = read_id(&(ieee->h));
- if (abfd->filename == (char *)NULL) {
+ if (abfd->filename == (CONST char *)NULL) {
abfd->filename = ieee->mb.module_name;
}
/* Determine the architecture and machine type of the object file.
*/
{
- bfd_arch_info_struct_type *arch = bfd_scan_arch(processor);
+ bfd_arch_info_type *arch = bfd_scan_arch(processor);
if (arch == 0) goto fail;
abfd->arch_info = arch;
}
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 = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+ 50);
bfd_seek(abfd, 0, 0);
- bfd_read((PTR)(ieee_data(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd);
+ bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd);
ieee_slurp_sections(abfd);
return abfd->xvec;
fail:
(void) bfd_release(abfd, ieee);
- set_tdata (abfd, save);
+abfd->tdata.ieee_data = save;
return (bfd_target *)NULL;
}
bfd *ignore_abfd AND
PTR afile AND
asymbol *symbol AND
- bfd_print_symbol_enum_type how)
+ bfd_print_symbol_type how)
{
FILE *file = (FILE *)afile;
switch (how) {
- case bfd_print_symbol_name_enum:
+ case bfd_print_symbol_name:
fprintf(file,"%s", symbol->name);
break;
- case bfd_print_symbol_type_enum:
+ case bfd_print_symbol_more:
#if 0
fprintf(file,"%4x %2x",aout_symbol(symbol)->desc & 0xffff,
aout_symbol(symbol)->other & 0xff);
#endif
BFD_FAIL();
break;
- case bfd_print_symbol_all_enum:
+ case bfd_print_symbol_nm:
+ case bfd_print_symbol_all:
{
CONST char *section_name = symbol->section == (asection *)NULL ?
- "*abs" : symbol->section->name;
+ (CONST char *)"*abs" : symbol->section->name;
if (symbol->name[0] == ' ') {
fprintf(file,"* empty table entry ");
}
{
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();*/
+
parse_expression(ieee,
&r->relent.addend,
- &r->relent.section,
+ §ion,
&r->symbol,
&pcrel, &extra);
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));
bfd *abfd)
{
bfd_byte *location_ptr = (bfd_byte *)NULL;
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
unsigned int section_number ;
ieee_per_section_type *current_map = (ieee_per_section_type *)NULL;
for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
- per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->size);
+ per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->_raw_size);
/*SUPPRESS 68*/
per->reloc_tail_ptr =
(ieee_reloc_type **)&(s->relocation);
boolean pcrel;
next_byte(&(ieee->h));
must_parse_int(&(ieee->h)); /* Thow away section #*/
- parse_expression(ieee, &value, &dsection, &symbol,
+ parse_expression(ieee, &value,
+ &dsection,
+ &symbol,
&pcrel, &extra);
current_map->pc = value;
- BFD_ASSERT((unsigned)(value - s->vma) <= s->size);
+ BFD_ASSERT((unsigned)(value - s->vma) <= s->_raw_size);
}
break;
{
/* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
ieee_reloc_type *src = (ieee_reloc_type *)(section->relocation);
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
while (src != (ieee_reloc_type *)NULL) {
/* Work out which symbol to attach it this reloc to */
symbols + src->symbol.index + ieee->external_reference_base_offset;
break;
case 0:
- src->relent.sym_ptr_ptr = (asymbol **)NULL;
+ src->relent.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
break;
default:
DEFUN(ieee_write_section_part,(abfd),
bfd *abfd)
{
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
asection *s;
ieee->w.r.section_part = bfd_tell(abfd);
for (s = abfd->sections; s != (asection *)NULL; s=s->next) {
- ieee_write_byte(abfd, ieee_section_type_enum);
- ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+ if (s != &bfd_abs_section)
+ {
+
+ ieee_write_byte(abfd, ieee_section_type_enum);
+ ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
- if (abfd->flags & EXEC_P)
+ if (abfd->flags & EXEC_P)
{
/* This image is executable, so output absolute sections */
ieee_write_byte(abfd, ieee_variable_A_enum);
ieee_write_byte(abfd, ieee_variable_S_enum);
}
- else
+ else
{
ieee_write_byte(abfd, ieee_variable_C_enum);
}
- switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM))
+ switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM))
{
case SEC_CODE | SEC_LOAD:
case SEC_CODE:
}
- ieee_write_id(abfd, s->name);
+ ieee_write_id(abfd, s->name);
#if 0
- ieee_write_int(abfd, 0); /* Parent */
- ieee_write_int(abfd, 0); /* Brother */
- ieee_write_int(abfd, 0); /* Context */
+ ieee_write_int(abfd, 0); /* Parent */
+ ieee_write_int(abfd, 0); /* Brother */
+ ieee_write_int(abfd, 0); /* Context */
#endif
- /* Alignment */
- ieee_write_byte(abfd, ieee_section_alignment_enum);
- ieee_write_byte(abfd, 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->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_int(abfd, s->vma);
+ /* Alignment */
+ ieee_write_byte(abfd, ieee_section_alignment_enum);
+ ieee_write_byte(abfd, 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->_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_int(abfd, s->vma);
+ }
+ }
+
}
-
- }
}
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_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->size) {
+ while (current_byte_index < s->_raw_size) {
bfd_size_type run;
unsigned int MAXRUN = 32;
run = MAXRUN;
- if (run > s->size - current_byte_index) {
- run = s->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->size));
- memset((PTR)stream, 0, s->size);
+ stream = (uint8e_type *)(bfd_alloc(abfd, s->_raw_size));
+ memset((PTR)stream, 0, s->_raw_size);
}
- while (current_byte_index < s->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->size - current_byte_index) {
- run = s->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();
+
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);
}
ieee_write_int(abfd, s->vma );
ieee_write_byte(abfd,ieee_repeat_data_enum);
- ieee_write_int(abfd, s->size);
+ 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);
else
{
unsigned int i;
- for (i = 0; i < s->size; i++) {
+ for (i = 0; i < s->_raw_size; i++) {
if (stream[i] != 0) {
do_with_relocs(abfd, s);
return;
section_number = THIS();
NEXT();
- ieee= ieee_data(input_bfd);
+ ieee= IEEE_DATA(input_bfd);
s = ieee->section_table[section_number];
if (s->output_section) {
value = s->output_section->vma ;
DEFUN(ieee_write_debug_part, (abfd),
bfd *abfd)
{
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
bfd_chain_type *chain = ieee->chain_root;
unsigned char output_buffer[OBS];
boolean some_debug = false;
output_bfd = abfd;
if (chain == (bfd_chain_type *)NULL) {
- /* There is no debug info, so we'll fake some up */
- CONST static char fake[] = {
- 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
- '1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
- ieee->w.r.debug_information_part = 0;
-
#if 0
-here;
+ /* There is no debug info, so we'll fake some up */
+ CONST static char fake[] = {
+ 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
+ '1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
+ ieee->w.r.debug_information_part = 0;
-/* bfd_write(fake, 1, sizeof(fake), abfd);*/
- /* Now write a header for each section */
- {
- int i = 0;
- asection *s = abfd->sections;
- while (s) {
- ieee_write_byte(abfd, 0xf8);
- ieee_write_byte(abfd, 0x0b);
- ieee_write_byte(abfd, 0);
- 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_byte(abfd,0);
- ieee_write_byte(abfd, 0xf9);
- ieee_write_expression(abfd, s->size, 0, 0, 0, 0);
+ here;
+
+
+ /* bfd_write(fake, 1, sizeof(fake), abfd);*/
+ /* Now write a header for each section */
+ {
+ int i = 0;
+ asection *s = abfd->sections;
+ while (s) {
+ if (s != abfd->abs_section)
+ {
+
+ ieee_write_byte(abfd, 0xf8);
+ ieee_write_byte(abfd, 0x0b);
+ ieee_write_byte(abfd, 0);
+ 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->symbol, 0, 0, 0);
+ ieee_write_byte(abfd,0);
+ ieee_write_byte(abfd, 0xf9);
+ ieee_write_expression(abfd, s->size,
+ bfd_abs_section.symbol, 0, 0, 0);
+ i++;
+ }
+
s = s->next;
- i++;
+
}
- /* Close the scope */
- ieee_write_byte(abfd, 0xf9);
- }
+ /* Close the scope */
+ ieee_write_byte(abfd, 0xf9);
+ }
#endif
- }
+ }
else{
- while (chain != (bfd_chain_type *)NULL) {
- bfd *entry = chain->this;
- ieee_data_type *entry_ieee = ieee_data(entry);
- if (entry_ieee->w.r.debug_information_part) {
- bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
- relocate_debug(abfd, entry);
- }
+ while (chain != (bfd_chain_type *)NULL) {
+ bfd *entry = chain->this;
+ ieee_data_type *entry_ieee = IEEE_DATA(entry);
+ if (entry_ieee->w.r.debug_information_part) {
+ bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
+ relocate_debug(abfd, entry);
+ }
- chain = chain->next;
- }
- if (some_debug) {
- ieee->w.r.debug_information_part = here;
- }
- else {
- ieee->w.r.debug_information_part = 0;
+ chain = chain->next;
+ }
+ if (some_debug) {
+ ieee->w.r.debug_information_part = here;
+ }
+ else {
+ ieee->w.r.debug_information_part = 0;
+ }
}
- }
flush();
}
bfd *abfd)
{
asection *s;
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
ieee->w.r.data_part = bfd_tell(abfd);
for (s = abfd->sections; s != (asection *)NULL; s = s->next)
{
{
asection *s;
for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
- if (s->size != 0) {
- ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->size));
+ if (s->_raw_size != 0) {
+ ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->_raw_size));
}
}
}
bfd *abfd)
{
asymbol **q;
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
unsigned int reference_index = IEEE_REFERENCE_BASE;
unsigned int public_index = IEEE_PUBLIC_BASE+2;
for (q = abfd->outsymbols; *q != (asymbol *)NULL; q++) {
asymbol *p = *q;
hadone = true;
- if (p->flags & BSF_UNDEFINED) {
+ if (p->section == &bfd_und_section) {
/* This must be a symbol reference .. */
ieee_write_byte(abfd, ieee_external_reference_enum);
ieee_write_int(abfd, reference_index);
p->value = reference_index;
reference_index++;
}
- else if(p->flags & BSF_FORT_COMM) {
+ else if(p->section == &bfd_com_section) {
/* This is a weak reference */
ieee_write_byte(abfd, ieee_external_reference_enum);
ieee_write_int(abfd, reference_index);
/* Write out the value */
ieee_write_2bytes(abfd, ieee_value_record_enum);
ieee_write_int(abfd, public_index);
- if (p->section != (asection *)NULL)
+ if (p->section != &bfd_abs_section)
{
if (abfd->flags & EXEC_P)
- {
- /* If fully linked, then output all symbols
- relocated */
- ieee_write_int(abfd,
- p->value + p->section->output_offset+ p->section->output_section->vma);
+ {
+ /* If fully linked, then output all symbols
+ relocated */
+ ieee_write_int(abfd,
+ p->value + p->section->output_offset+ p->section->output_section->vma);
- }
- else {
- ieee_write_expression(abfd,
- p->value + p->section->output_offset,
- p->section->output_section,
- (asymbol *)NULL, false, 0);
}
+ else {
+ ieee_write_expression(abfd,
+ p->value + p->section->output_offset,
+ 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[] =
+CONST static 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 environ[] =
+CONST static unsigned char envi[] =
{
0xf0, 0x21, 0x00,
DEFUN(ieee_write_me_part,(abfd),
bfd *abfd)
{
- ieee_data_type *ieee= ieee_data(abfd);
+ ieee_data_type *ieee= IEEE_DATA(abfd);
ieee->w.r.trailer_part = bfd_tell(abfd);
if (abfd->start_address) {
ieee->w.r.me_record = bfd_tell(abfd);
DEFUN(ieee_write_object_contents,(abfd),
bfd *abfd)
{
- ieee_data_type *ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(abfd);
unsigned int i;
file_ptr old;
/* Fast forward over the header area */
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(environ, 1, sizeof(environ), abfd);
+ bfd_write((char *)envi, 1, sizeof(envi), abfd);
output_bfd = abfd;
flush();
bfd *arch AND
bfd *prev)
{
- ieee_ar_data_type *ar = ieee_ar_data(arch);
+ ieee_ar_data_type *ar = IEEE_AR_DATA(arch);
/* take the next one from the arch state, or reset */
if (prev == (bfd *)NULL) {
/* Reset the index - the first two entries are bogus*/
bfd *abfd;
struct stat *buf;
{
- ieee_ar_data_type *ar = ieee_ar_data(abfd);
+ ieee_ar_data_type *ar = IEEE_AR_DATA(abfd);
if (ar == (ieee_ar_data_type *)NULL) {
bfd_error = invalid_operation;
return -1;
bfd *abfd AND
asection *section)
{
- ieee_data_type *ieee = ieee_data(section->owner);
- ieee_data_type *output_ieee = ieee_data(abfd);
+ ieee_data_type *ieee = IEEE_DATA(section->owner);
+ ieee_data_type *output_ieee = IEEE_DATA(abfd);
/* can only accumulate data from other ieee bfds */
if (section->owner->xvec != abfd->xvec)
return;
#define ieee_slurp_armap bfd_true
#define ieee_slurp_extended_name_table bfd_true
#define ieee_truncate_arname (void (*)())bfd_nullvoidptr
-#define ieee_write_armap (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, int, int))) bfd_nullvoidptr
+#define ieee_write_armap (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, unsigned int, int))) bfd_nullvoidptr
#define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
#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
/*SUPPRESS 460 */
bfd_target ieee_vec =
{
"ieee", /* name */
- bfd_target_ieee_flavour_enum,
+ bfd_target_ieee_flavour,
true, /* target byte order */
true, /* target headers byte order */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
- (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
+ ( SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
' ', /* ar_pad_char */
16, /* ar_max_namelen */