ruby-changes:65646
From: Nobuyoshi <ko1@a...>
Date: Wed, 24 Mar 2021 20:14:24 +0900 (JST)
Subject: [ruby-changes:65646] 1f08b0d18d (master): Removed dln_a_out
https://git.ruby-lang.org/ruby.git/commit/?id=1f08b0d18d From 1f08b0d18d9d1178cef1eac91f6ea97cb6b437eb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 24 Mar 2021 20:13:55 +0900 Subject: Removed dln_a_out a.out format is considered extinct nowadays. --- configure.ac | 64 +--- dln.c | 1002 +-------------------------------------------------- dln.h | 5 - include/ruby/ruby.h | 5 - ruby.c | 9 - 5 files changed, 16 insertions(+), 1069 deletions(-) diff --git a/configure.ac b/configure.ac index a3641cb..58aa35a 100644 --- a/configure.ac +++ b/configure.ac @@ -1092,7 +1092,6 @@ main() https://github.com/ruby/ruby/blob/trunk/configure.ac#L1092 AC_LIBOBJ([langinfo]) ], [mingw*], [ LIBS="-lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi $LIBS" - ac_cv_header_a_out_h=no ac_cv_header_pwd_h=no ac_cv_header_utime_h=no ac_cv_header_sys_ioctl_h=no @@ -1212,7 +1211,6 @@ dnl AC_HEADER_STDC has been checked in AC_USE_SYSTEM_EXTENSIONS https://github.com/ruby/ruby/blob/trunk/configure.ac#L1211 AC_HEADER_STDBOOL AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(a.out.h) AC_CHECK_HEADERS(atomic.h) AC_CHECK_HEADERS(copyfile.h) AC_CHECK_HEADERS(direct.h) @@ -2710,16 +2708,13 @@ main(int argc, char *argv[]) https://github.com/ruby/ruby/blob/trunk/configure.ac#L2708 : "runtime section" && { dnl wheather use dln_a_out or not AC_ARG_WITH(dln-a-out, - AS_HELP_STRING([--with-dln-a-out], [use dln_a_out if possible]), + AS_HELP_STRING([--with-dln-a-out], [dln_a_out is deprecated]), [ AS_CASE([$withval], [yes], [ - AS_IF([test "$enable_shared" = yes], [ - AC_MSG_ERROR(dln_a_out can not make shared library) - ]) - with_dln_a_out=yes], - [ - with_dln_a_out=no])], [with_dln_a_out=no]) + AC_MSG_ERROR(dln_a_out no longer supported) + ]) +]) AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf, [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ @@ -2729,9 +2724,6 @@ rb_cv_binary_elf=no)]) https://github.com/ruby/ruby/blob/trunk/configure.ac#L2724 AS_IF([test "$rb_cv_binary_elf" = yes], [ AC_DEFINE(USE_ELF) - AS_IF([test "$with_dln_a_out" = yes], [ - AC_MSG_ERROR(dln_a_out does not work with ELF) - ]) AC_CHECK_HEADERS([elf.h elf_abi.h]) AS_IF([test $ac_cv_header_elf_h = yes -o $ac_cv_header_elf_abi_h = yes], [ AC_LIBOBJ([addr2line]) @@ -2747,7 +2739,7 @@ AS_IF([test "$ac_cv_header_mach_o_loader_h" = yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L2739 AS_CASE(["$target_os"], [linux* | gnu* | k*bsd*-gnu | bsdi* | kopensolaris*-gnu], [ AS_IF([test "$rb_cv_binary_elf" = no], [ - with_dln_a_out=yes + AC_MSG_ERROR(Not ELF) ], [ LDFLAGS="$LDFLAGS -rdynamic" ])]) @@ -2781,7 +2773,7 @@ AC_SUBST(ASMEXT, S)dnl https://github.com/ruby/ruby/blob/trunk/configure.ac#L2773 STATIC= -AS_IF([test "$with_dln_a_out" != yes], [ +: "dlopen" && { rb_cv_dlopen=unknown AC_MSG_CHECKING(whether OS depend dynamic link works) AS_IF([test "$GCC" = yes], [ @@ -2806,8 +2798,9 @@ AS_IF([test "$with_dln_a_out" != yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L2798 [esix*|uxpds*], [CCDLFLAGS="$CCDLFLAGS -KPIC"], [: ${CCDLFLAGS=""}]) ]) +} - +: "rpath" && { AC_ARG_ENABLE(rpath, AS_HELP_STRING([--enable-rpath], [embed run path into extension libraries. enabled by default on ELF platforms]), @@ -2933,7 +2926,8 @@ AS_IF([test "$with_dln_a_out" != yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L2926 RPATHFLAG=" ${rpathflag}%1\$-s" ]) ]) -]) +} + AS_IF([test "${LDSHAREDXX}" = ""], [ AS_CASE(["${LDSHARED}"], [*'$(CC)'*], [ @@ -3063,33 +3057,7 @@ AC_ARG_WITH(valgrind, https://github.com/ruby/ruby/blob/trunk/configure.ac#L3057 AS_IF([test x$with_valgrind != xno], [AC_CHECK_HEADERS(valgrind/memcheck.h)]) -dln_a_out_works=no -AS_IF([test "$ac_cv_header_a_out_h" = yes], [ - AS_IF([test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown], [ - cat confdefs.h > config.h - AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#define USE_DLN_A_OUT -#include "dln.c" -]], [[]])], - rb_cv_dln_a_out=yes, - rb_cv_dln_a_out=no)]) - AS_IF([test "$rb_cv_dln_a_out" = yes], [ - dln_a_out_works=yes - AC_DEFINE(USE_DLN_A_OUT) - ]) - ]) -]) - -AS_IF([test "$dln_a_out_works" = yes], [ - AS_IF([test "$GCC" = yes], [ - STATIC=-static - ], [ - STATIC=-Bstatic - ]) - DLEXT=so - CCDLFLAGS= -], [ +: "dlext & soext" && { AS_CASE(["$target_os"], [hpux*], [ DLEXT=sl], @@ -3102,9 +3070,10 @@ AS_IF([test "$dln_a_out_works" = yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L3070 DLEXT=so], [ DLEXT=so]) -]) : ${SOEXT="${DLEXT}"} AC_SUBST(SOEXT) +} + AS_IF([test "$rb_cv_dlopen:$load_relative" = yes:yes], [ AS_IF([test "$ac_cv_func_dladdr" = yes], [ LOAD_RELATIVE=1 @@ -3124,9 +3093,7 @@ test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT") https://github.com/ruby/ruby/blob/trunk/configure.ac#L3093 test ".$DLEXT2" = "." || AC_DEFINE_UNQUOTED(DLEXT2, ".$DLEXT2") AC_SUBST(DLEXT) -AS_IF([test "$with_dln_a_out" = yes], [ - STRIP=true -], [ +: "strip" && { AC_MSG_CHECKING([for $STRIP flags]) AC_LINK_IFELSE([AC_LANG_PROGRAM], [AS_IF( ["${STRIP}" -A -n conftest$ac_exeext 2>/dev/null], [ @@ -3140,8 +3107,7 @@ AS_IF([test "$with_dln_a_out" = yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L3107 AC_MSG_RESULT([none needed]) ]) ]) -]) - +} AC_ARG_WITH(ext, AS_HELP_STRING([--with-ext=EXTS], diff --git a/dln.c b/dln.c index 48d4090..b050898 100644 --- a/dln.c +++ b/dln.c @@ -28,10 +28,6 @@ static void dln_loaderror(const char *format, ...); https://github.com/ruby/ruby/blob/trunk/dln.c#L28 # include <stdlib.h> #endif -#ifdef USE_DLN_A_OUT -char *dln_argv0; -#endif - #if defined(HAVE_ALLOCA_H) #include <alloca.h> #endif @@ -98,7 +94,7 @@ dln_loaderror(const char *format, ...) https://github.com/ruby/ruby/blob/trunk/dln.c#L94 } #endif -#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP) +#if defined(HAVE_DLOPEN) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP) /* dynamic load with dlopen() */ # define USE_DLN_DLOPEN #endif @@ -147,972 +143,6 @@ static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX https://github.com/ruby/ruby/blob/trunk/dln.c#L143 *(buf) = tmp;\ } while (0) -#ifdef USE_DLN_A_OUT - -#ifndef LIBC_NAME -# define LIBC_NAME "libc.a" -#endif - -#ifndef DLN_DEFAULT_LIB_PATH -# define DLN_DEFAULT_LIB_PATH "/lib:/usr/lib:/usr/local/lib:." -#endif - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> - -static int dln_errno; - -#define DLN_ENOEXEC ENOEXEC /* Exec format error */ -#define DLN_ECONFL 1201 /* Symbol name conflict */ -#define DLN_ENOINIT 1202 /* No initializer given */ -#define DLN_EUNDEF 1203 /* Undefine symbol remains */ -#define DLN_ENOTLIB 1204 /* Not a library file */ -#define DLN_EBADLIB 1205 /* Malformed library file */ -#define DLN_EINIT 1206 /* Not initialized */ - -static int dln_init_p = 0; - -#include <ar.h> -#include <a.out.h> -#ifndef N_COMM -# define N_COMM 0x12 -#endif -#ifndef N_MAGIC -# define N_MAGIC(x) (x).a_magic -#endif - -#define INVALID_OBJECT(h) (N_MAGIC(h) != OMAGIC) - -#include "ruby/util.h" -#include "ruby/st.h" - -static st_table *sym_tbl; -static st_table *undef_tbl; - -static int load_lib(const char *); - -static int -load_header(int fd, struct exec *hdrp, long disp) -{ - int size; - - lseek(fd, disp, 0); - size = read(fd, hdrp, sizeof(struct exec)); - if (size == -1) { - dln_errno = errno; - return -1; - } - if (size != sizeof(struct exec) || N_BADMAG(*hdrp)) { - dln_errno = DLN_ENOEXEC; - return -1; - } - return 0; -} - -#if defined(sequent) -#define RELOC_SYMBOL(r) ((r)->r_symbolnum) -#define RELOC_MEMORY_SUB_P(r) ((r)->r_bsr) -#define RELOC_PCREL_P(r) ((r)->r_pcrel || (r)->r_bsr) -#define RELOC_TARGET_SIZE(r) ((r)->r_length) -#endif - -/* Default macros */ -#ifndef RELOC_ADDRESS -#define RELOC_ADDRESS(r) ((r)->r_address) -#define RELOC_EXTERN_P(r) ((r)->r_extern) -#define RELOC_SYMBOL(r) ((r)->r_symbolnum) -#define RELOC_MEMORY_SUB_P(r) 0 -#define RELOC_PCREL_P(r) ((r)->r_pcrel) -#define RELOC_TARGET_SIZE(r) ((r)->r_length) -#endif - -#if defined(__sun) && defined(__sparc) -/* Sparc (Sun 4) macros */ -# undef relocation_info -# define relocation_info reloc_info_sparc -# define R_RIGHTSHIFT(r) (reloc_r_rightshift[(r)->r_type]) -# define R_BITSIZE(r) (reloc_r_bitsize[(r)->r_type]) -# define R_LENGTH(r) (reloc_r_length[(r)->r_type]) -static const int reloc_r_rightshift[] = { - 0, 0, 0, 0, 0, 0, 2, 2, 10, 0, 0, 0, 0, 0, 0, -}; -static const int reloc_r_bitsize[] = { - 8, 16, 32, 8, 16, 32, 30, 22, 22, 22, 13, 10, 32, 32, 16, -}; -static const int reloc_r_length[] = { - 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -}; -# define R_PCREL(r) \ - ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22) -# define R_SYMBOL(r) ((r)->r_index) -#endif - -#if defined(sequent) -#define R_SYMBOL(r) ((r)->r_symbolnum) -#define R_MEMORY_SUB(r) ((r)->r_bsr) -#define R_PCREL(r) ((r)->r_pcrel || (r)->r_bsr) -#define R_LENGTH(r) ((r)->r_length) -#endif - -#ifndef R_SYMBOL -# define R_SYMBOL(r) ((r)->r_symbolnum) -# define R_MEMORY_SUB(r) 0 -# define R_PCREL(r) ((r)->r_pcrel) -# define R_LENGTH(r) ((r)->r_length) -#endif - -static struct relocation_info * -load_reloc(int fd, struct exec *hdrp, long disp) -{ - struct relocation_info *reloc; - int size; - - lseek(fd, disp + N_TXTOFF(*hdrp) + hdrp->a_text + hdrp->a_data, 0); - size = hdrp->a_trsize + hdrp->a_drsize; - reloc = (struct relocation_info*)xmalloc(size); - if (reloc == NULL) { - dln_errno = errno; - return NULL; (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/