$OpenBSD: patch-ghc_rts_Linker_c,v 1.5 2004/01/08 20:33:23 avsm Exp $
sprintf.
preliminary attempts to get object file loading working, so that
ghci will work. Needs revisiting, to check all lib interfaces

--- ghc/rts/Linker.c.orig	Fri May 30 08:40:51 2003
+++ ghc/rts/Linker.c	Fri Nov  7 12:32:30 2003
@@ -59,7 +59,7 @@
 #include <sys/mman.h>
 #endif
 
-#if defined(linux_TARGET_OS) || defined(solaris2_TARGET_OS) || defined(freebsd_TARGET_OS) || defined(netbsd_TARGET_OS)
+#if defined(linux_TARGET_OS) || defined(solaris2_TARGET_OS) || defined(freebsd_TARGET_OS) || defined(netbsd_TARGET_OS) || defined(openbsd_TARGET_OS)
 #  define OBJFORMAT_ELF
 #elif defined(cygwin32_TARGET_OS) || defined (mingw32_TARGET_OS)
 #  define OBJFORMAT_PEi386
@@ -773,10 +773,10 @@
       	extension. */
 
    buf = stgMallocBytes(strlen(dll_name) + 10, "addDLL");
-   sprintf(buf, "%s.DLL", dll_name);
+   snprintf(buf, strlen(dll_name) + 10, "%s.DLL", dll_name);
    instance = LoadLibrary(buf);
    if (instance == NULL) {
-	 sprintf(buf, "%s.DRV", dll_name);	// KAA: allow loading of drivers (like winspool.drv)
+	 snprintf(buf, strlen(dll_name) + 10, "%s.DRV", dll_name);	// KAA: allow loading of drivers (like winspool.drv)
 	 instance = LoadLibrary(buf);
 	 if (instance == NULL) {
 		stgFree(buf);
@@ -2011,7 +2011,15 @@
 #  define ELF_NEED_PLT      /* needs Procedure Linkage Tables */
 #endif
 
+#if !defined(openbsd_TARGET_OS)
 #include <elf.h>
+#else
+/* openbsd elf has things in different places, with diff names */
+#include <elf_abi.h>
+#include <machine/reloc.h>
+#define R_386_32    RELOC_32
+#define R_386_PC32  RELOC_PC32
+#endif
 
 /*
  * Define a set of types which can be used for both ELF32 and ELF64
