Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/sys/linux/dl')
-rw-r--r--newlib/libc/sys/linux/dl/dl-cache.c2
-rw-r--r--newlib/libc/sys/linux/dl/dl-load.c4
-rw-r--r--newlib/libc/sys/linux/dl/dl-local.h65
-rw-r--r--newlib/libc/sys/linux/dl/dl-open.c4
-rw-r--r--newlib/libc/sys/linux/dl/dl-reloc.c52
-rw-r--r--newlib/libc/sys/linux/dl/dl-runtime.c4
-rw-r--r--newlib/libc/sys/linux/dl/dlfcn.h84
-rw-r--r--newlib/libc/sys/linux/dl/do-rel.h10
-rw-r--r--newlib/libc/sys/linux/dl/dynamic-link.h25
-rw-r--r--newlib/libc/sys/linux/dl/ldsodefs.h3
10 files changed, 129 insertions, 124 deletions
diff --git a/newlib/libc/sys/linux/dl/dl-cache.c b/newlib/libc/sys/linux/dl/dl-cache.c
index 9511da13f..a71e5e876 100644
--- a/newlib/libc/sys/linux/dl/dl-cache.c
+++ b/newlib/libc/sys/linux/dl/dl-cache.c
@@ -208,7 +208,7 @@ _dl_load_cache_lookup (const char *name)
/* This file ends in static libraries where we don't have a hwcap. */
unsigned long int *hwcap;
uint64_t platform;
- #pragma weak _dl_hwcap
+ weak_extern (_dl_hwcap);
/* This is where the strings start. */
cache_data = (const char *) cache_new;
diff --git a/newlib/libc/sys/linux/dl/dl-load.c b/newlib/libc/sys/linux/dl/dl-load.c
index 4e32d604b..65b72c729 100644
--- a/newlib/libc/sys/linux/dl/dl-load.c
+++ b/newlib/libc/sys/linux/dl/dl-load.c
@@ -1095,7 +1095,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
}
else
/* Adjust the PT_PHDR value by the runtime load address. */
- l->l_phdr = (ElfW(Addr)) l->l_phdr + l->l_addr;
+ (ElfW(Addr)) l->l_phdr += l->l_addr;
}
/* We are done mapping in the file. We no longer need the descriptor. */
@@ -1115,7 +1115,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
}
}
else
- l->l_ld = (ElfW(Addr)) l->l_ld + l->l_addr;
+ (ElfW(Addr)) l->l_ld += l->l_addr;
l->l_entry += l->l_addr;
diff --git a/newlib/libc/sys/linux/dl/dl-local.h b/newlib/libc/sys/linux/dl/dl-local.h
deleted file mode 100644
index 3629ab94c..000000000
--- a/newlib/libc/sys/linux/dl/dl-local.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef _LOCAL_H
-#include <dlfcn.h>
-
-#define internal_function
-
-/* Internally used flag. */
-#define __RTLD_DLOPEN 0x80000000
-#define __RTLD_SPROF 0x40000000
-
-/* Now define the internal interfaces. */
-extern void *__dlvsym (void *__handle, __const char *__name,
- __const char *__version);
-
-extern void *__libc_dlopen (__const char *__name);
-extern void *__libc_dlsym (void *__map, __const char *__name);
-extern int __libc_dlclose (void *__map);
-
-/* Locate shared object containing the given address. */
-extern int _dl_addr (const void *address, Dl_info *info)
- internal_function;
-
-/* Open the shared object NAME, relocate it, and run its initializer if it
- hasn't already been run. MODE is as for `dlopen' (see <dlfcn.h>). If
- the object is already opened, returns its existing map. */
-extern void *_dl_open (const char *name, int mode, const void *caller)
- internal_function;
-
-/* Close an object previously opened by _dl_open. */
-extern void _dl_close (void *map)
- internal_function;
-
-/* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
- RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
- the symbol value, which may be NULL. */
-extern void *_dl_sym (void *handle, const char *name, void *who)
- internal_function;
-
-/* Look up version VERSION of symbol NAME in shared object HANDLE
- (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
- function, for RTLD_NEXT. Returns the symbol value, which may be
- NULL. */
-extern void *_dl_vsym (void *handle, const char *name, const char *version,
- void *who)
- internal_function;
-
-/* Call OPERATE, catching errors from `dl_signal_error'. If there is no
- error, *ERRSTRING is set to null. If there is an error, *ERRSTRING is
- set to a string constructed from the strings passed to _dl_signal_error,
- and the error code passed is the return value and *OBJNAME is set to
- the object name which experienced the problems. ERRSTRING if nonzero
- points to a malloc'ed string which the caller has to free after use.
- ARGS is passed as argument to OPERATE. */
-extern int _dl_catch_error (const char **objname, const char **errstring,
- void (*operate) (void *),
- void *args)
- internal_function;
-
-/* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
- _dl_catch_error. Returns zero for success, nonzero for failure; and
- arranges for `dlerror' to return the error details.
- ARGS is passed as argument to OPERATE. */
-extern int _dlerror_run (void (*operate) (void *), void *args)
- internal_function;
-
-#endif
diff --git a/newlib/libc/sys/linux/dl/dl-open.c b/newlib/libc/sys/linux/dl/dl-open.c
index 4e068d435..195361427 100644
--- a/newlib/libc/sys/linux/dl/dl-open.c
+++ b/newlib/libc/sys/linux/dl/dl-open.c
@@ -36,8 +36,8 @@
extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
void (*dl_main) (const ElfW(Phdr) *phdr,
ElfW(Word) phnum,
- ElfW(Addr) *user_entry))
- weak_function;
+ ElfW(Addr) *user_entry));
+weak_extern (BP_SYM (_dl_sysdep_start))
/* This function is used to unload the cache file if necessary. */
extern void _dl_unload_cache (void);
diff --git a/newlib/libc/sys/linux/dl/dl-reloc.c b/newlib/libc/sys/linux/dl/dl-reloc.c
index 0bffa4e76..94163143e 100644
--- a/newlib/libc/sys/linux/dl/dl-reloc.c
+++ b/newlib/libc/sys/linux/dl/dl-reloc.c
@@ -105,47 +105,50 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
{
/* Do the actual relocation of the object's GOT and other data. */
+ /* String table object symbols. */
+ const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
+
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
-#define RESOLVE_MAP(ref, version, r_type, scope) \
+#define RESOLVE_MAP(ref, version, r_type) \
(ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \
- ? ((__builtin_expect ((*ref) == map->l_lookup_cache.sym, 0) \
- && elf_machine_type_class (r_type) == map->l_lookup_cache.type_class)\
+ ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0) \
+ && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class) \
? (++_dl_num_cache_relocations, \
- (*ref) = map->l_lookup_cache.ret, \
- map->l_lookup_cache.value) \
+ (*ref) = l->l_lookup_cache.ret, \
+ l->l_lookup_cache.value) \
: ({ lookup_t _lr; \
int _tc = elf_machine_type_class (r_type); \
- map->l_lookup_cache.type_class = _tc; \
- map->l_lookup_cache.sym = (*ref); \
+ l->l_lookup_cache.type_class = _tc; \
+ l->l_lookup_cache.sym = (*ref); \
_lr = ((version) != NULL && (version)->hash != 0 \
? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \
- map, (ref), scope, \
+ l, (ref), scope, \
(version), _tc, 0) \
- : _dl_lookup_symbol (strtab + (*ref)->st_name, map, (ref),\
+ : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \
scope, _tc, 0)); \
- map->l_lookup_cache.ret = (*ref); \
- map->l_lookup_cache.value = _lr; })) \
- : map)
-#define RESOLVE(ref, version, r_type, scope) \
+ l->l_lookup_cache.ret = (*ref); \
+ l->l_lookup_cache.value = _lr; })) \
+ : l)
+#define RESOLVE(ref, version, r_type) \
(ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \
- ? ((__builtin_expect ((*ref) == map->l_lookup_cache.sym, 0) \
- && elf_machine_type_class (r_type) == map->l_lookup_cache.type_class)\
+ ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0) \
+ && elf_machine_type_class (r_type) == l->l_lookup_cache.type_class) \
? (++_dl_num_cache_relocations, \
- (*ref) = map->l_lookup_cache.ret, \
- map->l_lookup_cache.value) \
+ (*ref) = l->l_lookup_cache.ret, \
+ l->l_lookup_cache.value) \
: ({ lookup_t _lr; \
int _tc = elf_machine_type_class (r_type); \
- map->l_lookup_cache.type_class = _tc; \
- map->l_lookup_cache.sym = (*ref); \
+ l->l_lookup_cache.type_class = _tc; \
+ l->l_lookup_cache.sym = (*ref); \
_lr = ((version) != NULL && (version)->hash != 0 \
? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \
- map, (ref), scope, \
+ l, (ref), scope, \
(version), _tc, 0) \
- : _dl_lookup_symbol (strtab + (*ref)->st_name, map, (ref),\
+ : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \
scope, _tc, 0)); \
- map->l_lookup_cache.ret = (*ref); \
- map->l_lookup_cache.value = _lr; })) \
- : map->l_addr)
+ l->l_lookup_cache.ret = (*ref); \
+ l->l_lookup_cache.value = _lr; })) \
+ : l->l_addr)
#include "dynamic-link.h"
@@ -194,7 +197,6 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
}
}
-#include <machine/dl-machine.h>
void
internal_function
diff --git a/newlib/libc/sys/linux/dl/dl-runtime.c b/newlib/libc/sys/linux/dl/dl-runtime.c
index 4fb81cfaf..403091d2e 100644
--- a/newlib/libc/sys/linux/dl/dl-runtime.c
+++ b/newlib/libc/sys/linux/dl/dl-runtime.c
@@ -46,7 +46,7 @@
function. */
#ifndef ELF_MACHINE_NO_PLT
-static ElfW(Addr) __attribute__ ((regparm (2), used))
+static ElfW(Addr) __attribute__ ((regparm (2), unused))
fixup (
# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
ELF_MACHINE_RUNTIME_FIXUP_ARGS,
@@ -130,7 +130,7 @@ fixup (
#if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__
-static ElfW(Addr) __attribute__ ((regparm (3), used))
+static ElfW(Addr) __attribute__ ((regparm (3), unused))
profile_fixup (
#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
ELF_MACHINE_RUNTIME_FIXUP_ARGS,
diff --git a/newlib/libc/sys/linux/dl/dlfcn.h b/newlib/libc/sys/linux/dl/dlfcn.h
new file mode 100644
index 000000000..67ba73d5d
--- /dev/null
+++ b/newlib/libc/sys/linux/dl/dlfcn.h
@@ -0,0 +1,84 @@
+/* User functions for run-time dynamic loading.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _DLFCN_H
+#define _DLFCN_H 1
+
+#include <features.h>
+
+/* Collect various system dependent definitions and declarations. */
+#include <sys/dlfcn.h>
+
+
+/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
+ the run-time address of the symbol called NAME in the next shared
+ object is returned. The "next" relation is defined by the order
+ the shared objects were loaded. */
+# define RTLD_NEXT ((void *) -1l)
+
+/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
+ the run-time address of the symbol called NAME in the global scope
+ is returned. */
+# define RTLD_DEFAULT ((void *) 0)
+
+
+__BEGIN_DECLS
+
+/* Open the shared object FILE and map it in; return a handle that can be
+ passed to `dlsym' to get symbol values from it. */
+extern void *dlopen (__const char *__file, int __mode) __THROW;
+
+/* Unmap and close a shared object opened by `dlopen'.
+ The handle cannot be used again after calling `dlclose'. */
+extern int dlclose (void *__handle) __THROW;
+
+/* Find the run-time address in the shared object HANDLE refers to
+ of the symbol called NAME. */
+extern void *dlsym (void *__restrict __handle,
+ __const char *__restrict __name) __THROW;
+
+/* Find the run-time address in the shared object HANDLE refers to
+ of the symbol called NAME with VERSION. */
+extern void *dlvsym (void *__restrict __handle,
+ __const char *__restrict __name,
+ __const char *__restrict __version) __THROW;
+
+/* When any of the above functions fails, call this function
+ to return a string describing the error. Each call resets
+ the error string so that a following call returns null. */
+extern char *dlerror (void) __THROW;
+
+
+/* Structure containing information about object searched using
+ `dladdr'. */
+typedef struct
+{
+ __const char *dli_fname; /* File name of defining object. */
+ void *dli_fbase; /* Load address of that object. */
+ __const char *dli_sname; /* Name of nearest symbol. */
+ void *dli_saddr; /* Exact value of nearest symbol. */
+} Dl_info;
+
+/* Fill in *INFO with the following information about ADDRESS.
+ Returns 0 iff no shared object's segments contain that address. */
+extern int dladdr (__const void *__address, Dl_info *__info) __THROW;
+
+__END_DECLS
+
+#endif /* dlfcn.h */
diff --git a/newlib/libc/sys/linux/dl/do-rel.h b/newlib/libc/sys/linux/dl/do-rel.h
index 03b9e807b..46202d704 100644
--- a/newlib/libc/sys/linux/dl/do-rel.h
+++ b/newlib/libc/sys/linux/dl/do-rel.h
@@ -44,8 +44,7 @@
static inline void
elf_dynamic_do_rel (struct link_map *map,
ElfW(Addr) reladdr, ElfW(Addr) relsize,
- int lazy,
- struct r_scope_elem *scope[])
+ int lazy)
{
const ElfW(Rel) *r = (const void *) reladdr;
const ElfW(Rel) *end = (const void *) (reladdr + relsize);
@@ -78,7 +77,7 @@ elf_dynamic_do_rel (struct link_map *map,
RTLD_BOOTSTRAP) because rtld.c contains the common defn for
_dl_rtld_map, which is incompatible with a weak decl in the same
file. */
- #pragma weak _dl_rtld_map
+ weak_extern (_dl_rtld_map);
if (map != &_dl_rtld_map) /* Already done in rtld itself. */
# ifndef DO_RELA
/* Rela platforms get the offset from r_addend and this must
@@ -102,14 +101,13 @@ elf_dynamic_do_rel (struct link_map *map,
ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)];
elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
&map->l_versions[ndx],
- (void *) (l_addr + r->r_offset),
- scope);
+ (void *) (l_addr + r->r_offset));
}
}
else
for (; r < end; ++r)
elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
- (void *) (l_addr + r->r_offset), scope);
+ (void *) (l_addr + r->r_offset));
}
}
diff --git a/newlib/libc/sys/linux/dl/dynamic-link.h b/newlib/libc/sys/linux/dl/dynamic-link.h
index c1709f7c6..a63fded89 100644
--- a/newlib/libc/sys/linux/dl/dynamic-link.h
+++ b/newlib/libc/sys/linux/dl/dynamic-link.h
@@ -17,9 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#ifndef __DYNAMIC_LINK_H__
-#define __DYNAMIC_LINK_H__
-
#include <elf.h>
#include <machine/dl-machine.h>
#include <assert.h>
@@ -36,7 +33,7 @@ extern int _dl_verbose __attribute__ ((unused));
/* Read the dynamic section at DYN and fill in INFO with indices DT_*. */
-static void __attribute__ ((unused))
+static inline void __attribute__ ((unused))
elf_get_dynamic_info (struct link_map *l)
{
ElfW(Dyn) *dyn = l->l_ld;
@@ -124,17 +121,6 @@ elf_get_dynamic_info (struct link_map *l)
info[DT_RPATH] = NULL;
}
-# if ! ELF_MACHINE_NO_REL
-# include "do-rel.h"
-# endif
-
-# if ! ELF_MACHINE_NO_RELA
-# define DO_RELA
-# include "do-rel.h"
-# endif
-
-#endif /* __DYNAMIC_LINK_H__ */
-
#ifdef RESOLVE
/* Get the definitions of `elf_dynamic_do_rel' and `elf_dynamic_do_rela'.
@@ -178,8 +164,7 @@ elf_get_dynamic_info (struct link_map *l)
elf_dynamic_do_##reloc ((map), \
ranges[ranges_index].start, \
ranges[ranges_index].size, \
- ranges[ranges_index].lazy, \
- scope); \
+ ranges[ranges_index].lazy); \
} while (0)
# else
# define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel) \
@@ -219,8 +204,7 @@ elf_get_dynamic_info (struct link_map *l)
elf_dynamic_do_##reloc ((map), \
ranges[ranges_index].start, \
ranges[ranges_index].size, \
- ranges[ranges_index].lazy, \
- scope); \
+ ranges[ranges_index].lazy); \
} while (0)
# endif
@@ -231,6 +215,7 @@ elf_get_dynamic_info (struct link_map *l)
# endif
# if ! ELF_MACHINE_NO_REL
+# include "do-rel.h"
# define ELF_DYNAMIC_DO_REL(map, lazy) \
_ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
# else
@@ -238,6 +223,8 @@ elf_get_dynamic_info (struct link_map *l)
# endif
# if ! ELF_MACHINE_NO_RELA
+# define DO_RELA
+# include "do-rel.h"
# define ELF_DYNAMIC_DO_RELA(map, lazy) \
_ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
# else
diff --git a/newlib/libc/sys/linux/dl/ldsodefs.h b/newlib/libc/sys/linux/dl/ldsodefs.h
index e6f57ddcf..f24e1136b 100644
--- a/newlib/libc/sys/linux/dl/ldsodefs.h
+++ b/newlib/libc/sys/linux/dl/ldsodefs.h
@@ -28,12 +28,11 @@
#include <string.h>
#include <elf.h>
+#include <dlfcn.h>
#include <link.h>
#include <dl-lookupcfg.h>
#include <bits/libc-lock.h>
-#include "dl-local.h"
-
__BEGIN_DECLS
/* We use this macro to refer to ELF types independent of the native wordsize.