All debugging information is preserved */
#include <bfd.h>
-#include "sysdep.h"
#include "bucomm.h"
#include "sysroff.h"
#include "coffgrok.h"
int byte = *idx / 8;
if (size == -2)
- size = 4;
- if (size == -1)
+ {
+ if (sh)
+ size = 4;
+ else if (h8300)
+ size = 2;
+ }
+ else if (size == -1)
size = 0;
if (byte > 240)
{
writeINT (data.data[i], ptr, idx, 1, file);
}
+}
-
-
-}
static void
writeCHARS (string, ptr, idx, size, file)
char *string;
ptr[i++] = size;
}
-
+ /* BUG WAITING TO HAPPEN */
memcpy (ptr + i, string, size);
i += size;
*idx = i * 8;
static void
wr_tr ()
{
- struct IT_tr t;
- sysroff_swap_tr_out (file, &t);
+ /* The TR block is not normal - it doesn't have any contents. */
+
+ static char b[] = {
+ 0xff, /* IT */
+ 0x03, /* RL */
+ 0xfd, /* CS */
+ };
+ fwrite (b, 1, sizeof (b), file);
}
static void
}
}
if (sh)
- {
- un.tool = "C_SH";
- }
- if (h8300)
- {
- un.tool = "C_H8/300H";
- }
+ un.tool = "C_SH";
+ else if (h8300)
+ un.tool = "C_H8/300H";
un.tcd = DATE;
un.linker = "L_GX00";
un.lcd = DATE;
{
case bfd_arch_h8300:
hd.au = 8;
- hd.si = 32;
+ hd.si = 0;
hd.afl = 2;
- hd.spcsz = 0;
+ hd.spcsz = 32;
hd.segsz = 0;
hd.segsh = 0;
hd.cpu = "H8300H";
break;
case bfd_arch_sh:
hd.au = 8;
- hd.si = 32;
- hd.afl = 2;
- hd.spcsz = 0;
+ hd.si = 0;
+ hd.afl = 4;
+ hd.spcsz = 32;
hd.segsz = 0;
hd.segsh = 0;
hd.cpu = "SH";
{
dsy.type = STYPE_ENUM;
dsy.assign = 0;
- dsy.vallen = 4;
- dsy.value = symbol->where->offset;
+ dsy.evallen = 4;
+ dsy.evalue = symbol->where->offset;
}
if (symbol->type->type == coff_structdef_type
{
if (sh)
dsy.reg = rname_sh[symbol->where->offset];
- if (h8300)
+ else if (h8300)
dsy.reg = rname_h8300[symbol->where->offset];
}
n++;
}
}
+
static void
wr_cs ()
{
/* It seems that the CS struct is not normal - the size is wrong
heres one I prepared earlier.. */
- static char b[] =
- {0x80, 0x21, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x00,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xde};
+ static char b[] = {
+ 0x80, /* IT */
+ 0x21, /* RL */
+ 0x00, /* number of chars in variable length part */
+ 0x80, /* hd */
+ 0x00, /* hs */
+ 0x80, /* un */
+ 0x00, /* us */
+ 0x80, /* sc */
+ 0x00, /* ss */
+ 0x80, /* er */
+ 0x80, /* ed */
+ 0x80, /* sh */
+ 0x80, /* ob */
+ 0x80, /* rl */
+ 0x80, /* du */
+ 0x80, /* dps */
+ 0x80, /* dsy */
+ 0x80, /* dty */
+ 0x80, /* dln */
+ 0x80, /* dso */
+ 0x80, /* dus */
+ 0x00, /* dss */
+ 0x80, /* dbt */
+ 0x00, /* dpp */
+ 0x80, /* dfp */
+ 0x80, /* den */
+ 0x80, /* dds */
+ 0x80, /* dar */
+ 0x80, /* dpt */
+ 0x00, /* dul */
+ 0x00, /* dse */
+ 0x00, /* dot */
+ 0xDE /* CS */
+ };
fwrite (b, 1, sizeof (b), file);
}
return scount;
}
+
+/* Write out the ER records for a unit. */
static void
wr_er (ptr, sfile, first)
struct coff_ofile *ptr;
er.name = sym->name;
sysroff_swap_er_out (file, &er);
sym->er_number = idx++;
-
}
}
}
}
+/* Write out the ED records for a unit. */
static void
wr_ed (ptr, sfile, first)
struct coff_ofile *ptr;
wr_un (ptr, sfile, first, 0);
nsecs = wr_sc (ptr, sfile);
p2 = ftell (file);
- fseek (file, p1, 0);
+ fseek (file, p1, SEEK_SET);
wr_un (ptr, sfile, first, nsecs);
- fseek (file, p2, 0);
+ fseek (file, p2, SEEK_SET);
wr_er (ptr, sfile, first);
wr_ed (ptr, sfile, first);
first = 0;
exit (1);
}
- file = fopen (output_file, "wb");
+ file = fopen (output_file, FOPEN_WB);
if (!file)
{