summary refs log tree commit diff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index b8cd7d6..c1664be 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,5 @@
 #include "all.h"
+#include "config.h"
 #include <ctype.h>
 #include <getopt.h>
 
@@ -74,10 +75,11 @@ main(int ac, char *av[])
 {
 	FILE *inf;
 	char *f;
-	int c;
+	int c, asm;
 
+	asm = Defaultasm;
 	outf = stdout;
-	while ((c = getopt(ac, av, "d:o:")) != -1)
+	while ((c = getopt(ac, av, "d:o:G:")) != -1)
 		switch (c) {
 		case 'd':
 			for (; *optarg; optarg++)
@@ -90,11 +92,32 @@ main(int ac, char *av[])
 			if (strcmp(optarg, "-") != 0)
 				outf = fopen(optarg, "w");
 			break;
+		case 'G':
+			if (strcmp(optarg, "e") == 0)
+				asm = Gaself;
+			else if (strcmp(optarg, "m") == 0)
+				asm = Gasmacho;
+			else {
+				fprintf(stderr, "unknown gas flavor '%s'\n", optarg);
+				exit(1);
+			}
+			break;
 		default:
 			fprintf(stderr, "usage: %s [-d <flags>] [-o out] {file.ssa, -}\n", av[0]);
 			exit(1);
 		}
 
+	switch (asm) {
+	case Gaself:
+		locprefix = ".L";
+		symprefix = "";
+		break;
+	case Gasmacho:
+		locprefix = "L";
+		symprefix = "_";
+		break;
+	}
+
 	do {
 		f = av[optind];
 		if (!f || strcmp(f, "-") == 0) {