Home | History | Annotate | Line # | Download | only in dlfcn
dlfcn_elf.c revision 1.5.40.1
      1  1.5.40.1     matt /*	$NetBSD: dlfcn_elf.c,v 1.5.40.1 2010/04/21 05:28:08 matt Exp $	*/
      2       1.1  minoura 
      3       1.1  minoura /*
      4       1.1  minoura  * Copyright (c) 2000 Takuya SHIOZAKI
      5       1.1  minoura  * All rights reserved.
      6       1.1  minoura  *
      7       1.1  minoura  * Redistribution and use in source and binary forms, with or without
      8       1.1  minoura  * modification, are permitted provided that the following conditions
      9       1.1  minoura  * are met:
     10       1.1  minoura  * 1. Redistributions of source code must retain the above copyright
     11       1.1  minoura  *    notice, this list of conditions and the following disclaimer.
     12       1.1  minoura  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  minoura  *    notice, this list of conditions and the following disclaimer in the
     14       1.1  minoura  *    documentation and/or other materials provided with the distribution.
     15       1.1  minoura  *
     16       1.1  minoura  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17       1.1  minoura  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18       1.1  minoura  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19       1.1  minoura  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20       1.1  minoura  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21       1.1  minoura  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22       1.1  minoura  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23       1.1  minoura  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24       1.1  minoura  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25       1.1  minoura  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26       1.1  minoura  */
     27       1.1  minoura 
     28       1.1  minoura #include <sys/cdefs.h>
     29       1.1  minoura #if defined(LIBC_SCCS) && !defined(lint)
     30  1.5.40.1     matt __RCSID("$NetBSD: dlfcn_elf.c,v 1.5.40.1 2010/04/21 05:28:08 matt Exp $");
     31       1.1  minoura #endif /* LIBC_SCCS and not lint */
     32       1.1  minoura 
     33       1.1  minoura #include "namespace.h"
     34       1.1  minoura 
     35       1.5  thorpej #undef dlopen
     36       1.5  thorpej #undef dlclose
     37       1.5  thorpej #undef dlsym
     38       1.5  thorpej #undef dlerror
     39       1.5  thorpej #undef dladdr
     40  1.5.40.1     matt #undef dfinfo
     41       1.5  thorpej 
     42       1.5  thorpej #define	dlopen		___dlopen
     43       1.5  thorpej #define	dlclose		___dlclose
     44       1.5  thorpej #define	dlsym		___dlsym
     45       1.5  thorpej #define	dlerror		___dlerror
     46       1.5  thorpej #define	dladdr		___dladdr
     47  1.5.40.1     matt #define	dlinfo		___dlinfo
     48       1.5  thorpej 
     49       1.1  minoura #define ELFSIZE ARCH_ELFSIZE
     50       1.1  minoura #include "rtld.h"
     51       1.1  minoura 
     52       1.1  minoura #ifdef __weak_alias
     53       1.5  thorpej __weak_alias(dlopen,___dlopen)
     54       1.5  thorpej __weak_alias(dlclose,___dlclose)
     55       1.5  thorpej __weak_alias(dlsym,___dlsym)
     56       1.5  thorpej __weak_alias(dlerror,___dlerror)
     57       1.5  thorpej __weak_alias(dladdr,___dladdr)
     58  1.5.40.1     matt __weak_alias(dlinfo,___dlinfo)
     59       1.5  thorpej 
     60       1.5  thorpej __weak_alias(__dlopen,___dlopen)
     61       1.5  thorpej __weak_alias(__dlclose,___dlclose)
     62       1.5  thorpej __weak_alias(__dlsym,___dlsym)
     63       1.5  thorpej __weak_alias(__dlerror,___dlerror)
     64       1.5  thorpej __weak_alias(__dladdr,___dladdr)
     65  1.5.40.1     matt __weak_alias(__dlinfo,___dlinfo)
     66       1.1  minoura #endif
     67       1.1  minoura 
     68       1.4    skrll /*
     69       1.4    skrll  * For ELF, the dynamic linker directly resolves references to its
     70       1.4    skrll  * services to functions inside the dynamic linker itself.  These
     71       1.4    skrll  * weak-symbol stubs are necessary so that "ld" won't complain about
     72       1.4    skrll  * undefined symbols.  The stubs are executed only when the program is
     73       1.4    skrll  * linked statically, or when a given service isn't implemented in the
     74       1.4    skrll  * dynamic linker.  They must return an error if called, and they must
     75       1.4    skrll  * be weak symbols so that the dynamic linker can override them.
     76       1.4    skrll  */
     77       1.4    skrll 
     78       1.4    skrll static char dlfcn_error[] = "Service unavailable";
     79       1.4    skrll 
     80       1.4    skrll /*ARGSUSED*/
     81       1.4    skrll void *
     82       1.4    skrll dlopen(const char *name, int mode)
     83       1.4    skrll {
     84       1.4    skrll 
     85       1.4    skrll 	return NULL;
     86       1.4    skrll }
     87       1.4    skrll 
     88       1.4    skrll /*ARGSUSED*/
     89       1.4    skrll int
     90       1.4    skrll dlclose(void *fd)
     91       1.4    skrll {
     92       1.4    skrll 
     93       1.4    skrll 	return -1;
     94       1.4    skrll }
     95       1.4    skrll 
     96       1.4    skrll /*ARGSUSED*/
     97       1.4    skrll void *
     98       1.4    skrll dlsym(void *handle, const char *name)
     99       1.4    skrll {
    100       1.4    skrll 
    101       1.4    skrll 	return NULL;
    102       1.4    skrll }
    103       1.4    skrll 
    104       1.4    skrll /*ARGSUSED*/
    105       1.4    skrll __aconst char *
    106       1.4    skrll dlerror()
    107       1.4    skrll {
    108       1.4    skrll 
    109       1.4    skrll 	return dlfcn_error;
    110       1.4    skrll }
    111       1.4    skrll 
    112       1.4    skrll /*ARGSUSED*/
    113       1.4    skrll int
    114       1.4    skrll dladdr(const void *addr, Dl_info *dli)
    115       1.4    skrll {
    116       1.4    skrll 
    117       1.4    skrll 	return 0;
    118       1.4    skrll }
    119  1.5.40.1     matt 
    120  1.5.40.1     matt /*ARGSUSED*/
    121  1.5.40.1     matt int
    122  1.5.40.1     matt dlinfo(void *handle, int req, void *v)
    123  1.5.40.1     matt {
    124  1.5.40.1     matt 
    125  1.5.40.1     matt 	return -1;
    126  1.5.40.1     matt }
    127