mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
* elf/elf.h: Define AT_EXECFN.
* elf/rtld.c [!__ASSUME_AT_EXECFN] (process_envvars): Don't handle LD_ORIGIN_PATH. * elf/dl-sysdep.c (_dl_sysdep_start): Handle AT_EXECFN. * elf/dl-support.c: Define _dl_execfn. Don't define _dl_origin_path if __ASSUME_AT_EXECFN is defined. (_dl_aux_init): Handle AT_EXECFN. * sysdeps/unix/sysv/linux/kernel-features.h: Define __ASSUME_AT_EXECFN for 2.6.27 and up. * sysdeps/generic/ldsodefs.h (rtld_global_ro): Add _dl_execfn. Don't define _dl_origin_path if __ASSUME_AT_EXECFN is defined. * sysdeps/unix/sysv/linux/dl-origin.c (_dl_get_origin): Use _dl_execfn if available and avoid compatibility code if __ASSUME_AT_EXECFN is defined.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@ -1,5 +1,20 @@
|
|||||||
2008-07-24 Ulrich Drepper <drepper@redhat.com>
|
2008-07-24 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/elf.h: Define AT_EXECFN.
|
||||||
|
* elf/rtld.c [!__ASSUME_AT_EXECFN] (process_envvars): Don't handle
|
||||||
|
LD_ORIGIN_PATH.
|
||||||
|
* elf/dl-sysdep.c (_dl_sysdep_start): Handle AT_EXECFN.
|
||||||
|
* elf/dl-support.c: Define _dl_execfn. Don't define _dl_origin_path
|
||||||
|
if __ASSUME_AT_EXECFN is defined.
|
||||||
|
(_dl_aux_init): Handle AT_EXECFN.
|
||||||
|
* sysdeps/unix/sysv/linux/kernel-features.h: Define __ASSUME_AT_EXECFN
|
||||||
|
for 2.6.27 and up.
|
||||||
|
* sysdeps/generic/ldsodefs.h (rtld_global_ro): Add _dl_execfn.
|
||||||
|
Don't define _dl_origin_path if __ASSUME_AT_EXECFN is defined.
|
||||||
|
* sysdeps/unix/sysv/linux/dl-origin.c (_dl_get_origin): Use
|
||||||
|
_dl_execfn if available and avoid compatibility code if
|
||||||
|
__ASSUME_AT_EXECFN is defined.
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/dl-sysdep.h: Don't declare
|
* sysdeps/unix/sysv/linux/dl-sysdep.h: Don't declare
|
||||||
_dl_discover_osversion only for older kernels.
|
_dl_discover_osversion only for older kernels.
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Support for dynamic linking code in static libc.
|
/* Support for dynamic linking code in static libc.
|
||||||
Copyright (C) 1996-2005, 2006, 2007 Free Software Foundation, Inc.
|
Copyright (C) 1996-2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -62,8 +62,12 @@ struct link_map *_dl_profile_map;
|
|||||||
/* This is the address of the last stack address ever used. */
|
/* This is the address of the last stack address ever used. */
|
||||||
void *__libc_stack_end;
|
void *__libc_stack_end;
|
||||||
|
|
||||||
|
#ifndef __ASSUME_AT_EXECFN
|
||||||
/* Path where the binary is found. */
|
/* Path where the binary is found. */
|
||||||
const char *_dl_origin_path;
|
const char *_dl_origin_path;
|
||||||
|
#endif
|
||||||
|
/* File Name of the executable. */
|
||||||
|
const char *_dl_execfn;
|
||||||
|
|
||||||
/* Nonzero if runtime lookup should not update the .got/.plt. */
|
/* Nonzero if runtime lookup should not update the .got/.plt. */
|
||||||
int _dl_bind_not;
|
int _dl_bind_not;
|
||||||
@ -216,6 +220,9 @@ _dl_aux_init (ElfW(auxv_t) *av)
|
|||||||
__libc_enable_secure = av->a_un.a_val;
|
__libc_enable_secure = av->a_un.a_val;
|
||||||
__libc_enable_secure_decided = 1;
|
__libc_enable_secure_decided = 1;
|
||||||
break;
|
break;
|
||||||
|
case AT_EXECFN:
|
||||||
|
GLRO(dl_execfn) = (void *) av->a_un.a_val;
|
||||||
|
break;
|
||||||
# ifdef DL_PLATFORM_AUXV
|
# ifdef DL_PLATFORM_AUXV
|
||||||
DL_PLATFORM_AUXV
|
DL_PLATFORM_AUXV
|
||||||
# endif
|
# endif
|
||||||
|
@ -173,6 +173,9 @@ _dl_sysdep_start (void **start_argptr,
|
|||||||
GLRO(dl_sysinfo_dso) = (void *) av->a_un.a_val;
|
GLRO(dl_sysinfo_dso) = (void *) av->a_un.a_val;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case AT_EXECFN:
|
||||||
|
GLRO(dl_execfn) = (void *) av->a_un.a_val;
|
||||||
|
break;
|
||||||
#ifdef DL_PLATFORM_AUXV
|
#ifdef DL_PLATFORM_AUXV
|
||||||
DL_PLATFORM_AUXV
|
DL_PLATFORM_AUXV
|
||||||
#endif
|
#endif
|
||||||
|
@ -970,6 +970,8 @@ typedef struct
|
|||||||
|
|
||||||
#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
|
#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
|
||||||
|
|
||||||
|
#define AT_EXECFN 31 /* Filename of executable. */
|
||||||
|
|
||||||
/* Pointer to the global system page used for system calls and other
|
/* Pointer to the global system page used for system calls and other
|
||||||
nice things. */
|
nice things. */
|
||||||
#define AT_SYSINFO 32
|
#define AT_SYSINFO 32
|
||||||
|
@ -2579,10 +2579,12 @@ process_envvars (enum mode *modep)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 11:
|
case 11:
|
||||||
|
#ifndef __ASSUME_AT_EXECFN
|
||||||
/* Path where the binary is found. */
|
/* Path where the binary is found. */
|
||||||
if (!INTUSE(__libc_enable_secure)
|
if (!INTUSE(__libc_enable_secure)
|
||||||
&& memcmp (envline, "ORIGIN_PATH", 11) == 0)
|
&& memcmp (envline, "ORIGIN_PATH", 11) == 0)
|
||||||
GLRO(dl_origin_path) = &envline[12];
|
GLRO(dl_origin_path) = &envline[12];
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <bits/libc-lock.h>
|
#include <bits/libc-lock.h>
|
||||||
#include <hp-timing.h>
|
#include <hp-timing.h>
|
||||||
#include <tls.h>
|
#include <tls.h>
|
||||||
|
#include <kernel-features.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@ -592,8 +593,13 @@ struct rtld_global_ro
|
|||||||
/* Names of shared object for which the RPATH should be ignored. */
|
/* Names of shared object for which the RPATH should be ignored. */
|
||||||
EXTERN const char *_dl_inhibit_rpath;
|
EXTERN const char *_dl_inhibit_rpath;
|
||||||
|
|
||||||
|
#ifndef __ASSUME_AT_EXECFN
|
||||||
/* Location of the binary. */
|
/* Location of the binary. */
|
||||||
EXTERN const char *_dl_origin_path;
|
EXTERN const char *_dl_origin_path;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If set, points to the file name of the executable. */
|
||||||
|
EXTERN const char *_dl_execfn;
|
||||||
|
|
||||||
/* -1 if the dynamic linker should honor library load bias,
|
/* -1 if the dynamic linker should honor library load bias,
|
||||||
0 if not, -2 use the default (honor biases for normal
|
0 if not, -2 use the default (honor biases for normal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Find path of executable.
|
/* Find path of executable.
|
||||||
Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 1998-2000, 2002, 2004, 2008 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
||||||
|
|
||||||
@ -35,30 +35,32 @@
|
|||||||
const char *
|
const char *
|
||||||
_dl_get_origin (void)
|
_dl_get_origin (void)
|
||||||
{
|
{
|
||||||
|
#ifndef __ASSUME_AT_EXECFN
|
||||||
char linkval[PATH_MAX];
|
char linkval[PATH_MAX];
|
||||||
char *result;
|
#endif
|
||||||
|
char *str;
|
||||||
|
char *result = (char *) -1l;
|
||||||
int len;
|
int len;
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
|
||||||
|
|
||||||
len = INTERNAL_SYSCALL (readlink, err, 3, "/proc/self/exe", linkval,
|
str = GLRO(dl_execfn);
|
||||||
sizeof (linkval));
|
#ifndef __ASSUME_AT_EXECFN
|
||||||
if (! INTERNAL_SYSCALL_ERROR_P (len, err) && len > 0 && linkval[0] != '[')
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
/* We can use this value. */
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
assert (linkval[0] == '/');
|
|
||||||
while (len > 1 && linkval[len - 1] != '/')
|
len = INTERNAL_SYSCALL (readlink, err, 3, "/proc/self/exe", linkval,
|
||||||
--len;
|
sizeof (linkval));
|
||||||
result = (char *) malloc (len + 1);
|
if (! INTERNAL_SYSCALL_ERROR_P (len, err)
|
||||||
if (result == NULL)
|
&& len > 0 && linkval[0] != '[')
|
||||||
result = (char *) -1;
|
str = linkval;
|
||||||
else if (len == 1)
|
|
||||||
memcpy (result, "/", 2);
|
|
||||||
else
|
|
||||||
*((char *) __mempcpy (result, linkval, len - 1)) = '\0';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
|
len = strlen (str);
|
||||||
|
|
||||||
|
#ifndef __ASSUME_AT_EXECFN
|
||||||
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
result = (char *) -1;
|
|
||||||
/* We use the environment variable LD_ORIGIN_PATH. If it is set make
|
/* We use the environment variable LD_ORIGIN_PATH. If it is set make
|
||||||
a copy and strip out trailing slashes. */
|
a copy and strip out trailing slashes. */
|
||||||
if (GLRO(dl_origin_path) != NULL)
|
if (GLRO(dl_origin_path) != NULL)
|
||||||
@ -76,6 +78,21 @@ _dl_get_origin (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* We can use this value. */
|
||||||
|
assert (str[0] == '/');
|
||||||
|
while (len > 1 && str[len - 1] != '/')
|
||||||
|
--len;
|
||||||
|
result = (char *) malloc (len + 1);
|
||||||
|
if (result == NULL)
|
||||||
|
result = (char *) -1;
|
||||||
|
else if (len == 1)
|
||||||
|
memcpy (result, "/", 2);
|
||||||
|
else
|
||||||
|
*((char *) __mempcpy (result, str, len - 1)) = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Set flags signalling availability of kernel features based on given
|
/* Set flags signalling availability of kernel features based on given
|
||||||
kernel version number.
|
kernel version number.
|
||||||
Copyright (C) 1999-2006, 2007 Free Software Foundation, Inc.
|
Copyright (C) 1999-2006, 2007, 2008 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -492,3 +492,8 @@
|
|||||||
#if __LINUX_KERNEL_VERSION >= 0x020618
|
#if __LINUX_KERNEL_VERSION >= 0x020618
|
||||||
# define __ASSUME_ADJ_OFFSET_SS_READ 1
|
# define __ASSUME_ADJ_OFFSET_SS_READ 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Support for AT_EXECFN was added in 2.6.27. */
|
||||||
|
#if __LINUX_KERNEL_VERSION >= 0x02061b
|
||||||
|
# define __ASSUME_AT_EXECFN 1
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user