mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-20 09:41:18 +00:00
f41c80910d
1997-08-24 12:24 Ulrich Drepper <drepper@cygnus.com> * configure.in (INSTALL): Quote `$'. * libc.map: Add __xpg_basename. * csu/Makefile (initfini.s): Disable optimization. * elf/dl-deps.c: Implement handling of DL_FILTER. * elf/dl-load.c (_dl_init_paths): Add error check. * intl/finddomain.c (_nl_find_domain): Correct comment. * intl/localealias.c: Include <bits/libc-lock.h> not <libc-lock.h>. * libio/stdio.h: Make {,v}snprintf available if __USE_BSD. Change extern inline functions to work correctly in C++. * locale/iso-4217.def: Update for more recent ISO 4217 version. * locale/loadlocale.c (_nl_load_locale): Add cast. * manual/message.texi: Finish gettext section. * posix/getopt_init.c: Don't use relative #include path. (__getopt_clean_environment): Change function to take pointer to environment as argument. Optimize generation of test string a bit. * sysdeps/unix/sysv/linux/init-first.c: Call __getopt_clean_environment with additional argument. * poisx/glob.c: Add prototype for next_brace_sub. * sysdeps/generic/dl-sysdep.c: Recognize AT_BASE value on auxiliary vector. * sysdeps/i386/dl-machine.h (elf_machine_load_address): Rewrite to not generate relocation entry. Suggested by Richard Henderson. (ELF_MACHINE_BEFORE_RTLD_RELOC): Removed. (elf_machine_runtime_setup): Add .aligns. * sysdeps/i386/fpu/fraiseexcpt.c: Add volatile to asms. * sysdeps/i386/fpu/bits/mathinline.h: Partially undo change of 1997-08-14 03:14. gcc 2.7.2* is really broken in some aspects. * sysdeps/standalone/i386/i386.h: Clean up asm statements a bit. * sysdeps/standalone/i960/i960ca.h: Likewise. 1997-08-22 19:04 Richard Henderson <rth@cygnus.com> * elf/rtld.c (_dl_start): Init _dl_rtld_map.l_opencount due to undocumented test addition in _dl_map_object. Support ET_EXEC versions of ld.so, for debugging at least: * elf/dl-load.c (_dl_map_object): Add_name_to_object could get called despite the DT_SONAME != NULL test, segfaulting. Simplify the code here as well. * elf/dl-lookup.c (do_lookup): Skip objects with no symtab. (_dl_setup_hash): Likewise for hash tables. * elf/dl-version.c (_dl_check_map_versions): Likewise for strtabs. * elf/rtld.c (_dl_start): Likewise for rpath. (_dl_rtld_libname2): New variable. (dl_main): Use it to add an soname for ourselves when we don't have one of our own. Base it on the target's .interp. (dl_main): Again, skip printing of objects that don't have strtabs. Sparc 32 merge: * elf/dl-runtime.c (ELF_FIXUP_RETURN_VALUE): Provide default value. (fixup): Simplify code. Use ELF_FIXUP_RETURN_VALUE. (profile_fixup): Likewise, though this still needs fixing for Sparc32 and PPC. * sysdeps/powerpc/dl-machine.h: Transmute ELF_FIXUP_RETURNS_ADDRESS to ELF_FIXUP_RETURN_VALUE. * sysdeps/sparc/sparc32/dl-machine.h: Implement lazy relocation. Fix up _dl_start_user to handle _dl_skip_args properly. Use _dl_hwcap to determine if "flush" is available/needed. * sysdeps/sparc/configure.in: Remove. It doesn't actually do anything anymore, and what it did do is done somewhere else. * sysdeps/sparc/configure: Likewise. * sysdeps/sparc/fpu/bits/mathdef.h (FP_ILOGB0, FP_ILOGBNAN): New. * sysdeps/sparc/fpu/fraiseexcpt.c: Rearrange for smaller code. * sysdeps/sparc/sparc32/Makefile: Fix sparc->sparc/sparc32 bits in divrem expansions. * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h (END, LOC): New definitions for assembly syntax differences. * sysdeps/sparc/sparc32/__longjmp.S: %g6,%g7 are reserved to the "system". Use %g2,%g3 instead. Use new local label macro. * sysdeps/sparc/sparc32/add_n.S: Use <sysdep.h> and ENTRY, END, and LOC for proper assembly headers/footers. * sysdeps/sparc/sparc32/addmul_1.S: Likewise. * sysdeps/sparc/sparc32/alloca.S: Likewise. * sysdeps/sparc/sparc32/dotmul.S: Likewise. * sysdeps/sparc/sparc32/lshift.S: Likewise. * sysdeps/sparc/sparc32/mul_1.S: Likewise. * sysdeps/sparc/sparc32/rshift.S: Likewise. * sysdeps/sparc/sparc32/sparcv8/addmul_1.S: Likewise. * sysdeps/sparc/sparc32/sparcv8/mul_1.S: Likewise. * sysdeps/sparc/sparc32/sparcv8/submul_1.S: Likewise. * sysdeps/sparc/sparc32/sparcv8/udiv_qrnnd.S: Likewise. * sysdeps/sparc/sparc32/sub_n.S: Likewise. * sysdeps/sparc/sparc32/submul_1.S: Likewise. * sysdeps/sparc/sparc32/udiv_qrnnd.S: Likewise. * sysdeps/sparc/sparc32/umul.S: Likewise. * sysdeps/sparc/sparc32/divrem.m4: Likewise. * sysdeps/sparc/sparc32/rem.S: Regenerate. * sysdeps/sparc/sparc32/sdiv.S: Regenerate. * sysdeps/sparc/sparc32/udiv.S: Regenerate. * sysdeps/sparc/sparc32/urem.S: Regenerate. * sysdeps/sparc/sparc32/sparcv8/dotmul.S: New file. * sysdeps/sparc/sparc32/sparcv8/rem.S: New file. * sysdeps/sparc/sparc32/sparcv8/sdiv.S: New file. * sysdeps/sparc/sparc32/sparcv8/udiv.S: New file. * sysdeps/sparc/sparc32/sparcv8/umul.S: New file. * sysdeps/sparc/sparc32/sparcv8/urem.S: New file. * sysdeps/sparc/sparc32/bsd-_setjmp.S: Dike out. * sysdeps/sparc/sparc32/bsd-setjmp.S: Likewise. * sysdeps/sparc/sparc32/setjmp.S: Add _setjmp and setjmp entry points. * sysdeps/unix/sysv/linux/sparc/sparc32/__sigtrampoline.S: Clean up PIC code. * sysdeps/sparc/sparc32/elf/start.S: New file, slightly modified from the sparc64 version. * sysdeps/sparc/sparc32/elf/start.c: Removed. * sysdeps/unix/sysv/linux/sparc/sparc32/init-first.h: Rewrite in assembly based on the sparc64 version. * sysdeps/sparc/sparc32/fpu/bits/fenv.h: Duh. Use proper syntax for manipulating %fsr. * sysdeps/sparc/sparc32/fpu/fpu_control.h: Make IEEE conformance be the default. * elf/elf.h (HWCAP_SPARC_*): New definitions. * elf/rtld.c (_dl_hwcap): New variable. * sysdeps/generic/dl-sysdep.c (_dl_sysdep_start): Record AT_HWCAP. * sysdeps/unix/sysv/linux/sparc/sparc32/getpagesize.c: New file. Attempt to get hold of the page size based on what we might have been told at startup time in _dl_pagesize. This will be obsolete when I finish the kernel hooks for a proper sysconf(), stay tuned. Sparc 64 merge: * sysdeps/sparc/sparc64/dl-machine.h (ELF_FIXUP_RETURN_VALUE): New. Figure out the right thing to return based on the .plt format. * sysdeps/sparc/sparc64/fpu/fpu_control.h: Update comment. * sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h (__dev_t): Should have been 64-bits wide. * sysdeps/unix/sysv/linux/sparc/sparc64/init-first.h: sll->sllx, optimize for branch delay slot usage. 1997-08-22 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * csu/Makefile ($(objpfx)crt%.o): Fix a missing *.so -> *.os change. 1997-08-20 Andreas Jaeger <aj@arthur.rhein-neckar.de> * math/libm-test.c (identities): Change epsilon. * sysdeps/i386/fpu/bits/mathinline.h: Correct arguments to fabs, fabsf, fabsl, __fabsl. * sysdeps/libm-i387/e_remainderl.S: Pop extra value from FPU stack. * sysdeps/libm-ieee754/s_csinhl.c: Include <fenv.h>.
356 lines
9.9 KiB
C
356 lines
9.9 KiB
C
/* Handle symbol and library versioning.
|
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public License as
|
|
published by the Free Software Foundation; either version 2 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
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
#include <elf.h>
|
|
#include <errno.h>
|
|
#include <link.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
#include <stdio-common/_itoa.h>
|
|
|
|
|
|
/* Set in rtld.c at startup. */
|
|
extern char **_dl_argv;
|
|
|
|
#define VERSTAG(tag) (DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (tag))
|
|
|
|
|
|
#define make_string(string, rest...) \
|
|
({ \
|
|
const char *all[] = { string, ## rest }; \
|
|
size_t len, cnt; \
|
|
char *result, *cp; \
|
|
\
|
|
len = 1; \
|
|
for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \
|
|
len += strlen (all[cnt]); \
|
|
\
|
|
cp = result = alloca (len); \
|
|
for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \
|
|
cp = stpcpy (cp, all[cnt]); \
|
|
\
|
|
result; \
|
|
})
|
|
|
|
|
|
static inline struct link_map *
|
|
find_needed (const char *name, struct link_map *map)
|
|
{
|
|
unsigned int n;
|
|
|
|
for (n = 0; n < _dl_loaded->l_nsearchlist; ++n)
|
|
if (_dl_name_match_p (name, _dl_loaded->l_searchlist[n]))
|
|
return _dl_loaded->l_searchlist[n];
|
|
|
|
/* The required object is not in the global scope, look to see if it is
|
|
a dependency of the current object. */
|
|
for (n = 0; n < map->l_nsearchlist; n++)
|
|
if (_dl_name_match_p (name, map->l_searchlist[n]))
|
|
return map->l_searchlist[n];
|
|
|
|
/* Should never happen. */
|
|
return NULL;
|
|
}
|
|
|
|
|
|
static int
|
|
match_symbol (const char *name, ElfW(Word) hash, const char *string,
|
|
struct link_map *map, int verbose, int weak)
|
|
{
|
|
const char *strtab = (const char *) (map->l_addr
|
|
+ map->l_info[DT_STRTAB]->d_un.d_ptr);
|
|
ElfW(Addr) def_offset;
|
|
ElfW(Verdef) *def;
|
|
|
|
if (map->l_info[VERSTAG (DT_VERDEF)] == NULL)
|
|
{
|
|
/* The file has no symbol versioning. I.e., the dependent
|
|
object was linked against another version of this file. We
|
|
only print a message if verbose output is requested. */
|
|
if (verbose)
|
|
_dl_signal_error (0, map->l_name, make_string ("\
|
|
no version information available (required by ",
|
|
name, ")"));
|
|
return 0;
|
|
}
|
|
|
|
def_offset = map->l_info[VERSTAG (DT_VERDEF)]->d_un.d_ptr;
|
|
assert (def_offset != 0);
|
|
|
|
def = (ElfW(Verdef) *) ((char *) map->l_addr + def_offset);
|
|
while (1)
|
|
{
|
|
/* Currently the version number of the definition entry is 1.
|
|
Make sure all we see is this version. */
|
|
if (def->vd_version != 1)
|
|
{
|
|
char buf[20];
|
|
buf[sizeof (buf) - 1] = '\0';
|
|
_dl_signal_error (0, map->l_name,
|
|
make_string ("unsupported version ",
|
|
_itoa_word (def->vd_version,
|
|
&buf[sizeof (buf) - 1],
|
|
10, 0),
|
|
" of Verdef record"));
|
|
return 1;
|
|
}
|
|
|
|
/* Compare the hash values. */
|
|
if (hash == def->vd_hash)
|
|
{
|
|
ElfW(Verdaux) *aux = (ElfW(Verdaux) *) ((char *) def + def->vd_aux);
|
|
|
|
/* To be safe, compare the string as well. */
|
|
if (strcmp (string, strtab + aux->vda_name) == 0)
|
|
/* Bingo! */
|
|
return 0;
|
|
}
|
|
|
|
/* If no more definitions we failed to find what we want. */
|
|
if (def->vd_next == 0)
|
|
break;
|
|
|
|
/* Next definition. */
|
|
def = (ElfW(Verdef) *) ((char *) def + def->vd_next);
|
|
}
|
|
|
|
/* Symbol not found. If it was a weak reference it is not fatal. */
|
|
if (weak)
|
|
{
|
|
if (verbose)
|
|
_dl_signal_error (0, map->l_name,
|
|
make_string ("weak version `", string,
|
|
"' not found (required by ", name,
|
|
")"));
|
|
return 0;
|
|
}
|
|
|
|
_dl_signal_error (0, map->l_name,
|
|
make_string ("version `", string,
|
|
"' not found (required by ", name, ")"));
|
|
return 1;
|
|
}
|
|
|
|
|
|
int
|
|
_dl_check_map_versions (struct link_map *map, int verbose)
|
|
{
|
|
int result = 0;
|
|
const char *strtab;
|
|
/* Pointer to section with needed versions. */
|
|
ElfW(Dyn) *dyn;
|
|
/* Pointer to dynamic section with definitions. */
|
|
ElfW(Dyn) *def;
|
|
/* We need to find out which is the highest version index used
|
|
in a dependecy. */
|
|
unsigned int ndx_high = 0;
|
|
|
|
/* If we don't have a string table, we must be ok. */
|
|
if (map->l_info[DT_STRTAB] == NULL)
|
|
return 0;
|
|
strtab = (const char *) (map->l_addr + map->l_info[DT_STRTAB]->d_un.d_ptr);
|
|
|
|
dyn = map->l_info[VERSTAG (DT_VERNEED)];
|
|
def = map->l_info[VERSTAG (DT_VERDEF)];
|
|
|
|
if (dyn != NULL)
|
|
{
|
|
/* This file requires special versions from its dependencies. */
|
|
ElfW(Verneed) *ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr);
|
|
|
|
/* Currently the version number of the needed entry is 1.
|
|
Make sure all we see is this version. */
|
|
if (ent->vn_version != 1)
|
|
{
|
|
char buf[20];
|
|
buf[sizeof (buf) - 1] = '\0';
|
|
_dl_signal_error (0, (*map->l_name ? map->l_name : _dl_argv[0]),
|
|
make_string ("unsupported version ",
|
|
_itoa_word (ent->vn_version,
|
|
&buf[sizeof (buf) - 1],
|
|
10, 0),
|
|
" of Verneed record\n"));
|
|
return 1;
|
|
}
|
|
|
|
while (1)
|
|
{
|
|
ElfW(Vernaux) *aux;
|
|
struct link_map *needed = find_needed (strtab + ent->vn_file, map);
|
|
|
|
/* If NEEDED is NULL this means a dependency was not found
|
|
and no stub entry was created. This should never happen. */
|
|
assert (needed != NULL);
|
|
|
|
/* NEEDED is the map for the file we need. Now look for the
|
|
dependency symbols. */
|
|
aux = (ElfW(Vernaux) *) ((char *) ent + ent->vn_aux);
|
|
while (1)
|
|
{
|
|
/* Match the symbol. */
|
|
result |= match_symbol ((*map->l_name
|
|
? map->l_name : _dl_argv[0]),
|
|
aux->vna_hash,
|
|
strtab + aux->vna_name,
|
|
needed, verbose,
|
|
aux->vna_flags & VER_FLG_WEAK);
|
|
|
|
/* Compare the version index. */
|
|
if ((unsigned int) (aux->vna_other & 0x7fff) > ndx_high)
|
|
ndx_high = aux->vna_other & 0x7fff;
|
|
|
|
if (aux->vna_next == 0)
|
|
/* No more symbols. */
|
|
break;
|
|
|
|
/* Next symbol. */
|
|
aux = (ElfW(Vernaux) *) ((char *) aux + aux->vna_next);
|
|
}
|
|
|
|
if (ent->vn_next == 0)
|
|
/* No more dependencies. */
|
|
break;
|
|
|
|
/* Next dependency. */
|
|
ent = (ElfW(Verneed) *) ((char *) ent + ent->vn_next);
|
|
}
|
|
}
|
|
|
|
/* We also must store the names of the defined versions. Determine
|
|
the maximum index here as well.
|
|
|
|
XXX We could avoid the loop by just taking the number of definitions
|
|
as an upper bound of new indeces. */
|
|
if (def != NULL)
|
|
{
|
|
ElfW(Verdef) *ent;
|
|
ent = (ElfW(Verdef) *) (map->l_addr + def->d_un.d_ptr);
|
|
while (1)
|
|
{
|
|
if ((unsigned int) (ent->vd_ndx & 0x7fff) > ndx_high)
|
|
ndx_high = ent->vd_ndx & 0x7fff;
|
|
|
|
if (ent->vd_next == 0)
|
|
/* No more definitions. */
|
|
break;
|
|
|
|
ent = (ElfW(Verdef) *) ((char *) ent + ent->vd_next);
|
|
}
|
|
}
|
|
|
|
if (ndx_high > 0)
|
|
{
|
|
/* Now we are ready to build the array with the version names
|
|
which can be indexed by the version index in the VERSYM
|
|
section. */
|
|
map->l_versions = (struct r_found_version *)
|
|
calloc (ndx_high + 1, sizeof (*map->l_versions));
|
|
if (map->l_versions == NULL)
|
|
{
|
|
_dl_signal_error (ENOMEM, (*map->l_name ? map->l_name : _dl_argv[0]),
|
|
"cannot allocate version reference table");
|
|
result = 1;
|
|
}
|
|
else
|
|
{
|
|
/* Store the number of available symbols. */
|
|
map->l_nversions = ndx_high + 1;
|
|
|
|
if (dyn != NULL)
|
|
{
|
|
ElfW(Verneed) *ent;
|
|
ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr);
|
|
while (1)
|
|
{
|
|
ElfW(Vernaux) *aux;
|
|
aux = (ElfW(Vernaux) *) ((char *) ent + ent->vn_aux);
|
|
while (1)
|
|
{
|
|
ElfW(Half) ndx = aux->vna_other & 0x7fff;
|
|
map->l_versions[ndx].hash = aux->vna_hash;
|
|
map->l_versions[ndx].hidden = aux->vna_other & 0x8000;
|
|
map->l_versions[ndx].name = &strtab[aux->vna_name];
|
|
map->l_versions[ndx].filename = &strtab[ent->vn_file];
|
|
|
|
if (aux->vna_next == 0)
|
|
/* No more symbols. */
|
|
break;
|
|
|
|
/* Advance to next symbol. */
|
|
aux = (ElfW(Vernaux) *) ((char *) aux + aux->vna_next);
|
|
}
|
|
|
|
if (ent->vn_next == 0)
|
|
/* No more dependencies. */
|
|
break;
|
|
|
|
/* Advance to next dependency. */
|
|
ent = (ElfW(Verneed) *) ((char *) ent + ent->vn_next);
|
|
}
|
|
}
|
|
|
|
/* And insert the defined versions. */
|
|
if (def != NULL)
|
|
{
|
|
ElfW(Verdef) *ent;
|
|
ent = (ElfW(Verdef) *) (map->l_addr + def->d_un.d_ptr);
|
|
while (1)
|
|
{
|
|
ElfW(Verdaux) *aux;
|
|
aux = (ElfW(Verdaux) *) ((char *) ent + ent->vd_aux);
|
|
|
|
if ((ent->vd_flags & VER_FLG_BASE) == 0)
|
|
{
|
|
/* The name of the base version should not be
|
|
available for matching a versioned symbol. */
|
|
ElfW(Half) ndx = ent->vd_ndx & 0x7fff;
|
|
map->l_versions[ndx].hash = ent->vd_hash;
|
|
map->l_versions[ndx].name = &strtab[aux->vda_name];
|
|
map->l_versions[ndx].filename = NULL;
|
|
}
|
|
|
|
if (ent->vd_next == 0)
|
|
/* No more definitions. */
|
|
break;
|
|
|
|
ent = (ElfW(Verdef) *) ((char *) ent + ent->vd_next);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
int
|
|
_dl_check_all_versions (struct link_map *map, int verbose)
|
|
{
|
|
struct link_map *l;
|
|
int result = 0;
|
|
|
|
for (l = map; l != NULL; l = l->l_next)
|
|
result |= l->l_opencount != 0 && _dl_check_map_versions (l, verbose);
|
|
|
|
return result;
|
|
}
|