mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-04 10:50:07 +00:00
Un-nest nested functions in dynamic linker
This commit is contained in:
parent
e08a64e708
commit
22bef64863
@ -27,17 +27,8 @@
|
||||
#include <sys/types.h>
|
||||
#include "dynamic-link.h"
|
||||
|
||||
void
|
||||
_dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
|
||||
ElfW(Rela) *conflictend)
|
||||
{
|
||||
#if ! ELF_MACHINE_NO_RELA
|
||||
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC))
|
||||
_dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name));
|
||||
#ifndef NESTING
|
||||
|
||||
{
|
||||
/* Do the conflict relocation of the object and library GOT and other
|
||||
data. */
|
||||
|
||||
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
|
||||
#define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
|
||||
@ -51,13 +42,49 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
|
||||
(map) = resolve_conflict_map; \
|
||||
} while (0)
|
||||
|
||||
#include "dynamic-link.h"
|
||||
|
||||
#endif /* n NESTING */
|
||||
|
||||
void
|
||||
_dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
|
||||
ElfW(Rela) *conflictend)
|
||||
{
|
||||
#if ! ELF_MACHINE_NO_RELA
|
||||
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC))
|
||||
_dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name));
|
||||
|
||||
{
|
||||
/* Do the conflict relocation of the object and library GOT and other
|
||||
data. */
|
||||
|
||||
#ifdef NESTING
|
||||
|
||||
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
|
||||
#define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
|
||||
#define RESOLVE(ref, version, flags) (*ref = NULL, 0)
|
||||
#define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \
|
||||
do { \
|
||||
while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset)) \
|
||||
|| (resolve_conflict_map->l_map_start > (ElfW(Addr)) (r_offset))) \
|
||||
resolve_conflict_map = resolve_conflict_map->l_next; \
|
||||
\
|
||||
(map) = resolve_conflict_map; \
|
||||
} while (0)
|
||||
|
||||
#endif /* NESTING */
|
||||
|
||||
/* Prelinking makes no sense for anything but the main namespace. */
|
||||
assert (l->l_ns == LM_ID_BASE);
|
||||
struct link_map *resolve_conflict_map __attribute__ ((__unused__))
|
||||
= GL(dl_ns)[LM_ID_BASE]._ns_loaded;
|
||||
|
||||
#ifdef NESTING
|
||||
|
||||
#include "dynamic-link.h"
|
||||
|
||||
#endif /* NESTING */
|
||||
|
||||
/* Override these, defined in dynamic-link.h. */
|
||||
#undef CHECK_STATIC_TLS
|
||||
#define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0)
|
||||
|
@ -141,6 +141,40 @@ _dl_nothread_init_static_tls (struct link_map *map)
|
||||
'\0', map->l_tls_blocksize - map->l_tls_initimage_size);
|
||||
}
|
||||
|
||||
#ifndef NESTING
|
||||
|
||||
/* String table object symbols. */
|
||||
|
||||
static struct link_map *glob_l;
|
||||
static struct r_scope_elem **glob_scope;
|
||||
static const char *glob_strtab;
|
||||
|
||||
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
|
||||
#define RESOLVE_MAP(ref, version, r_type) \
|
||||
((ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \
|
||||
&& __glibc_likely (!dl_symbol_visibility_binds_local_p (*ref))) \
|
||||
? ((__builtin_expect ((*ref) == glob_l->l_lookup_cache.sym, 0) \
|
||||
&& elf_machine_type_class (r_type) == glob_l->l_lookup_cache.type_class) \
|
||||
? (bump_num_cache_relocations (), \
|
||||
(*ref) = glob_l->l_lookup_cache.ret, \
|
||||
glob_l->l_lookup_cache.value) \
|
||||
: ({ lookup_t _lr; \
|
||||
int _tc = elf_machine_type_class (r_type); \
|
||||
glob_l->l_lookup_cache.type_class = _tc; \
|
||||
glob_l->l_lookup_cache.sym = (*ref); \
|
||||
const struct r_found_version *v = NULL; \
|
||||
if ((version) != NULL && (version)->hash != 0) \
|
||||
v = (version); \
|
||||
_lr = _dl_lookup_symbol_x (glob_strtab + (*ref)->st_name, glob_l, (ref), \
|
||||
glob_scope, v, _tc, \
|
||||
DL_LOOKUP_ADD_DEPENDENCY, NULL); \
|
||||
glob_l->l_lookup_cache.ret = (*ref); \
|
||||
glob_l->l_lookup_cache.value = _lr; })) \
|
||||
: glob_l)
|
||||
|
||||
#include "dynamic-link.h"
|
||||
|
||||
#endif /* n NESTING */
|
||||
|
||||
void
|
||||
_dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
||||
@ -227,6 +261,8 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
||||
{
|
||||
/* Do the actual relocation of the object's GOT and other data. */
|
||||
|
||||
#ifdef NESTING
|
||||
|
||||
/* String table object symbols. */
|
||||
const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
|
||||
|
||||
@ -255,6 +291,14 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
||||
|
||||
#include "dynamic-link.h"
|
||||
|
||||
#else
|
||||
|
||||
glob_l = l;
|
||||
glob_scope = scope;
|
||||
glob_strtab = (const void *) D_PTR (glob_l, l_info[DT_STRTAB]);
|
||||
|
||||
#endif /* NESTING */
|
||||
|
||||
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
|
||||
|
||||
#ifndef PROF
|
||||
|
@ -16,6 +16,10 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef NESTING
|
||||
#define auto static
|
||||
#endif
|
||||
|
||||
/* This macro is used as a callback from elf_machine_rel{a,} when a
|
||||
static TLS reloc is about to be performed. Since (in dl-load.c) we
|
||||
permit dynamic loading of objects that might use such relocs, we
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <assert.h>
|
||||
#include <libc-diag.h>
|
||||
|
||||
#if defined NESTING || !defined SAW_EGDI
|
||||
|
||||
#ifndef RESOLVE_MAP
|
||||
static
|
||||
#else
|
||||
@ -184,3 +186,11 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
|
||||
info[DT_RPATH] = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NESTING
|
||||
#ifndef SAW_EGDI
|
||||
#define SAW_EGDI
|
||||
#endif
|
||||
#endif /* n NESTING */
|
||||
|
36
elf/rtld.c
36
elf/rtld.c
@ -324,7 +324,7 @@ DL_SYSINFO_IMPLEMENTATION
|
||||
is fine, too. The latter is important here. We can avoid setting
|
||||
up a temporary link map for ld.so if we can mark _rtld_global as
|
||||
hidden. */
|
||||
#ifdef PI_STATIC_AND_HIDDEN
|
||||
#if 0 //def PI_STATIC_AND_HIDDEN
|
||||
# define DONT_USE_BOOTSTRAP_MAP 1
|
||||
#endif
|
||||
|
||||
@ -439,9 +439,27 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
|
||||
return start_addr;
|
||||
}
|
||||
|
||||
#ifndef NESTING
|
||||
#ifdef DONT_USE_BOOTSTRAP_MAP
|
||||
# define bootstrap_map GL(dl_rtld_map)
|
||||
#else
|
||||
struct dl_start_final_info info;
|
||||
# define bootstrap_map info.l
|
||||
#endif
|
||||
|
||||
/* This #define produces dynamic linking inline functions for
|
||||
bootstrap relocation instead of general-purpose relocation.
|
||||
Since ld.so must not have any undefined symbols the result
|
||||
is trivial: always the map of ld.so itself. */
|
||||
#define RTLD_BOOTSTRAP
|
||||
#define RESOLVE_MAP(sym, version, flags) (&bootstrap_map)
|
||||
#include "dynamic-link.h"
|
||||
#endif /* n NESTING */
|
||||
|
||||
static ElfW(Addr) __attribute_used__
|
||||
_dl_start (void *arg)
|
||||
{
|
||||
#ifdef NESTING
|
||||
#ifdef DONT_USE_BOOTSTRAP_MAP
|
||||
# define bootstrap_map GL(dl_rtld_map)
|
||||
#else
|
||||
@ -457,6 +475,7 @@ _dl_start (void *arg)
|
||||
#define BOOTSTRAP_MAP (&bootstrap_map)
|
||||
#define RESOLVE_MAP(sym, version, flags) BOOTSTRAP_MAP
|
||||
#include "dynamic-link.h"
|
||||
#endif /* NESTING */
|
||||
|
||||
if (HP_TIMING_INLINE && HP_SMALL_TIMING_AVAIL)
|
||||
#ifdef DONT_USE_BOOTSTRAP_MAP
|
||||
@ -2785,3 +2804,18 @@ print_statistics (hp_timing_t *rtld_total_timep)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NESTING
|
||||
char *dummy1 = (char *)elf_get_dynamic_info;
|
||||
# if ! ELF_MACHINE_NO_REL
|
||||
char *dummy2 = (char *)elf_machine_rel;
|
||||
char *dummy3 = (char *)elf_machine_rel_relative;
|
||||
#endif
|
||||
# if ! ELF_MACHINE_NO_RELA
|
||||
char *dummy4 = (char *)elf_machine_rela;
|
||||
char *dummy5 = (char *)elf_machine_rela_relative;
|
||||
#endif
|
||||
# if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
|
||||
char *dummy6 = (char *)elf_machine_lazy_rel;
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user