r_symbolnum = GET_UINT32 (r->r_symbolnum) & (3L << 29);
r_address = GET_INT32 (r->r_address);
- if (state->format == LD_FORMAT_IA16_AOUT || state->format == LD_FORMAT_I386_AOUT || ((r_symbolnum >> 28) & 0xff) != N_ABS) {
+ if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS || state->format == LD_FORMAT_I386_AOUT || ((r_symbolnum >> 28) & 0xff) != N_ABS) {
if (state->format == LD_FORMAT_BIN || state->format == LD_FORMAT_COM) {
if (state->format == LD_FORMAT_I386_AOUT) {
header_size = sizeof (struct aout_exec);
- } else if (state->format == LD_FORMAT_IA16_AOUT) {
+ } else if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS) {
header_size = sizeof (struct elks_exec);
}
write741_to_byte_array (header->a_trsize, tgr.relocations_count * sizeof (struct relocation_info));
write741_to_byte_array (header->a_drsize, dgr.relocations_count * sizeof (struct relocation_info));
- } else if (state->format == LD_FORMAT_IA16_AOUT) {
+ } else if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS) {
struct elks_exec *header = output;
header->a_magic[1] = ELKS_MAGIC & 0xff;
header->a_flags = 0x10;
- header->a_cpu = 0x04;
+ header->a_cpu = (state->format == LD_FORMAT_I386_ELKS) ? 0x10 : 0x04;
header->a_hdrlen = sizeof (*header);
write741_to_byte_array (header->a_text, state->text_size);
}
- } else if (state->format == LD_FORMAT_IA16_AOUT) {
+ } else if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS) {
if (tgr.relocations_count > 0) {
text = (void *) (char *) output;
data = (void *) ((char *) text + state->text_size);
- } else if (state->format == LD_FORMAT_IA16_AOUT || state->format == LD_FORMAT_I386_AOUT) {
+ } else if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS || state->format == LD_FORMAT_I386_AOUT) {
if (init_elks_object ()) {
return EXIT_FAILURE;
}
- if (state->format == LD_FORMAT_IA16_AOUT || state->format == LD_FORMAT_I386_AOUT) {
+ if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS || state->format == LD_FORMAT_I386_AOUT) {
entry = get_entry ();
}
}
- } else if (state->format == LD_FORMAT_IA16_AOUT || state->format == LD_FORMAT_I386_AOUT) {
+ } else if (state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS || state->format == LD_FORMAT_I386_AOUT) {
if (write_elks_object (entry)) {
state->ofile = xstrdup ("a.out");
}
- if (state->format == LD_FORMAT_BIN || state->format == LD_FORMAT_COM) {
+ if (state->format == LD_FORMAT_BIN || state->format == LD_FORMAT_COM || state->format == LD_FORMAT_IA16_ELKS || state->format == LD_FORMAT_I386_ELKS) {
if (state->format == LD_FORMAT_COM) {
state->psp = 0x100;
}
+ if (state->format == LD_FORMAT_IA16_ELKS) {
+
+ if (state->text_size > 65536L || state->data_size > 65536L || (state->text_size + state->data_size) > 65536L) {
+
+ report_at (program_name, 0, REPORT_ERROR, "binary to large for elks-ia16");
+ return EXIT_FAILURE;
+
+ }
+
+ }
+
if (state->nb_elks_objs > 0) {
if (create_executable_from_elks_objects ()) {
#define LD_FORMAT_COM 0x00
#define LD_FORMAT_BIN 0x01
-#define LD_FORMAT_IA16_AOUT 0x02
-#define LD_FORMAT_I386_AOUT 0x04
+#define LD_FORMAT_IA16_ELKS 0x02
+#define LD_FORMAT_I386_ELKS 0x04
+
+#define LD_FORMAT_I386_AOUT 0x08
extern struct ld_state *state;
extern const char *program_name;
fprintf (stderr, " --oformat FORMAT Specify the format of output file (default msdos)\n");
fprintf (stderr, " Supported formats are:\n");
- fprintf (stderr, " a.out-i386, binary, msdos\n");
+ fprintf (stderr, " a.out-i386, elks-ia16, elks-i386,\n");
+ fprintf (stderr, " binary, msdos\n");
fprintf (stderr, " -e ADDRESS Set start address.\n");
fprintf (stderr, " -s Ignored.\n");
}
- if (xstrcasecmp (optarg, "a.out-ia16") == 0) {
+ if (xstrcasecmp (optarg, "elks-ia16") == 0) {
- state->format = LD_FORMAT_IA16_AOUT;
+ state->format = LD_FORMAT_IA16_ELKS;
+ break;
+
+ }
+
+ if (xstrcasecmp (optarg, "elks-i386") == 0) {
+
+ state->format = LD_FORMAT_I386_ELKS;
break;
}