mirror of git://sourceware.org/git/glibc.git
Update.
2004-09-20 Ulrich Drepper <drepper@redhat.com> * elf/dl-load.c (_dl_map_object_from_fd): Add some error checking. Reorder code slightly. * elf/rtld.c (dl_main): No need to check whether l_info[DT_HASH] is non-null, _dl_setup_hash will do that.
This commit is contained in:
parent
2edb61e3f9
commit
efec50797a
|
@ -1,3 +1,10 @@
|
||||||
|
2004-09-20 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-load.c (_dl_map_object_from_fd): Add some error checking.
|
||||||
|
Reorder code slightly.
|
||||||
|
* elf/rtld.c (dl_main): No need to check whether l_info[DT_HASH]
|
||||||
|
is non-null, _dl_setup_hash will do that.
|
||||||
|
|
||||||
2004-09-19 Ulrich Drepper <drepper@redhat.com>
|
2004-09-19 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/setegid.c [HAVE_PTR__NPTL_SETXID]: Call
|
* sysdeps/unix/sysv/linux/setegid.c [HAVE_PTR__NPTL_SETXID]: Call
|
||||||
|
|
139
elf/dl-load.c
139
elf/dl-load.c
|
@ -1126,21 +1126,20 @@ cannot allocate TLS data structures for initial thread");
|
||||||
|
|
||||||
goto postmap;
|
goto postmap;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This object is loaded at a fixed address. This must never
|
|
||||||
happen for objects loaded with dlopen(). */
|
|
||||||
if (__builtin_expect ((mode & __RTLD_OPENEXEC) == 0, 0))
|
|
||||||
{
|
|
||||||
errstring = N_("cannot dynamically load executable");
|
|
||||||
goto call_lose;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Notify ELF_PREFERRED_ADDRESS that we have to load this one
|
/* This object is loaded at a fixed address. This must never
|
||||||
fixed. */
|
happen for objects loaded with dlopen(). */
|
||||||
ELF_FIXED_ADDRESS (loader, c->mapstart);
|
if (__builtin_expect ((mode & __RTLD_OPENEXEC) == 0, 0))
|
||||||
|
{
|
||||||
|
errstring = N_("cannot dynamically load executable");
|
||||||
|
goto call_lose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Notify ELF_PREFERRED_ADDRESS that we have to load this one
|
||||||
|
fixed. */
|
||||||
|
ELF_FIXED_ADDRESS (loader, c->mapstart);
|
||||||
|
|
||||||
|
|
||||||
/* Remember which part of the address space this object uses. */
|
/* Remember which part of the address space this object uses. */
|
||||||
l->l_map_start = c->mapstart + l->l_addr;
|
l->l_map_start = c->mapstart + l->l_addr;
|
||||||
l->l_map_end = l->l_map_start + maplength;
|
l->l_map_end = l->l_map_start + maplength;
|
||||||
|
@ -1220,43 +1219,8 @@ cannot allocate TLS data structures for initial thread");
|
||||||
|
|
||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->l_phdr == NULL)
|
|
||||||
{
|
|
||||||
/* The program header is not contained in any of the segments.
|
|
||||||
We have to allocate memory ourself and copy it over from
|
|
||||||
out temporary place. */
|
|
||||||
ElfW(Phdr) *newp = (ElfW(Phdr) *) malloc (header->e_phnum
|
|
||||||
* sizeof (ElfW(Phdr)));
|
|
||||||
if (newp == NULL)
|
|
||||||
{
|
|
||||||
errstring = N_("cannot allocate memory for program header");
|
|
||||||
goto call_lose_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
l->l_phdr = memcpy (newp, phdr,
|
|
||||||
(header->e_phnum * sizeof (ElfW(Phdr))));
|
|
||||||
l->l_phdr_allocated = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* Adjust the PT_PHDR value by the runtime load address. */
|
|
||||||
l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_TLS
|
|
||||||
/* Adjust the address of the TLS initialization image. */
|
|
||||||
if (l->l_tls_initimage != NULL)
|
|
||||||
l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We are done mapping in the file. We no longer need the descriptor. */
|
|
||||||
__close (fd);
|
|
||||||
/* Signal that we closed the file. */
|
|
||||||
fd = -1;
|
|
||||||
|
|
||||||
if (l->l_type == lt_library && type == ET_EXEC)
|
|
||||||
l->l_type = lt_executable;
|
|
||||||
|
|
||||||
if (l->l_ld == 0)
|
if (l->l_ld == 0)
|
||||||
{
|
{
|
||||||
if (__builtin_expect (type == ET_DYN, 0))
|
if (__builtin_expect (type == ET_DYN, 0))
|
||||||
|
@ -1268,27 +1232,10 @@ cannot allocate TLS data structures for initial thread");
|
||||||
else
|
else
|
||||||
l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||||
|
|
||||||
l->l_entry += l->l_addr;
|
|
||||||
|
|
||||||
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
|
|
||||||
_dl_debug_printf ("\
|
|
||||||
dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\
|
|
||||||
entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n",
|
|
||||||
(int) sizeof (void *) * 2,
|
|
||||||
(unsigned long int) l->l_ld,
|
|
||||||
(int) sizeof (void *) * 2,
|
|
||||||
(unsigned long int) l->l_addr,
|
|
||||||
(int) sizeof (void *) * 2, maplength,
|
|
||||||
(int) sizeof (void *) * 2,
|
|
||||||
(unsigned long int) l->l_entry,
|
|
||||||
(int) sizeof (void *) * 2,
|
|
||||||
(unsigned long int) l->l_phdr,
|
|
||||||
(int) sizeof (void *) * 2, l->l_phnum);
|
|
||||||
|
|
||||||
elf_get_dynamic_info (l, NULL);
|
elf_get_dynamic_info (l, NULL);
|
||||||
|
|
||||||
/* Make sure we are not dlopen'ing an object
|
/* Make sure we are not dlopen'ing an object that has the
|
||||||
that has the DF_1_NOOPEN flag set. */
|
DF_1_NOOPEN flag set. */
|
||||||
if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
|
if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
|
||||||
&& (mode & __RTLD_DLOPEN))
|
&& (mode & __RTLD_DLOPEN))
|
||||||
{
|
{
|
||||||
|
@ -1305,6 +1252,27 @@ cannot allocate TLS data structures for initial thread");
|
||||||
goto call_lose;
|
goto call_lose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (l->l_phdr == NULL)
|
||||||
|
{
|
||||||
|
/* The program header is not contained in any of the segments.
|
||||||
|
We have to allocate memory ourself and copy it over from out
|
||||||
|
temporary place. */
|
||||||
|
ElfW(Phdr) *newp = (ElfW(Phdr) *) malloc (header->e_phnum
|
||||||
|
* sizeof (ElfW(Phdr)));
|
||||||
|
if (newp == NULL)
|
||||||
|
{
|
||||||
|
errstring = N_("cannot allocate memory for program header");
|
||||||
|
goto call_lose_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
l->l_phdr = memcpy (newp, phdr,
|
||||||
|
(header->e_phnum * sizeof (ElfW(Phdr))));
|
||||||
|
l->l_phdr_allocated = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Adjust the PT_PHDR value by the runtime load address. */
|
||||||
|
l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr);
|
||||||
|
|
||||||
if (__builtin_expect ((stack_flags &~ GL(dl_stack_flags)) & PF_X, 0))
|
if (__builtin_expect ((stack_flags &~ GL(dl_stack_flags)) & PF_X, 0))
|
||||||
{
|
{
|
||||||
/* The stack is presently not executable, but this module
|
/* The stack is presently not executable, but this module
|
||||||
|
@ -1334,8 +1302,43 @@ cannot enable executable stack as shared object requires");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->l_info[DT_HASH])
|
#ifdef USE_TLS
|
||||||
_dl_setup_hash (l);
|
/* Adjust the address of the TLS initialization image. */
|
||||||
|
if (l->l_tls_initimage != NULL)
|
||||||
|
l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We are done mapping in the file. We no longer need the descriptor. */
|
||||||
|
if (__builtin_expect (__close (fd) != 0, 0))
|
||||||
|
{
|
||||||
|
errstring = N_("cannot close file descriptor");
|
||||||
|
goto call_lose_errno;
|
||||||
|
}
|
||||||
|
/* Signal that we closed the file. */
|
||||||
|
fd = -1;
|
||||||
|
|
||||||
|
if (l->l_type == lt_library && type == ET_EXEC)
|
||||||
|
l->l_type = lt_executable;
|
||||||
|
|
||||||
|
l->l_entry += l->l_addr;
|
||||||
|
|
||||||
|
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
|
||||||
|
_dl_debug_printf ("\
|
||||||
|
dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\
|
||||||
|
entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n",
|
||||||
|
(int) sizeof (void *) * 2,
|
||||||
|
(unsigned long int) l->l_ld,
|
||||||
|
(int) sizeof (void *) * 2,
|
||||||
|
(unsigned long int) l->l_addr,
|
||||||
|
(int) sizeof (void *) * 2, maplength,
|
||||||
|
(int) sizeof (void *) * 2,
|
||||||
|
(unsigned long int) l->l_entry,
|
||||||
|
(int) sizeof (void *) * 2,
|
||||||
|
(unsigned long int) l->l_phdr,
|
||||||
|
(int) sizeof (void *) * 2, l->l_phnum);
|
||||||
|
|
||||||
|
/* Set up the symbol hash table. */
|
||||||
|
_dl_setup_hash (l);
|
||||||
|
|
||||||
/* If this object has DT_SYMBOLIC set modify now its scope. We don't
|
/* If this object has DT_SYMBOLIC set modify now its scope. We don't
|
||||||
have to do this for the main map. */
|
have to do this for the main map. */
|
||||||
|
|
|
@ -1039,9 +1039,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||||
{
|
{
|
||||||
/* Extract the contents of the dynamic section for easy access. */
|
/* Extract the contents of the dynamic section for easy access. */
|
||||||
elf_get_dynamic_info (GL(dl_loaded), NULL);
|
elf_get_dynamic_info (GL(dl_loaded), NULL);
|
||||||
if (GL(dl_loaded)->l_info[DT_HASH])
|
/* Set up our cache of pointers into the hash table. */
|
||||||
/* Set up our cache of pointers into the hash table. */
|
_dl_setup_hash (GL(dl_loaded));
|
||||||
_dl_setup_hash (GL(dl_loaded));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__builtin_expect (mode, normal) == verify)
|
if (__builtin_expect (mode, normal) == verify)
|
||||||
|
|
Loading…
Reference in New Issue