From: Jakub Jelinek <jakub@redhat.com>
To: Roland McGrath <roland@redhat.com>, Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Make LD_ASSUME_KERNEL working even for static binaries
Date: Mon, 09 Dec 2002 10:29:00 -0000 [thread overview]
Message-ID: <20021209192931.J1310@sunsite.ms.mff.cuni.cz> (raw)
Hi!
LD_ASSUME_KERNEL doesn't work for static binaries, the following patch makes
it work even for them (so you can influence what libraries it will use
during NSS lookups or ICONV).
2002-12-09 Jakub Jelinek <jakub@redhat.com>
* elf/dl-support.c (_dl_non_dynamic_init): Add DL_OSVERSION_INIT if
defined.
* sysdeps/unix/sysv/linux/dl-librecon.h (_dl_osversion_init): New
function.
(EXTRA_LD_ENVVARS): Use it.
(DL_OSVERSION_INIT): Define.
* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Include linux
dl-librecon.h.
(EXTRA_LD_ENVVARS): Undef before defining. Use _dl_osversion_init.
--- libc/elf/dl-support.c.jj 2002-12-06 12:27:23.000000000 +0100
+++ libc/elf/dl-support.c 2002-12-09 16:57:58.000000000 +0100
@@ -214,6 +214,10 @@ _dl_non_dynamic_init (void)
DL_PLATFORM_INIT;
#endif
+#ifdef DL_OSVERSION_INIT
+ DL_OSVERSION_INIT;
+#endif
+
/* Now determine the length of the platform string. */
if (_dl_platform != NULL)
_dl_platformlen = strlen (_dl_platform);
--- libc/sysdeps/unix/sysv/linux/i386/dl-librecon.h.jj 2002-01-31 04:39:22.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/i386/dl-librecon.h 2002-12-09 17:15:06.000000000 +0100
@@ -19,7 +19,8 @@
02111-1307 USA. */
#ifndef _DL_LIBRECON_H
-#define _DL_LIBRECON_H 1
+
+#include <sysdeps/unix/sysv/linux/dl-librecon.h>
#define DISTINGUISH_LIB_VERSIONS \
do \
@@ -47,27 +48,12 @@
while (0)
/* Recognizing extra environment variables. */
+#undef EXTRA_LD_ENVVARS
#define EXTRA_LD_ENVVARS \
case 13: \
if (memcmp (envline, "ASSUME_KERNEL", 13) == 0) \
{ \
- unsigned long int i, j, osversion = 0; \
- char *p = &envline[14], *q; \
- \
- for (i = 0; i < 3; i++, p = q + 1) \
- { \
- j = __strtoul_internal (p, &q, 0, 0); \
- if (j >= 255 || p == q || (i < 2 && *q && *q != '.')) \
- { \
- osversion = 0; \
- break; \
- } \
- osversion |= j << (16 - 8 * i); \
- if (!*q) \
- break; \
- } \
- if (osversion) \
- GL(dl_osversion) = osversion; \
+ _dl_osversion_init (&envline[14]); \
break; \
} \
\
--- libc/sysdeps/unix/sysv/linux/dl-librecon.h.jj 2002-01-31 04:39:22.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/dl-librecon.h 2002-12-09 17:20:45.000000000 +0100
@@ -1,5 +1,5 @@
/* Optional code to distinguish library flavours.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
@@ -21,29 +21,42 @@
#ifndef _DL_LIBRECON_H
#define _DL_LIBRECON_H 1
+static inline void __attribute__ ((unused, always_inline))
+_dl_osversion_init (char *assume_kernel)
+{
+ unsigned long int i, j, osversion = 0;
+ char *p = assume_kernel, *q;
+
+ for (i = 0; i < 3; i++, p = q + 1)
+ {
+ j = __strtoul_internal (p, &q, 0, 0);
+ if (j >= 255 || p == q || (i < 2 && *q && *q != '.'))
+ {
+ osversion = 0;
+ break;
+ }
+ osversion |= j << (16 - 8 * i);
+ if (!*q)
+ break;
+ }
+ if (osversion)
+ GL(dl_osversion) = osversion;
+}
+
/* Recognizing extra environment variables. */
#define EXTRA_LD_ENVVARS \
case 13: \
if (memcmp (envline, "ASSUME_KERNEL", 13) == 0) \
{ \
- unsigned long int i, j, osversion = 0; \
- char *p = &envline[14], *q; \
- \
- for (i = 0; i < 3; i++, p = q + 1) \
- { \
- j = __strtoul_internal (p, &q, 0, 0); \
- if (j >= 255 || p == q || (i < 2 && *q && *q != '.')) \
- { \
- osversion = 0; \
- break; \
- } \
- osversion |= j << (16 - 8 * i); \
- if (!*q) \
- break; \
- } \
- if (osversion) \
- GL(dl_osversion) = osversion; \
+ _dl_osversion_init (&envline[14]); \
break; \
}
+#define DL_OSVERSION_INIT \
+ do { \
+ char *assume_kernel = getenv ("LD_ASSUME_KERNEL"); \
+ if (assume_kernel) \
+ _dl_osversion_init (assume_kernel); \
+ } while (0)
+
#endif /* dl-librecon.h */
Jakub
next reply other threads:[~2002-12-09 18:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-09 10:29 Jakub Jelinek [this message]
2002-12-09 12:50 ` Roland McGrath
[not found] ` <20021209162539.J27455@devserv.devel.redhat.com>
2002-12-09 13:43 ` Ulrich Drepper
2002-12-09 13:45 ` Roland McGrath
2002-12-10 2:31 ` Roland McGrath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021209192931.J1310@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).