--- orig/acconfig.h +++ mod/acconfig.h @@ -166,7 +166,8 @@ #include #define ISNORMAL(a) (fpclass(a)>=FP_NZERO) #else -#error "No isnormal found" +#include +#define ISNORMAL(a) (finite(a) && (a) != 0.0) #endif #endif #endif --- orig/configure.in +++ mod/configure.in @@ -673,13 +673,15 @@ if test "$enable_dlopen" = "yes" ; then - AC_CHECK_LIB(dl,dlopen,have_dl=1,have_dl=0) - if test "$have_dl" = "0" ; then - echo "Cannot find dlopen in -dl" - exit 1 - fi +dnl AC_CHECK_LIB(dl,dlopen,have_dl=1,have_dl=0) +dnl if test "$have_dl" = "0" ; then +dnl echo "Cannot find dlopen in -dl" +dnl exit 1 +dnl fi + AC_SEARCH_LIBS(dlopen, dl, have_dl=1, AC_ERROR(dlopen not found)) +dnl LIBS and TLIBS - why not merged from the beginning? - TLIBS="$TLIBS -ldl -rdynamic" + TLIBS="$TLIBS -rdynamic" AC_DEFINE(USE_DLOPEN) fi @@ -946,6 +948,9 @@ AC_CHECK_HEADERS(sys/ioctl.h) +# OpenBSD has elf_abi.h instead of elf.h +AC_CHECK_HEADERS(elf.h elf_abi.h) + #-------------------------------------------------------------------- # The code below deals with several issues related to gettimeofday: @@ -1232,19 +1237,18 @@ AC_CHECK_HEADERS(asm/sigcontext.h) AC_CHECK_HEADERS(asm/signal.h) AC_TRY_COMPILE([#include - long code; - ], + ], [ - void *p = ((void *)(((struct sigcontext_struct *)(&code)))); + struct sigcontext_struct foo; ], [ sigcontext_struct_works=1; AC_DEFINE(SIGNAL_H_HAS_SIGCONTEXT) - AC_MSG_RESULT("sigcontext in signal.h") + AC_MSG_RESULT("sigcontext_struct in signal.h") ], [sigcontext_struct_works=0; - AC_MSG_RESULT("sigcontext NOT in signal.h")] + AC_MSG_RESULT("sigcontext_struct NOT in signal.h")] ) if test "$sigcontext_struct_works" = 0 ; then AC_TRY_COMPILE([#include @@ -1254,10 +1258,9 @@ #ifdef HAVE_ASM_SIGNAL_H #include #endif - long code; ], [ - void *p = ((void *)(((struct sigcontext *)(&code)))); + struct sigcontext foo; ], [ sigcontext_works=1 ; --- orig/h/FreeBSD.h +++ mod/h/FreeBSD.h @@ -22,6 +22,9 @@ #endif #define ELFW(a) Mjoin(ELF,Mjoin(__ELF_NATIVE_CLASS,Mjoin(_,a))) +/* OpenBSD needs sys/types.h included before link.h, which is included + in linux.h */ +#include #include "linux.h" #if defined(__i386__) --- orig/h/bsd.h +++ mod/h/bsd.h @@ -4,7 +4,10 @@ #define UNIX #define AV #define SFASL + +#if 0 #define HAVE_AOUT +#endif #define MEM_SAVE_LOCALS \ --- orig/h/linux.h +++ mod/h/linux.h @@ -5,7 +5,7 @@ #endif #undef HAVE_AOUT -#define HAVE_AOUT +/* #define HAVE_AOUT */ #define HAVE_ELF /* Seeking to the end of ELF data is a little messy... */ --- orig/o/fasldlsym.c +++ mod/o/fasldlsym.c @@ -28,8 +28,10 @@ #ifdef HAVE_AOUT #include HAVE_AOUT #endif -#ifdef HAVE_ELF +#if defined(HAVE_ELF_H) #include +#elif defined(HAVE_ELF_ABI_H) +#include #endif #include "ptable.h" --- orig/o/file.d +++ mod/o/file.d @@ -78,8 +78,10 @@ #define a_drsize rdsize #endif -#ifdef HAVE_ELF +#if defined(HAVE_ELF_H) #include +#elif defined(HAVE_ELF_ABI_H) +#include #endif extern void tcpCloseSocket (int fd); --- orig/o/sfaslelf.c +++ mod/o/sfaslelf.c @@ -23,7 +23,7 @@ */ -#if !defined(__linux__) && !defined(__FreeBSD__) +#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) #define ELF_TARGET_SPARC 1 #endif @@ -36,7 +36,15 @@ #include #include +#if defined(HAVE_ELF_H) #include +#elif defined(HAVE_ELF_ABI_H) +#include +/* XXX: bad OpenBSD hack FIX!! */ +#include +#else +#error Neither elf.h nor elf_abi.h found +#endif #include "gclincl.h" /* #ifdef HAVE_LIBBFD */ @@ -545,56 +553,60 @@ /* do_bfd_reloc(ELF32_R_TYPE(reloc_info->r_info),s+a,(unsigned int *)where); */ /* #else */ switch(ELF32_R_TYPE(reloc_info->r_info)){ -#if (defined(__svr4__) || defined(__linux__) || defined(__FreeBSD__)) && defined(__i386__) - case R_386_NONE: - FEerror("Unsupported ELF type R_386_NONE",0); +#if (defined(__svr4__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) + + /* XXX: Linux broken in favor of OpenBSD. FIX! */ + case RELOC_NONE: + FEerror("Unsupported ELF type RELOC_NONE",0); break; - case R_386_32: + case RELOC_32: val = (s+a); ADD_VAL(where,~0,val); break; - case R_386_PC32: + case RELOC_PC32: val = (s+a) - (unsigned int)where /* - 4 */; ADD_VAL(where,~0,val); break; - case R_386_GOT32: - FEerror("Unsupported ELF type R_386_GOY32",0); + case RELOC_GOT32: + FEerror("Unsupported ELF type RELOC_GOY32",0); break; - case R_386_PLT32: - FEerror("Unsupported ELF type R_386_PLT32",0); + case RELOC_PLT32: + FEerror("Unsupported ELF type RELOC_PLT32",0); break; - case R_386_COPY: - FEerror("Unsupported ELF type R_386_COPY",0); + case RELOC_COPY: + FEerror("Unsupported ELF type RELOC_COPY",0); break; - case R_386_GLOB_DAT: - FEerror("Unsupported ELF type R_386_GLOB_DAT",0); + case RELOC_GLOB_DAT: + FEerror("Unsupported ELF type RELOC_GLOB_DAT",0); break; - case R_386_JMP_SLOT: - FEerror("Unsupported ELF type R_386_JMP_SLOT",0); +#ifdef RELOC_JMP_SLOT + case RELOC_JMP_SLOT: + FEerror("Unsupported ELF type RELOC_JMP_SLOT",0); break; +#endif - case R_386_RELATIVE: - FEerror("Unsupported ELF type R_386_RELATIVE",0); + case RELOC_RELATIVE: + FEerror("Unsupported ELF type RELOC_RELATIVE",0); break; - case R_386_GOTOFF: - FEerror("Unsupported ELF type R_386_GOTOFF",0); + case RELOC_GOTOFF: + FEerror("Unsupported ELF type RELOC_GOTOFF",0); break; - case R_386_GOTPC: - FEerror("Unsupported ELF type R_386_GOTPC",0); + case RELOC_GOTPC: + FEerror("Unsupported ELF type RELOC_GOTPC",0); break; -#ifdef R_386_NUM - case R_386_NUM: - FEerror("Unsupported ELF type R_386_NUM",0); +#ifdef RELOC_NUM + case RELOC_NUM: + FEerror("Unsupported ELF type RELOC_NUM",0); break; #endif --- orig/o/sgbc.c +++ mod/o/sgbc.c @@ -1075,7 +1075,11 @@ memprotect_handler_test(int sig, long code, void *scp, char *addr) { char *faddr; +#ifdef GET_FAULT_ADDR faddr=GET_FAULT_ADDR(sig,code,scp,addr); +#else + faddr = addr; +#endif if (memprotect_handler_invocations) { memprotect_result=memprotect_multiple_invocations; --- orig/o/unixfasl.c +++ mod/o/unixfasl.c @@ -282,7 +282,7 @@ static int faslink(object faslfile, object ldargstring) { -#if ((defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)) || defined(DARWIN) +#if ((defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__ELF__)) || defined(DARWIN) FEerror("faslink() not supported for ELF yet",0); return 0; #else --- orig/unixport/makefile +++ mod/unixport/makefile @@ -178,4 +178,4 @@ gazonk*.lsp plt*h *_map .INTERMEDIATE: init_ansi_gcl.lsp.tmp init_gcl.lsp.tmp raw_gcl raw_ansi_gcl -.PRECIOUS: init_gcl.lsp init_ansi_gcl.lsp \ No newline at end of file +.PRECIOUS: init_gcl.lsp init_ansi_gcl.lsp raw_pre_gcl --- orig/unixport/rsym_elf.c +++ mod/unixport/rsym_elf.c @@ -27,7 +27,28 @@ #include "ext_sym.h" +#if defined(HAVE_ELF_H) #include +#elif defined(HAVE_ELF_ABI_H) +#include +#else +#error Neither elf.h nor elf_abi.h found +#endif + +/* For OpenBSD */ +#ifndef ElfW +/* ElfW(type) becomes Elf32_type or Elf64_type, respectively. + * Defined in link.h on Linux. OpenBSD does this in another way: + * by defining Elf_Ehdr etc to the correct type in exec_elf.h. + */ +#ifdef Elf_Ehdr +#define ElfW(type) Elf_##type +#else +#error Neither ElfW nor Elf_Ehdr defined +#endif + +#endif + ElfW(Phdr) pheader; ElfW(Ehdr) eheader; ElfW(Sym) *symbol_table; @@ -36,7 +57,13 @@ #undef EXT_and_TEXT_BSS_DAT /* #define mjoin(a,b) a ## b */ /* #define Mjoin(a,b) mjoin(a,b) */ +#if defined(__ELF_NATIVE_CLASS) #define ELFW(a) Mjoin(ELF,Mjoin(__ELF_NATIVE_CLASS,Mjoin(_,a))) +#elif defined(ELFSIZE) +#define ELFW(a) Mjoin(ELF,Mjoin(ELFSIZE,Mjoin(_,a))) +#else +#error Neither __ELF_NATIVE_CLASS nor ELFSIZE defined +#endif int nsyms; char *my_string_table;