Index: src/installers/80x86/dragonfly/machine.c
===================================================================
--- src/installers/80x86/dragonfly/machine.c	(revision 575)
+++ src/installers/80x86/dragonfly/machine.c	(working copy)
@@ -41,13 +41,27 @@
 
 /* VARIABLES */
 
-char * local_prefix = "L";
-char * name_prefix = "_";
+int dragonfly_elf = 1;
 
+char * local_prefix = ".L";
+char * name_prefix = "";
 
-
 /* PROCEDURES */
 
+void
+set_dragonfly_format(int elf)
+{
+	dragonfly_elf = elf;
+	if (elf == 1) {
+		local_prefix = ".L";
+		name_prefix = "";
+	}
+	else {
+		local_prefix = "L";
+		name_prefix = "_";
+	}
+}
+
 /* is the result of a procedure delivering
    this shape produced in registers. */
 int reg_result
Index: src/installers/80x86/dragonfly/trans.1
===================================================================
--- src/installers/80x86/dragonfly/trans.1	(revision 575)
+++ src/installers/80x86/dragonfly/trans.1	(working copy)
@@ -153,10 +153,10 @@
 the .bss segment.
 .\" ----------------------------------------------------------------------
 .IP \fB-k\fIswitch\fR
-This option is applicable to Linux platforms only. If this option is on,
-\fBtrans386\fR will produce output for an ELF binary format assembler, otherwise
-a.out binary format is assumed. By default this option is on, as appropriate for
-later versions of Linux.
+This option is applicable to Linux and DragonFly  platforms only. If this
+option is on, \fBtrans386\fR will produce output for an ELF binary format
+assembler, otherwise a.out binary format is assumed. By default this option is
+on, as appropriate for later versions of Linux and DragonFly.
 .\" ----------------------------------------------------------------------
 .SH SEE ALSO
 \fIas\fR(1),\fIprof\fR(1), \fItcc\fR(1).
Index: src/installers/80x86/dragonfly/config.h
===================================================================
--- src/installers/80x86/dragonfly/config.h	(revision 575)
+++ src/installers/80x86/dragonfly/config.h	(working copy)
@@ -57,7 +57,7 @@
 #define issol86 0
 #define islinux 0
 #define isdragonfly 1
-#define remove_struct_ref 1
+#define remove_struct_ref (!dragonfly_elf)
 
 #define has_setcc 1
 #define little_end 1
@@ -84,7 +84,7 @@
 #define do_case_transforms 1
 #define substitute_complex 1
 #define has_rotate 1
-#define GCC_STRUCTS 1
+#define GCC_STRUCTS -1	/* (!dragonfly_elf) */
 
 
 #define maxmin_implemented 1
@@ -96,7 +96,8 @@
 #define value_of_null 0
 #define no_trap_on_nil_contents 1
 
-#define prefix_length 1	/* strlen(name_prefix) */
+extern int dragonfly_elf; /* machine.c */
+#define prefix_length (dragonfly_elf ? 0 : 1)	/* strlen(name_prefix) */
 #define AVOID_INTOV 0	/* No software interrupts */
 #define normal_fpucon 0x1272
 
@@ -130,8 +131,8 @@
  * a jump table can contain
  */
 
+#define temp_mips 0
 
+extern void set_dragonfly_format(int); /* XXX */
 
-#define temp_mips 0
-
 #endif
Index: src/installers/80x86/dragonfly/diag_out.c
===================================================================
--- src/installers/80x86/dragonfly/diag_out.c	(revision 575)
+++ src/installers/80x86/dragonfly/diag_out.c	(working copy)
@@ -248,13 +248,17 @@
 
     if (seg != 0)		/* 0 suppresses always */
     {
-      if (seg < 0)
+      if (seg < 0 && !dragonfly_elf)
 	seg = - seg;
       if (seg > 0)		/* -ve line nos are put out in the stabs */
       {
 	i = next_lab () ;
 	fprintf ( dg_file, "%sL.%ld:\n", local_prefix, i ) ;
 	fprintf ( dg_file, "\t.stabn\t0x%x,0,%ld,%sL.%ld",seg, lno, local_prefix, i ) ;
+	if (dragonfly_elf && in_proc) {
+	  outs("-");
+	  out_procname();
+	}
 	outnl ();
       }
     }
Index: src/installers/80x86/dragonfly/assembler.c
===================================================================
--- src/installers/80x86/dragonfly/assembler.c	(revision 575)
+++ src/installers/80x86/dragonfly/assembler.c	(working copy)
@@ -47,6 +47,12 @@
     PROTO_N ( (n) )
     PROTO_T ( int n )
 {
+  if (dragonfly_elf) {
+    outs(".align ");
+    outn((long)n);
+    outnl();
+    return;
+  }
   if (n == 1)
     return;
   outs(".align ");
@@ -90,6 +96,16 @@
     PROTO_N ( (f, jr) )
     PROTO_T ( int f X exp jr )
 {
+  if (dragonfly_elf) {
+    if (is80486 && !is80586 && ptno(jr) != last_jump_label) {
+      if (f == 1)
+	outs(".align 4");	/* repear jump */
+      if (f == 2)
+	outs(".align 16");	/* preceded by a jmp og ret */
+      outs("\n");
+      return;
+    }
+  }
   if (is80486 && !is80586 && ptno(jr) != last_jump_label) {
     if (f == 1)	/* repeat jump */
       outs(".align 3,0x90");
@@ -117,7 +133,10 @@
 void out_readonly_section
     PROTO_Z ()
 {
-  outs (".text");
+  if (dragonfly_elf)
+    outs(".section .rodata");
+  else
+    outs (".text");
   return;
 }
 
@@ -287,16 +306,23 @@
     PROTO_N ( (id) )
     PROTO_T ( char* id )
 {
-  outs(".stabs \"___TDFI_LIST__\",22,0,0,");
-  outs (id);
-  outnl ();
-  outnl ();
+  if (dragonfly_elf) {
+    outs(".section .init\n");
+    outs(" call ");
+    outs(id);
+  }
+  else {
+    outs(".stabs \"___TDFI_LIST__\",22,0,0,");
+    outs(id);
+    outnl();
+    outnl();
+  }
   return;
 }
 
 
 void out_main_prelude
-    PROTO_Z ()
+    PROTO_Z () /* !dragonfly_elf */
 {
   int nl1 = next_lab ();
   int nl2 = next_lab ();
@@ -318,7 +344,7 @@
 }
 
 void out_main_postlude
-    PROTO_Z ()
+    PROTO_Z () /* !dragonfly_elf */
 {
   char * sdummy = "Idummy";
   char * pdummy = (char *) xcalloc (((int)strlen(local_prefix) +
Index: src/installers/80x86/common/cproc.c
===================================================================
--- src/installers/80x86/common/cproc.c	(revision 575)
+++ src/installers/80x86/common/cproc.c	(working copy)
@@ -682,10 +682,12 @@
   outnl ();
 
 
-#if islinux || isfreebsd
+#if islinux || isfreebsd || isdragonfly
   if (
 #if islinux
 	!linux_elf &&
+#elif isdragonfly
+	!dragonfly_elf &&
 #endif
 	pname[0] != local_prefix[0] &&
 	!strcmp (pname+prefix_length, "main")) {
@@ -999,10 +1001,12 @@
     outnl ();
   }
 
-#if islinux || isfreebsd
+#if islinux || isfreebsd || isdragonfly
   if (
 #if islinux
 	!linux_elf &&
+#elif isdragonfly
+	!dragonfly_elf &&
 #endif
 	pname[0] != local_prefix[0] &&
 	!strcmp (pname+prefix_length, "main")) {
Index: src/installers/80x86/common/trans.c
===================================================================
--- src/installers/80x86/common/trans.c	(revision 575)
+++ src/installers/80x86/common/trans.c	(working copy)
@@ -382,6 +382,11 @@
       case 'i':
 	print_inlines = 1;
 	break;
+#if isdragonfly
+      case 'k':
+	set_dragonfly_format (s[2] == '1');
+	break;
+#endif
 #if islinux
       case 'k':
 	set_linux_format (s[2] == '1');
@@ -399,6 +404,10 @@
     };
   };
 
+#if isdragonfly
+  if (gcc_compatible < 0)
+    gcc_compatible = !dragonfly_elf;
+#endif
 #if islinux
   if (gcc_compatible < 0)
     gcc_compatible = ! linux_elf;
