Added COFF as a format option master
authorRobert Pengelly <robertapengelly@hotmail.com>
Fri, 13 Jun 2025 14:09:51 +0000 (15:09 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Fri, 13 Jun 2025 14:09:51 +0000 (15:09 +0100)
as.c
as.h
coff.c
intel.c
lib.c

diff --git a/as.c b/as.c
index 6d3905c31718e6596c1b682b3f3523ca557f632f..5e4cb64762764ca7f407549a1e19f82d72a83d22 100644 (file)
--- 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 aa97d137dc62b763137d2f45f2a3693192c88351..7062ee79d789a99ffee3903e57942ea280c07cc2 100644 (file)
--- 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 71361e8b8a9c0d3966803e991de9f78483d913a0..981040cfd75f8142c79974c65638d1419bc4a2e0 100644 (file)
--- 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 29b097704fd2eba4a0813da092e3fb9ca371993e..87ac26893e0196954ec53f442a5838bb0d0ee4f5 100644 (file)
--- 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 c0025ba6ac7a64f7cc33a65a1d941f97cfe5dad1..99c2b8383505a7112b14e82f319cc14ba4ff8c78 100644 (file)
--- 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;