OSDN Git Service

2003-05-28 Jeff Johnston <jjohnstn@redhat.com>
[pf3gnuchains/pf3gnuchains3x.git] / newlib / libc / sys / linux / dl / dl-librecon.h
1 /* Optional code to distinguish library flavours.
2    Copyright (C) 1998, 2001 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #ifndef _DL_LIBRECON_H
22 #define _DL_LIBRECON_H  1
23
24 #define DISTINGUISH_LIB_VERSIONS \
25   do                                                                          \
26     {                                                                         \
27       /* We have to find out whether the binary is linked against             \
28          libc 5 or glibc.  We do this by looking at all the DT_NEEDED         \
29          entries.  If one is libc.so.5 this is a libc 5 linked binary.  */    \
30       if (_dl_loaded->l_info[DT_NEEDED])                                      \
31         {                                                                     \
32           /* We have dependencies.  */                                        \
33           const ElfW(Dyn) *d;                                                 \
34           const char *strtab;                                                 \
35                                                                               \
36           strtab = (const char *) D_PTR (_dl_loaded, l_info[DT_STRTAB]);      \
37                                                                               \
38           for (d = _dl_loaded->l_ld; d->d_tag != DT_NULL; ++d)                \
39             if (d->d_tag == DT_NEEDED                                         \
40                 && strcmp (strtab + d->d_un.d_val, "libc.so.5") == 0)         \
41               break;                                                          \
42                                                                               \
43           /* We print a `5' or `6' depending on the outcome.  */              \
44           _dl_printf (d->d_tag != DT_NULL ? "5\n" : "6\n");                   \
45         }                                                                     \
46     }                                                                         \
47   while (0)
48
49 /* Recognizing extra environment variables.  */
50 #define EXTRA_LD_ENVVARS \
51   case 13:                                                                    \
52     if (memcmp (envline, "ASSUME_KERNEL", 13) == 0)                           \
53       {                                                                       \
54         unsigned long int i, j, osversion = 0;                                \
55         char *p = &envline[14], *q;                                           \
56                                                                               \
57         for (i = 0; i < 3; i++, p = q + 1)                                    \
58           {                                                                   \
59             j = __strtoul_internal (p, &q, 0, 0);                             \
60             if (j >= 255 || p == q || (i < 2 && *q && *q != '.'))             \
61               {                                                               \
62                 osversion = 0;                                                \
63                 break;                                                        \
64               }                                                               \
65             osversion |= j << (16 - 8 * i);                                   \
66             if (!*q)                                                          \
67               break;                                                          \
68           }                                                                   \
69         if (osversion)                                                        \
70           _dl_osversion = osversion;                                          \
71         break;                                                                \
72       }                                                                       \
73                                                                               \
74   case 15:                                                                    \
75     if (memcmp (envline, "LIBRARY_VERSION", 15) == 0)                         \
76       {                                                                       \
77         _dl_correct_cache_id = envline[16] == '5' ? 2 : 3;                    \
78         break;                                                                \
79       }
80
81 /* Extra unsecure variables.  The names are all stuffed in a single
82    string which means they have to be terminated with a '\0' explicitly.  */
83 #define EXTRA_UNSECURE_ENVVARS \
84   "LD_AOUT_LIBRARY_PATH\0"                                                    \
85   "LD_AOUT_PRELOAD\0"
86
87 #endif /* dl-librecon.h */