From 512312d38d03188695fc3950881a9f0ed3ed261a Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Thu, 7 Nov 2024 00:09:26 +0000 Subject: [PATCH] Also create I386 elks objects --- as.h | 6 ++++-- elks.c | 2 +- lib.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/as.h b/as.h index 2431e45..15d33f6 100644 --- a/as.h +++ b/as.h @@ -30,8 +30,10 @@ struct segment { }; -#define AS_OUTPUT_OBJ 0x00 -#define AS_OUTPUT_BIN 0x01 +#define AS_OUTPUT_IA16_ELKS 0x00 +#define AS_OUTPUT_I386_ELKS 0x01 + +#define AS_OUTPUT_BIN 0x02 struct as_state { diff --git a/elks.c b/elks.c index 3f60bb9..410c858 100644 --- a/elks.c +++ b/elks.c @@ -110,7 +110,7 @@ void output_elks (FILE *fp) { header.a_magic[1] = (ELKS_MAGIC & 0xff); header.a_flags = 0x10; - header.a_cpu = 0x04; + header.a_cpu = (state->format == AS_OUTPUT_I386_ELKS) ? 0x10 : 0x04; header.a_hdrlen = sizeof (header); if ((symbol = state->end_symbol)) { diff --git a/lib.c b/lib.c index 5635078..9b555c1 100644 --- a/lib.c +++ b/lib.c @@ -84,6 +84,9 @@ static void _print_usage (void) { fprintf (stderr, " -Uname Undefine 'name'.\n"); fprintf (stderr, "\n"); + fprintf (stderr, " -f FORMAT Specify the format of object file (default elks-ia16)\n"); + fprintf (stderr, " Supported formats are:\n"); + fprintf (stderr, " elks-ia16, elks-i386, binary\n"); fprintf (stderr, " -l FILE Print listings to file FILE.\n"); fprintf (stderr, " -o OBJFILE Name the object-file output OBJFILE (default a.out).\n"); @@ -397,9 +400,16 @@ void parse_args (int argc, char **argv, int optind) { } - if (xstrcasecmp (optarg, "obj") == 0) { + if (xstrcasecmp (optarg, "elks-ia16") == 0) { - state->format = AS_OUTPUT_OBJ; + state->format = AS_OUTPUT_IA16_ELKS; + break; + + } + + if (xstrcasecmp (optarg, "elks-i386") == 0) { + + state->format = AS_OUTPUT_I386_ELKS; break; } -- 2.34.1