From: Robert Pengelly Date: Fri, 13 Jun 2025 14:09:51 +0000 (+0100) Subject: Added COFF as a format option X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;p=sasm.git Added COFF as a format option --- diff --git a/as.c b/as.c index 6d3905c..5e4cb64 100644 --- a/as.c +++ b/as.c @@ -133,7 +133,7 @@ int main (int argc, char **argv) { if (state->format == AS_OUTPUT_I386_ELKS || state->format == AS_OUTPUT_IA16_ELKS) { output_elks (state->ofp); - } else if (state->format == AS_OUTPUT_WIN32 || state->format == AS_OUTPUT_WIN64) { + } else if (state->format == AS_OUTPUT_COFF || state->format == AS_OUTPUT_WIN32 || state->format == AS_OUTPUT_WIN64) { output_coff (state->ofp); } diff --git a/as.h b/as.h index aa97d13..7062ee7 100644 --- a/as.h +++ b/as.h @@ -32,9 +32,9 @@ struct segment { #define AS_OUTPUT_IA16_ELKS 0x00 #define AS_OUTPUT_I386_ELKS 0x01 - -#define AS_OUTPUT_WIN32 0x02 -#define AS_OUTPUT_WIN64 0x03 +#define AS_OUTPUT_COFF 0x02 +#define AS_OUTPUT_WIN32 0x03 +#define AS_OUTPUT_WIN64 0x04 struct as_state { diff --git a/coff.c b/coff.c index 71361e8..981040c 100644 --- a/coff.c +++ b/coff.c @@ -81,7 +81,7 @@ static int output_relocation (FILE *outfile, struct fixup *fixup) { } - } else if (state->format == AS_OUTPUT_WIN32) { + } else { switch (fixup->reloc_type) { diff --git a/intel.c b/intel.c index 29b0977..87ac268 100644 --- a/intel.c +++ b/intel.c @@ -2325,7 +2325,7 @@ void machine_dependent_init (void) { machine_dependent_set_march ("generic64"); machine_dependent_set_bits (64, 1); - } else if (state->format == AS_OUTPUT_I386_ELKS || state->format == AS_OUTPUT_WIN32) { + } else if (state->format == AS_OUTPUT_I386_ELKS || state->format == AS_OUTPUT_COFF || state->format == AS_OUTPUT_WIN32) { machine_dependent_set_march ("i386"); machine_dependent_set_bits (32, 1); @@ -6155,7 +6155,7 @@ void machine_dependent_apply_fixup (struct fixup *fixup, unsigned long value) { fixup->done = 1; } - if (state->format == AS_OUTPUT_WIN32 || state->format == AS_OUTPUT_WIN64) { + if (state->format == AS_OUTPUT_COFF || state->format == AS_OUTPUT_WIN32 || state->format == AS_OUTPUT_WIN64) { /* Not sure why but COFF requires this adjustment. */ if (fixup->pcrel && fixup->add_symbol && symbol_get_section (fixup->add_symbol) != current_section) { diff --git a/lib.c b/lib.c index c0025ba..99c2b83 100644 --- a/lib.c +++ b/lib.c @@ -87,7 +87,7 @@ static void _print_usage (void) { 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,\n"); - fprintf (stderr, " win32, win64\n"); + fprintf (stderr, " coff, win32, win64\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"); @@ -418,6 +418,13 @@ void parse_args (int argc, char **argv, int optind) { } + if (xstrcasecmp (optarg, "coff") == 0) { + + state->format = AS_OUTPUT_COFF; + break; + + } + if (xstrcasecmp (optarg, "win32") == 0) { state->format = AS_OUTPUT_WIN32;