aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorSteve Chamberlain <steve@cygnus>1991-04-08 23:26:05 +0000
committerSteve Chamberlain <steve@cygnus>1991-04-08 23:26:05 +0000
commitde7c1ff6139ecad81cf4ada557330ae0b3c7b5a6 (patch)
tree4821c5ee175cf0c70b0d20b6dab9276d74680a96 /bfd
parentad19c0a2d1d72cbee89680aa95d94b35a2a8eb3d (diff)
downloadfsf-binutils-gdb-de7c1ff6139ecad81cf4ada557330ae0b3c7b5a6.zip
fsf-binutils-gdb-de7c1ff6139ecad81cf4ada557330ae0b3c7b5a6.tar.gz
fsf-binutils-gdb-de7c1ff6139ecad81cf4ada557330ae0b3c7b5a6.tar.bz2
*** empty log message ***
Diffstat (limited to 'bfd')
-rwxr-xr-xbfd/coff-code.h16
-rw-r--r--bfd/oasys.c221
-rw-r--r--bfd/targets.c2
3 files changed, 143 insertions, 96 deletions
diff --git a/bfd/coff-code.h b/bfd/coff-code.h
index 2c1e289..df3d8a6 100755
--- a/bfd/coff-code.h
+++ b/bfd/coff-code.h
@@ -357,6 +357,13 @@ coff_real_object_p(abfd, nscns, opthdr)
abfd->obj_machine = 68020;
break;
#endif
+#ifdef MC88MAGIC
+ case MC88MAGIC:
+ case MC88DMAGIC:
+ abfd->obj_arch = bfd_arch_m88k;
+ abfd->obj_machine = 88100;
+ break;
+#endif
#ifdef I960ROMAGIC
case I960ROMAGIC:
case I960RWMAGIC:
@@ -1126,9 +1133,9 @@ coff_set_flags(abfd, magicp, flagsp)
*magicp = MC68MAGIC;
return true;
#endif
-#if M88DMAGIC
+#ifdef M88MAGIC
case bfd_arch_m88k:
- *magicp = MC88DMAGIC;
+ *magicp = MC88MAGIC;
return true;
break;
#endif
@@ -1711,7 +1718,7 @@ get_normalized_symtab(abfd)
}
else {
if ((((AUXENT *) (retval + 1))->x_file.x_n.x_offset
- = (int) malloc(namelength)) == NULL) {
+ = (int) malloc(namelength+1)) == NULL) {
bfd_error = no_memory;
return (NULL);
} /* on error */
@@ -1740,7 +1747,6 @@ get_normalized_symtab(abfd)
/* ...and normalize symbol names. */
for (s = retval + obj_symbol_slew(abfd); s < end; ++s) {
-
if (s->n_zeroes != 0) {
/*
This is a "short" name. Make it long.
@@ -1763,7 +1769,7 @@ get_normalized_symtab(abfd)
return (NULL);
} /* on error */
bzero(newstring, i);
- strncpy(newstring, s->n_name, 8);
+ strncpy(newstring, s->n_name, i -1 );
s->n_offset = (int) newstring;
s->n_zeroes = 0;
diff --git a/bfd/oasys.c b/bfd/oasys.c
index ff6ce54..4d57116 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -1,3 +1,4 @@
+/*#define UNDERSCORE_HACK 0*/
/*
bfd backend for oasys objects.
@@ -90,7 +91,13 @@ bfd *abfd;
/* Buy enough memory for all the symbols and all the names */
data->symbols =
(asymbol *)malloc(sizeof(asymbol) * abfd->symcount);
+#ifdef UNDERSCORE_HACK
+ /* buy 1 more char for each symbol to keep the underscore in*/
+ data->strings = malloc(data->symbol_string_length +
+ abfd->symcount);
+#else
data->strings = malloc(data->symbol_string_length);
+#endif
dest_undefined = data->symbols;
dest_defined = data->symbols + abfd->symcount -1;
@@ -98,6 +105,7 @@ bfd *abfd;
string_ptr = data->strings;
bfd_seek(abfd, (file_ptr)0, SEEK_SET);
while (loop) {
+
oasys_read_record(abfd, &record);
switch (record.header.type) {
case oasys_record_is_header_enum:
@@ -105,12 +113,16 @@ bfd *abfd;
case oasys_record_is_local_enum:
case oasys_record_is_symbol_enum:
{
+int flag = record.header.type == oasys_record_is_local_enum ?
+ (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
+
+
size_t length = oasys_string_length(&record);
switch (record.symbol.relb[0] & RELOCATION_TYPE_BITS) {
case RELOCATION_TYPE_ABS:
dest = dest_defined--;
dest->section = 0;
- dest->flags = BSF_ABSOLUTE | BSF_EXPORT | BSF_GLOBAL;
+ dest->flags = BSF_ABSOLUTE | flag;
break;
case RELOCATION_TYPE_REL:
dest = dest_defined--;
@@ -119,11 +131,11 @@ bfd *abfd;
RELOCATION_SECT_BITS];
if (record.header.type == oasys_record_is_local_enum)
{
- dest->flags = BSF_LOCAL;
+ dest->flags = BSF_LOCAL;
}
else {
- dest->flags = BSF_EXPORT | BSF_GLOBAL;
+ dest->flags = flag;
}
break;
case RELOCATION_TYPE_UND:
@@ -142,9 +154,15 @@ bfd *abfd;
}
dest->name = string_ptr;
dest->the_bfd = abfd;
-
+ dest->udata = (void *)NULL;
dest->value = bfd_h_getlong(abfd, &record.symbol.value);
+#if UNDERSCORE_HACK
+ string_ptr[0] = '_';
+ string_ptr++;
+#endif
memcpy(string_ptr, record.symbol.name, length);
+
+
string_ptr[length] =0;
string_ptr += length +1;
}
@@ -163,8 +181,7 @@ bfd *abfd;
{
oasys_slurp_symbol_table (abfd);
- return (abfd->symcount != 0) ?
- (abfd->symcount+1) * (sizeof (oasys_symbol_type *)) : 0;
+ return (abfd->symcount+1) * (sizeof (oasys_symbol_type *));
}
/*
@@ -289,10 +306,12 @@ bfd *abfd;
/* Inspect the records, but only keep the section info -
remember the size of the symbols
*/
+ static_data.first_data_record = 0;
while (loop) {
+
oasys_record_union_type record;
oasys_read_record(abfd, &record);
- if (record.header.length < sizeof(record.header))
+ if (record.header.length < sizeof(record.header))
return (bfd_target *)NULL;
switch ((oasys_record_enum_type)(record.header.type)) {
@@ -429,6 +448,7 @@ bfd *abfd;
per->reloc_tail_ptr = (oasys_reloc_type **)&(s->relocation);
}
+ if (data->first_data_record == 0) return true;
bfd_seek(abfd, data->first_data_record, SEEK_SET);
while (loop) {
oasys_read_record(abfd, &record);
@@ -436,93 +456,112 @@ bfd *abfd;
case oasys_record_is_header_enum:
break;
case oasys_record_is_data_enum:
- {
+ {
- uint8e_type *src = record.data.data;
- uint8e_type *end_src = ((uint8e_type *)&record) + record.header.length;
- unsigned int relbit;
- bfd_byte *dst_ptr ;
- bfd_byte *dst_base_ptr ;
- asection *section;
- unsigned int count;
-
- bfd_vma dst_offset = bfd_h_getlong(abfd, record.data.addr);
- section = data->sections[record.data.relb & RELOCATION_SECT_BITS];
- per = oasys_per_section(section);
-dst_base_ptr = dst_ptr = oasys_per_section(section)->data + dst_offset;
-
- while (src < end_src) {
- uint8e_type mod_byte = *src++;
- count = 8;
-
- for (relbit = 1; count-- != 0; relbit <<=1)
- {
- if (relbit & mod_byte)
- {
- uint8e_type reloc = *src;
- /* This item needs to be relocated */
- switch (reloc & RELOCATION_TYPE_BITS) {
- case RELOCATION_TYPE_ABS:
-
- break;
-
- case RELOCATION_TYPE_REL:
- {
- /* Relocate the item relative to the section */
- oasys_reloc_type *r =
- (oasys_reloc_type *)
- obstack_alloc(&per->reloc_obstack,
- sizeof(oasys_reloc_type));
- *(per->reloc_tail_ptr) = r;
- per->reloc_tail_ptr = &r->next;
- r->next= (oasys_reloc_type *)NULL;
- /* Reference to undefined symbol */
- src++;
- /* There is no symbol */
- r->symbol = 0;
- /* Work out the howto */
- r->relent.section =
- data->sections[reloc & RELOCATION_SECT_BITS];
- r->relent.addend = 0;
- r->relent.address = dst_ptr - dst_base_ptr;
- r->relent.howto = &howto_table[reloc>>6];
- section->reloc_count++;
-
- }
- break;
-
-
- case RELOCATION_TYPE_UND:
- {
- oasys_reloc_type *r =
- (oasys_reloc_type *)
- obstack_alloc(&per->reloc_obstack,
- sizeof(oasys_reloc_type));
- *(per->reloc_tail_ptr) = r;
- per->reloc_tail_ptr = &r->next;
- r->next= (oasys_reloc_type *)NULL;
- /* Reference to undefined symbol */
- src++;
- /* Get symbol number */
- r->symbol = (src[0]<<8) | src[1];
- /* Work out the howto */
- r->relent.section = (asection *)NULL;
- r->relent.addend = 0;
- r->relent.address = dst_ptr - dst_base_ptr;
- r->relent.howto = &howto_table[reloc>>6];
-
- section->reloc_count++;
- src+=2;
- }
- break;
- case RELOCATION_TYPE_COM:
- BFD_FAIL();
+ uint8e_type *src = record.data.data;
+ uint8e_type *end_src = ((uint8e_type *)&record) +
+ record.header.length;
+ unsigned int relbit;
+ bfd_byte *dst_ptr ;
+ bfd_byte *dst_base_ptr ;
+ asection *section;
+ unsigned int count;
+
+ bfd_vma dst_offset = bfd_h_getlong(abfd, record.data.addr);
+ section = data->sections[record.data.relb & RELOCATION_SECT_BITS];
+ per = oasys_per_section(section);
+ dst_base_ptr = oasys_per_section(section)->data;
+ dst_ptr = oasys_per_section(section)->data +
+ dst_offset;
+
+ while (src < end_src) {
+ uint32_type gap = end_src - src -1;
+ uint8e_type mod_byte = *src++;
+ count = 8;
+ if (mod_byte == 0 && gap >= 8) {
+ dst_ptr[0] = src[0];
+ dst_ptr[1] = src[1];
+ dst_ptr[2] = src[2];
+ dst_ptr[3] = src[3];
+ dst_ptr[4] = src[4];
+ dst_ptr[5] = src[5];
+ dst_ptr[6] = src[6];
+ dst_ptr[7] = src[7];
+ dst_ptr+= 8;
+ src += 8;
+ }
+ else {
+ for (relbit = 1; count-- != 0 && gap != 0; gap --, relbit <<=1)
+ {
+ if (relbit & mod_byte)
+ {
+ uint8e_type reloc = *src;
+ /* This item needs to be relocated */
+ switch (reloc & RELOCATION_TYPE_BITS) {
+ case RELOCATION_TYPE_ABS:
+
+ break;
+
+ case RELOCATION_TYPE_REL:
+ {
+ /* Relocate the item relative to the section */
+ oasys_reloc_type *r =
+ (oasys_reloc_type *)
+ obstack_alloc(&per->reloc_obstack,
+ sizeof(oasys_reloc_type));
+ *(per->reloc_tail_ptr) = r;
+ per->reloc_tail_ptr = &r->next;
+ r->next= (oasys_reloc_type *)NULL;
+ /* Reference to undefined symbol */
+ src++;
+ /* There is no symbol */
+ r->symbol = 0;
+ /* Work out the howto */
+ r->relent.section =
+ data->sections[reloc & RELOCATION_SECT_BITS];
+ r->relent.addend = 0;
+ r->relent.address = dst_ptr - dst_base_ptr;
+ r->relent.howto = &howto_table[reloc>>6];
+ r->relent.sym_ptr_ptr = (asymbol **)NULL;
+ section->reloc_count++;
+
+ }
+ break;
+
+
+ case RELOCATION_TYPE_UND:
+ {
+ oasys_reloc_type *r =
+ (oasys_reloc_type *)
+ obstack_alloc(&per->reloc_obstack,
+ sizeof(oasys_reloc_type));
+ *(per->reloc_tail_ptr) = r;
+ per->reloc_tail_ptr = &r->next;
+ r->next= (oasys_reloc_type *)NULL;
+ /* Reference to undefined symbol */
+ src++;
+ /* Get symbol number */
+ r->symbol = (src[0]<<8) | src[1];
+ /* Work out the howto */
+ r->relent.section = (asection *)NULL;
+ r->relent.addend = 0;
+ r->relent.address = dst_ptr - dst_base_ptr;
+ r->relent.howto = &howto_table[reloc>>6];
+ r->relent.sym_ptr_ptr = (asymbol **)NULL;
+
+ section->reloc_count++;
+ src+=2;
+ }
+ break;
+ case RELOCATION_TYPE_COM:
+ BFD_FAIL();
+ }
+ }
+ *dst_ptr++ = *src++;
}
- }
- *dst_ptr++ = *src++;
}
- }
- }
+ }
+ }
break;
case oasys_record_is_local_enum:
case oasys_record_is_symbol_enum:
diff --git a/bfd/targets.c b/bfd/targets.c
index e7cb64d..31741ec 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -37,6 +37,7 @@ extern bfd_target ieee_vec;
extern bfd_target oasys_vec;
extern bfd_target m88k_bcs_vec;
+vvvvvvvvvvvvvvvvvvvv
bfd_target *target_vector[] = {
&aout_little_vec,
&ieee_vec,
@@ -50,3 +51,4 @@ bfd_target *target_vector[] = {
&srec_vec,
NULL,
};
+^^^^^^^^^^^^^^^^^^^^