Home | History | Annotate | Line # | Download | only in dlfcn
dlfcn_elf.c revision 1.2.4.2
      1  1.2.4.2      tron /*	$NetBSD: dlfcn_elf.c,v 1.2.4.2 2004/05/28 09:01:18 tron 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.2.4.2      tron __RCSID("$NetBSD: dlfcn_elf.c,v 1.2.4.2 2004/05/28 09:01:18 tron 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.1   minoura #define ELFSIZE ARCH_ELFSIZE
     36      1.1   minoura #include "rtld.h"
     37      1.1   minoura 
     38      1.1   minoura #ifdef __weak_alias
     39      1.2  christos __weak_alias(dlopen,__dlopen)
     40      1.2  christos __weak_alias(dlclose,__dlclose)
     41      1.2  christos __weak_alias(dlsym,__dlsym)
     42      1.2  christos __weak_alias(dlerror,__dlerror)
     43      1.2  christos __weak_alias(dladdr,__dladdr)
     44      1.1   minoura #endif
     45      1.1   minoura 
     46  1.2.4.2      tron /*
     47  1.2.4.2      tron  * For ELF, the dynamic linker directly resolves references to its
     48  1.2.4.2      tron  * services to functions inside the dynamic linker itself.  These
     49  1.2.4.2      tron  * weak-symbol stubs are necessary so that "ld" won't complain about
     50  1.2.4.2      tron  * undefined symbols.  The stubs are executed only when the program is
     51  1.2.4.2      tron  * linked statically, or when a given service isn't implemented in the
     52  1.2.4.2      tron  * dynamic linker.  They must return an error if called, and they must
     53  1.2.4.2      tron  * be weak symbols so that the dynamic linker can override them.
     54  1.2.4.2      tron  */
     55  1.2.4.2      tron 
     56  1.2.4.2      tron static char dlfcn_error[] = "Service unavailable";
     57  1.2.4.2      tron 
     58  1.2.4.2      tron /*ARGSUSED*/
     59  1.2.4.2      tron void *
     60  1.2.4.2      tron dlopen(const char *name, int mode)
     61  1.2.4.2      tron {
     62  1.2.4.2      tron 
     63  1.2.4.2      tron 	return NULL;
     64  1.2.4.2      tron }
     65  1.2.4.2      tron 
     66  1.2.4.2      tron /*ARGSUSED*/
     67  1.2.4.2      tron int
     68  1.2.4.2      tron dlclose(void *fd)
     69  1.2.4.2      tron {
     70  1.2.4.2      tron 
     71  1.2.4.2      tron 	return -1;
     72  1.2.4.2      tron }
     73  1.2.4.2      tron 
     74  1.2.4.2      tron /*ARGSUSED*/
     75  1.2.4.2      tron void *
     76  1.2.4.2      tron dlsym(void *handle, const char *name)
     77  1.2.4.2      tron {
     78  1.2.4.2      tron 
     79  1.2.4.2      tron 	return NULL;
     80  1.2.4.2      tron }
     81  1.2.4.2      tron 
     82  1.2.4.2      tron /*ARGSUSED*/
     83  1.2.4.2      tron __aconst char *
     84  1.2.4.2      tron dlerror()
     85  1.2.4.2      tron {
     86  1.2.4.2      tron 
     87  1.2.4.2      tron 	return dlfcn_error;
     88  1.2.4.2      tron }
     89  1.2.4.2      tron 
     90  1.2.4.2      tron /*ARGSUSED*/
     91  1.2.4.2      tron int
     92  1.2.4.2      tron dladdr(const void *addr, Dl_info *dli)
     93  1.2.4.2      tron {
     94  1.2.4.2      tron 
     95  1.2.4.2      tron 	return 0;
     96  1.2.4.2      tron }
     97