+Thu Jun 6 18:27:38 1991 Steve Chamberlain (steve at cygint.cygnus.com)
+
+ * ../include/oasys.h oasys.c (oasys_archive_p): fixed so it works
+
+ * srec.c: now allows any number of sections to be created in a
+ file. Outputs addresses of the right length.
+
Thu May 30 15:30:10 1991 Steve Chamberlain (steve at cygint.cygnus.com)
* bfd.c (bfd_check_format): Fixed problem where when a defaulted
oasys_archive_header_type header;
oasys_external_archive_header_type header_ext;
unsigned int i;
-
+ file_ptr filepos;
bfd_seek(abfd, (file_ptr) 0, false);
(oasys_module_info_type*)
bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
+
oasys_module_table_type record;
oasys_external_module_table_type record_ext;
ar->module = module;
ar->module_count = header.mod_count;
- bfd_seek(abfd , header.mod_tbl_offset, SEEK_SET);
+
+ filepos = header.mod_tbl_offset;
for (i = 0; i < header.mod_count; i++) {
+ bfd_seek(abfd , filepos, SEEK_SET);
bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd);
record.mod_size = bfd_h_get_32(abfd, record_ext.mod_size);
- record.file_offset = bfd_h_get_32(abfd, record_ext.file_offset);
- record.mod_name_length = bfd_h_get_32(abfd, record_ext.mod_name_length);
+ record.file_offset = bfd_h_get_32(abfd,
+ record_ext.file_offset);
+
+ record.dep_count = bfd_h_get_32(abfd, record_ext.dep_count);
+ record.depee_count = bfd_h_get_32(abfd, record_ext.depee_count);
+ record.sect_count = bfd_h_get_32(abfd, record_ext.sect_count);
+
+
+ module[i].name = bfd_alloc(abfd,33);
- module[i].name = bfd_alloc(abfd,record.mod_name_length+1);
+ memcpy(module[i].name, record_ext.mod_name, 33);
+ filepos +=
+ sizeof(record_ext) +
+ record.dep_count * 4 +
+ record.depee_count * 4 +
+ record.sect_count * 8 + 187,
- bfd_read(module[i].name, 1, record.mod_name_length +1, abfd);
- /* SKip some stuff */
- bfd_seek(abfd, record.dep_count * sizeof(int32_type),
- SEEK_CUR);
module[i].size = record.mod_size;
module[i].pos = record.file_offset;
+ module[i].abfd = 0;
}
}
} u;
} srec_type;
-
+#define enda(x) (x->vma + x->size)
/*
called once per input srecord, used to work out vma and size of data.
*/
+static bfd_vma low,high;
static void
size_srec(abfd, section, address, raw, length)
bfd *abfd;
byte_as_two_char_type *raw;
unsigned int length;
{
- if (address < section->vma)
- section->vma = address;
-
- if (address + length > section->vma + section->size)
- section->size = (address+length) - section->vma;
+ if (address < low)
+ low = address;
+ if (address + length > high)
+ high = address + length;
}
+
/*
called once per input srecord, copies data from input into bfd_alloc'd area
*/
section = bfd_make_section(abfd, ".text");
section->size = 0;
section->vma = 0xffffffff;
+ low = 0xffffffff;
+ high = 0;
pass_over(abfd, size_srec, section);
-
+ section->size = high - low;
+ section->vma = low;
return abfd->xvec;
}
unsigned int i;
srec_type buffer;
bytes_written = 0;
- if (section->size <= 0xffff)
+ if (section->vma <= 0xffff)
type = 1;
- else if (section->size <= 0xffffff)
+ else if (section->vma <= 0xffffff)
type = 2;
else
type = 3;
return 0;
}
+static asymbol *
+DEFUN(srec_make_empty_symbol, (abfd),
+ bfd*abfd)
+{
+ asymbol *new= (asymbol *)bfd_zalloc (abfd, sizeof (asymbol));
+ new->the_bfd = abfd;
+ return new;
+}
/*SUPPRESS 460 */
-#define srec_new_section_hook (PROTO(boolean, (*), (bfd *, asection *)))bfd_false
+#define srec_new_section_hook (PROTO(boolean, (*), (bfd *, asection *)))bfd_true
#define srec_get_symtab_upper_bound bfd_false
#define srec_get_symtab (PROTO(unsigned int, (*), (bfd *, asymbol **)))bfd_0
#define srec_get_reloc_upper_bound (PROTO(unsigned int, (*),(bfd*, asection *)))bfd_false
#define srec_canonicalize_reloc (PROTO(unsigned int, (*),(bfd*,asection *, arelent **, asymbol **))) bfd_0
-#define srec_make_empty_symbol (PROTO(asymbol *,(*),(bfd*))) bfd_nullvoidptr
+
#define srec_print_symbol (PROTO(void,(*),(bfd *, PTR, asymbol *, bfd_print_symbol_enum_type))) bfd_void
#define srec_openr_next_archived_file (PROTO(bfd *, (*), (bfd*,bfd*))) bfd_nullvoidptr
ldmalloc((bfd_size_type)(sizeof(section_userdata_type)));
s->bfd_section = bfd_make_section(output_bfd, s->name);
+ if (s->bfd_section == (asection *)NULL) {
+ info("%P%F output format %s cannot represent section called %s\n",
+ output_bfd->xvec->name,
+ s->name);
+ }
s->bfd_section->output_section = s->bfd_section;
s->bfd_section->flags = SEC_NO_FLAGS;
/* We initialize an output sections output offset to minus its own */