mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-10 23:30:07 +00:00
fd26970f33
Tue Jan 21 04:05:20 1997 Ulrich Drepper <drepper@cygnus.com> * version.h (VERSION): Bump to 1.101. Implement -d and -r option to `ldd' to check relocations. * elf/dl-error.c: Add another method to intercept errors. (_dl_receive_error): New function. Install user defined handler. (receiver): New variable. Contains pointer to user provided handler. (_dl_signal_error): If user provided handler is installed call this. * elf/dl-load.c (_dl_map_object): When shared object is not found in trace mode initialize a few more fields so that lookup can actually happen but always fails. * elf/ldd.sh.in: Rewrite argument handling. Recognize new arguments to trigger reloation test. Return with appropriate error code if a file wasn't found. Print warning if object is not executable. * elf/ldd.bash.in: Likewise. * elf/link.h (receiver_fct): New type. Used in _dl_receive_error. (_dl_sysdep_error): New prototype. (_dl_receive_error): New prototype. (_dl_signal_error): Remove __attribute__ ((__noreturn__)). * elf/rtld.c (dl_main): Rewrite argument handling. More than one argument allowed. Recognize --data-relocs and --function-relocs arguments. Don't determine `lazy' mode from LD_BIND_NOW environment variable when in trace mode. If in trace mode and either --data-relocs or --function-relocs is given perform relocation. Report errors using print_unresolved function. (print_unresolved): New function. Print information about missing symbol on stderr. * sysdeps/generic/dl-sysdep.c (_dl_sysdep_error): New function. Like _dl_sysdep_message but print to stderr. * sysdeps/mach/hurd/dl-sysdep.c: Likewise. * sysdeps/generic/sockaddrcom.h: Add definition of sa_family_t. Reported by Andreas Schwab. (__SOCKADDR_COMMON): Use sa_family_t for family member. * sysdeps/unix/bsd/bsd4.4/sockaddrcom.h: Likewise. Linux/Sparc support by Miguel de Icaza. * sysdeps/sparc/fpu_control.h: New file. * sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S: New file. * sysdeps/unix/sysv/linux/sparc/brk.c: New file. * sysdeps/unix/sysv/linux/sparc/profil-counter.h: New file. * sysdeps/unix/sysv/linux/sparc/sigaction.c: New file. * sysdeps/unix/sysv/linux/sparc/socket.S: New file. * sysdeps/unix/sysv/linux/sparc/syscall.S: New file. * sysdeps/unix/sysv/linux/sparc/sysdep.h: New file. * sysdeps/unix/sysv/linux/sparc/Dist: New file. * sysdeps/unix/sysv/linux/sparc/Makefile: New file. * sysdeps/unix/sysv/linux/net/if_arp.h: Don't use kernel header. Provide own definition based on 4.4BSD and Linux. * sysdeps/unix/sysv/linux/net/ppp_defs.h: Define __u32 before including <linux/ppp_defs.h>. * sysdeps/unix/sysv/linux/sys/msq_buf.h (struct msqid_ds): Don't use __pid_t since the kernel might have a different size. * sysdeps/unix/sysv/linux/sys/shm_buf.h (struct shmid_ds): Likewise. Reported by Andreas Schwab. * time/asctime.c: Update copyright. * time/dysize.c: Likewise. * time/gmtime.c: Likewise. * time/timegm.c: Likewise. * time/offtime.c: Likewise. De-ANSI-declfy. * time/tzset.c (__tzset_internal): When TZ envvar does not name a DST timezone don't default to offset -1. * sysdeps/unix/sysv/linux/net/route.h: Don't use kernel header. Reported by a sun <asun@zoology.washington.edu>. * resolv/Makefile: Correct spelling: subdirs-dirs -> subdir-dirs. * sysdeps/stub/sysv_signal.c: New file. Stub implementation. * Makefile (distribute): Add mcheck.h. * nis/Makefile (distribute): Add nss-nis.h. * libio/Makefile (routines): Change vdprintf to iovdprintf to prevent dist problem. * nss/Makefile (distribute): Add digits_dots.c. * sysdeps/unix/sysv/linux/Dist: Add kernel_sigaction.h. * sysdeps/unix/sysv/linux/alpha/Dist: Add sys/procfs.h. * sysdeps/unix/sysv/linux/sparc/Dist: Add clone.S. * new-malloc/Makefile (distribute): Add mcheck-init.c and mcheck.h. Mon Jan 20 17:54:28 1997 Sven Verdoolaege <skimo@breughel.ufsia.ac.be> * manual/filesys.texi: Fix little problem (reentrant->readdir). Fri Jan 17 19:07:07 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * configure.in [$elf=yes]: Check for support of .previous and .popsection in the assembler. * config.h.in: Add HAVE_ASM_PREVIOUS_DIRECTIVE and HAVE_ASM_POPSECTION_DIRECTIVE. * libc-symbols.h (__make_section_unallocated) [HAVE_ELF]: Define appropriate if either .previous or .popsection is supported. (libc_warning) [HAVE_ELF]: Use it here. Sat Jan 18 22:15:26 1997 Richard Henderson <rth@tamu.edu> * Makeconfig (CFLAGS-.so): Add -fno-common to prevent odd sorts of errors that can occur when linking libc.so. Mon Jan 20 05:20:49 1997 Ulrich Drepper <drepper@cygnus.com> * elf/dl-load.c (open_path): When running setuid don't try a directory if it is not given with the full name. * elf/Makefile (before-compile): New variable. Mention trusted-dirs.h. (trusted-dirs.h): Construct file from $(default-rpath) and $(user-defined-trusted-dirs) variables. * elf/dl-load.c (_dl_map_object): Pass additional argument to open_path which is NULL except for the LD_LIBRARY_PATH pass in which case it is a pointer to the list of directories from the trusted-dirs.h file. (open_path): Accept additional argument with list of trusted dirs. When running setuid and a list of trusted dirs is given only use those which are mentioned in the list. * elf/rtld.c (dl_main): Don't reject whole LD_LIBRARY_PATH when running setuid. Instead accept entries which do not contain a '/'. * Makeconfig: Correct comment about +(default_cflags). Mon Jan 20 05:11:14 1997 Hrvoje Niksic <hniksic@srce.hr> * time/strptime.c (recursive): Use && not || to test for valid argument. Mon Jan 20 05:06:50 1997 Ulrich Drepper <drepper@cygnus.com> * elf/ldd.sh.in: Exit with value 1 if an error occured. * elf/ldd.bash.in: Likewise. * elf/rtld.c (dl_main): Do not always ignore LD_PRELOAD when the binary runs setuid. It is save to use those entries which do not contain a '/'. This is compatible with Solaris-2.
323 lines
11 KiB
C
323 lines
11 KiB
C
/* Support macros for making weak and strong aliases for symbols,
|
||
and for using symbol sets and linker warnings with GNU ld.
|
||
Copyright (C) 1995, 1996, 1997 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 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. */
|
||
|
||
#ifndef _LIBC_SYMBOLS_H
|
||
#define _LIBC_SYMBOLS_H 1
|
||
|
||
/* This file's macros are included implicitly in the compilation of every
|
||
file in the C library by -imacros.
|
||
|
||
We include config.h which is generated by configure.
|
||
It should define for us the following symbols:
|
||
|
||
* HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
|
||
* ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
|
||
* HAVE_GNU_LD if using GNU ld, with support for weak symbols in a.out,
|
||
and for symbol set and warning messages extensions in a.out and ELF.
|
||
* HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
|
||
* HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
|
||
* HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
|
||
|
||
*/
|
||
|
||
/* This is defined for the compilation of all C library code. features.h
|
||
tests this to avoid inclusion of stubs.h while compiling the library,
|
||
before stubs.h has been generated. Some library code that is shared
|
||
with other packages also tests this symbol to see if it is being
|
||
compiled as part of the C library. We must define this before including
|
||
config.h, because it makes some definitions conditional on whether libc
|
||
itself is being compiled, or just some generator program. */
|
||
#define _LIBC 1
|
||
|
||
/* Enable declarations of GNU extensions, since we are compiling them. */
|
||
#define _GNU_SOURCE 1
|
||
/* And we also need the data for the reentrant functions. */
|
||
#define _REENTRANT 1
|
||
|
||
#include <config.h>
|
||
/*
|
||
|
||
*/
|
||
|
||
#ifndef ASSEMBLER
|
||
|
||
/* Define the macros `_' and `N_' for conveniently marking translatable
|
||
strings in the libc source code. */
|
||
|
||
#define N_(msgid) msgid
|
||
|
||
#include <libintl.h>
|
||
extern const char _libc_intl_domainname[];
|
||
|
||
#ifdef dgettext
|
||
/* This is defined as an optimizing macro, so use it. */
|
||
#define _(msgid) dgettext (_libc_intl_domainname, (msgid))
|
||
#else
|
||
/* Be sure to use only the __ name when `dgettext' is a plain function
|
||
instead of an optimizing macro. */
|
||
#define _(msgid) __dgettext (_libc_intl_domainname, (msgid))
|
||
#endif
|
||
|
||
#endif
|
||
|
||
/*
|
||
|
||
*/
|
||
/* The symbols in all the user (non-_) macros are C symbols.
|
||
HAVE_GNU_LD without HAVE_ELF implies a.out. */
|
||
|
||
#if defined (HAVE_ASM_WEAK_DIRECTIVE) || defined (HAVE_ASM_WEAKEXT_DIRECTIVE)
|
||
#define HAVE_WEAK_SYMBOLS
|
||
#endif
|
||
|
||
#ifndef __SYMBOL_PREFIX
|
||
#ifdef NO_UNDERSCORES
|
||
#define __SYMBOL_PREFIX
|
||
#else
|
||
#define __SYMBOL_PREFIX "_"
|
||
#endif
|
||
#endif
|
||
|
||
#ifndef C_SYMBOL_NAME
|
||
#ifdef NO_UNDERSCORES
|
||
#define C_SYMBOL_NAME(name) name
|
||
#else
|
||
#define C_SYMBOL_NAME(name) _##name
|
||
#endif
|
||
#endif
|
||
|
||
|
||
/* Define ALIAS as a strong alias for ORIGINAL. */
|
||
#ifdef HAVE_ASM_SET_DIRECTIVE
|
||
#define strong_alias_asm(original, alias) \
|
||
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias); \
|
||
.set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
|
||
#ifdef ASSEMBLER
|
||
#define strong_alias(original, alias) strong_alias_asm (original, alias)
|
||
#else
|
||
#define strong_alias(original, alias) \
|
||
asm (__string_1 (ASM_GLOBAL_DIRECTIVE) " " __SYMBOL_PREFIX #alias "\n" \
|
||
".set " __SYMBOL_PREFIX #alias "," __SYMBOL_PREFIX #original);
|
||
#endif
|
||
#else
|
||
#define strong_alias_asm(original, alias) \
|
||
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias); \
|
||
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
|
||
#ifdef ASSEMBLER
|
||
#define strong_alias(original, alias) strong_alias_asm (original, alias)
|
||
#else
|
||
#define strong_alias(original, alias) \
|
||
asm (__string_1 (ASM_GLOBAL_DIRECTIVE) " " __SYMBOL_PREFIX #alias "\n" \
|
||
__SYMBOL_PREFIX #alias " = " __SYMBOL_PREFIX #original);
|
||
#endif
|
||
#endif
|
||
|
||
/* Helper macros used above. */
|
||
#define __string_1(x) __string_0(x)
|
||
#define __string_0(x) #x
|
||
|
||
|
||
#ifdef HAVE_WEAK_SYMBOLS
|
||
|
||
#ifdef ASSEMBLER
|
||
|
||
#ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
|
||
|
||
/* Define ALIAS as a weak alias for ORIGINAL.
|
||
If weak aliases are not available, this defines a strong alias. */
|
||
#define weak_alias(original, alias) \
|
||
.weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
|
||
|
||
/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
|
||
#define weak_extern(symbol) \
|
||
.weakext C_SYMBOL_NAME (symbol)
|
||
|
||
#else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
|
||
|
||
/* Define ALIAS as a weak alias for ORIGINAL.
|
||
If weak aliases are not available, this defines a strong alias. */
|
||
#define weak_alias(original, alias) \
|
||
.weak C_SYMBOL_NAME (alias); \
|
||
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
|
||
|
||
|
||
/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
|
||
#define weak_extern(symbol) \
|
||
.weak C_SYMBOL_NAME (symbol)
|
||
|
||
#endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
|
||
|
||
#else /* ! ASSEMBLER */
|
||
|
||
#ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
|
||
#define weak_extern_asm(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
|
||
#define weak_alias_asm(original, alias) \
|
||
asm (".weakext " __SYMBOL_PREFIX #alias ", " __SYMBOL_PREFIX #original);
|
||
#else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
|
||
#define weak_extern_asm(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
|
||
#define weak_alias_asm(original, alias) \
|
||
asm (".weak " __SYMBOL_PREFIX #alias "\n" \
|
||
__SYMBOL_PREFIX #alias " = " __SYMBOL_PREFIX #original);
|
||
#endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
|
||
|
||
#define weak_alias(o, a) weak_alias_asm (o, a)
|
||
#define weak_extern(symbol) weak_extern_asm (symbol)
|
||
|
||
#endif /* ! ASSEMBLER */
|
||
#else
|
||
#define weak_alias(original, alias) strong_alias(original, alias)
|
||
#define weak_extern(symbol) /* Do nothing; the ref will be strong. */
|
||
#endif
|
||
|
||
|
||
#if (!defined (ASSEMBLER) && \
|
||
(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)))
|
||
/* GCC 2.7 and later has special syntax for weak symbols and aliases.
|
||
Using that is better when possible, because the compiler and assembler
|
||
are better clued in to what we are doing. */
|
||
#undef strong_alias
|
||
#define strong_alias(name, aliasname) \
|
||
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
|
||
|
||
#ifdef HAVE_WEAK_SYMBOLS
|
||
#undef weak_alias
|
||
#define weak_alias(name, aliasname) \
|
||
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
|
||
|
||
/* This comes between the return type and function name in
|
||
a function definition to make that definition weak. */
|
||
#define weak_function __attribute__ ((weak))
|
||
#define weak_const_function __attribute__ ((weak, __const__))
|
||
|
||
#endif /* HAVE_WEAK_SYMBOLS. */
|
||
#endif /* Not ASSEMBLER, and GCC 2.7 or later. */
|
||
|
||
|
||
#ifndef weak_function
|
||
/* If we do not have the __attribute__ ((weak)) syntax, there is no way we
|
||
can define functions as weak symbols. The compiler will emit a `.globl'
|
||
directive for the function symbol, and a `.weak' directive in addition
|
||
will produce an error from the assembler. */
|
||
#define weak_function /* empty */
|
||
#define weak_const_function /* empty */
|
||
#endif
|
||
|
||
|
||
/* When a reference to SYMBOL is encountered, the linker will emit a
|
||
warning message MSG. */
|
||
#ifdef HAVE_GNU_LD
|
||
#ifdef HAVE_ELF
|
||
|
||
/* We want the .gnu.warning.SYMBOL section to be unallocated. */
|
||
#ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
|
||
#define __make_section_unallocated(section_string) \
|
||
asm(".section " section_string "; .previous");
|
||
#elif defined (HAVE_ASM_POPSECTION_DIRECTIVE)
|
||
#define __make_section_unallocated(section_string) \
|
||
asm(".pushsection " section_string "; .popsection");
|
||
#else
|
||
#define __make_section_unallocated(section_string)
|
||
#endif
|
||
|
||
#define link_warning(symbol, msg) \
|
||
__make_section_unallocated (".gnu.warning." #symbol) \
|
||
static const char __evoke_link_warning_##symbol[] \
|
||
__attribute__ ((section (".gnu.warning." #symbol))) = msg;
|
||
#else
|
||
#define link_warning(symbol, msg) \
|
||
asm(".stabs \"" msg "\",30,0,0,0\n" \
|
||
".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
|
||
#endif
|
||
#else
|
||
/* We will never be heard; they will all die horribly. */
|
||
#define link_warning(symbol, msg)
|
||
#endif
|
||
|
||
/* A canned warning for sysdeps/stub functions. */
|
||
#define stub_warning(name) \
|
||
link_warning (name, \
|
||
"warning: " #name " is not implemented and will always fail")
|
||
|
||
/*
|
||
|
||
*/
|
||
|
||
#ifdef HAVE_GNU_LD
|
||
|
||
/* Symbol set support macros. */
|
||
|
||
#ifdef HAVE_ELF
|
||
|
||
/* Make SYMBOL, which is in the text segment, an element of SET. */
|
||
#define text_set_element(set, symbol) _elf_set_element(set, symbol)
|
||
/* Make SYMBOL, which is in the data segment, an element of SET. */
|
||
#define data_set_element(set, symbol) _elf_set_element(set, symbol)
|
||
/* Make SYMBOL, which is in the bss segment, an element of SET. */
|
||
#define bss_set_element(set, symbol) _elf_set_element(set, symbol)
|
||
|
||
/* These are all done the same way in ELF.
|
||
There is a new section created for each set. */
|
||
#ifdef PIC
|
||
/* When building a shared library, make the set section writable,
|
||
because it will need to be relocated at run time anyway. */
|
||
#define _elf_set_element(set, symbol) \
|
||
static const void *__elf_set_##set##_element_##symbol##__ \
|
||
__attribute__ ((unused, section (#set))) = &(symbol)
|
||
#else
|
||
#define _elf_set_element(set, symbol) \
|
||
static const void *const __elf_set_##set##_element_##symbol##__ \
|
||
__attribute__ ((unused, section (#set))) = &(symbol)
|
||
#endif
|
||
|
||
/* Define SET as a symbol set. This may be required (it is in a.out) to
|
||
be able to use the set's contents. */
|
||
#define symbol_set_define(set) symbol_set_declare(set)
|
||
|
||
/* Declare SET for use in this module, if defined in another module. */
|
||
#define symbol_set_declare(set) \
|
||
extern void *const __start_##set __attribute__ ((__weak__)); \
|
||
extern void *const __stop_##set __attribute__ ((__weak__)); \
|
||
weak_extern (__start_##set) weak_extern (__stop_##set)
|
||
|
||
/* Return a pointer (void *const *) to the first element of SET. */
|
||
#define symbol_set_first_element(set) (&__start_##set)
|
||
|
||
/* Return true iff PTR (a void *const *) has been incremented
|
||
past the last element in SET. */
|
||
#define symbol_set_end_p(set, ptr) ((ptr) >= &__stop_##set)
|
||
|
||
#else /* Not ELF: a.out. */
|
||
|
||
#define text_set_element(set, symbol) \
|
||
asm(".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
|
||
#define data_set_element(set, symbol) \
|
||
asm(".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
|
||
#define bss_set_element(set, symbol) ?error Must use initialized data.
|
||
#define symbol_set_define(set) void *const (set)[1];
|
||
#define symbol_set_declare(set) extern void *const (set)[1];
|
||
|
||
#define symbol_set_first_element(set) &(set)[1]
|
||
#define symbol_set_end_p(set, ptr) (*(ptr) == 0)
|
||
|
||
#endif /* ELF. */
|
||
#endif /* Have GNU ld. */
|
||
|
||
#endif /* libc-symbols.h */
|