1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-05 19:35:52 +03:00

* elf/dl-load.c: Remove support for systems without MAP_ANON.

* elf/dl-minimal.c: Likewise.
	* elf/dl-misc.c: Likewise.
	* elf/rtld.c: Likewise.
	* sysdeps/generic/ldsodefs.h: Likewise.
This commit is contained in:
Ulrich Drepper
2009-03-31 22:03:24 +00:00
parent cb14424eb9
commit 20739e5454
6 changed files with 13 additions and 45 deletions

View File

@@ -1,3 +1,11 @@
2009-03-31 Ulrich Drepper <drepper@redhat.com>
* elf/dl-load.c: Remove support for systems without MAP_ANON.
* elf/dl-minimal.c: Likewise.
* elf/dl-misc.c: Likewise.
* elf/rtld.c: Likewise.
* sysdeps/generic/ldsodefs.h: Likewise.
2009-03-30 Ulrich Drepper <drepper@redhat.com> 2009-03-30 Ulrich Drepper <drepper@redhat.com>
* elf/do-lookup.h (do_lookup_x): Minor optimization and cleanup. * elf/do-lookup.h (do_lookup_x): Minor optimization and cleanup.

View File

@@ -85,14 +85,6 @@
#define STRING(x) __STRING (x) #define STRING(x) __STRING (x)
#ifdef MAP_ANON
/* The fd is not examined when using MAP_ANON. */
# define ANONFD -1
#else
int _dl_zerofd = -1;
# define ANONFD _dl_zerofd
#endif
/* Handle situations where we have a preferred location in memory for /* Handle situations where we have a preferred location in memory for
the shared objects. */ the shared objects. */
#ifdef ELF_PREFERRED_ADDRESS_DATA #ifdef ELF_PREFERRED_ADDRESS_DATA
@@ -1312,7 +1304,7 @@ cannot allocate TLS data structures for initial thread");
caddr_t mapat; caddr_t mapat;
mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage, mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage,
c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED, c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED,
ANONFD, 0); -1, 0);
if (__builtin_expect (mapat == MAP_FAILED, 0)) if (__builtin_expect (mapat == MAP_FAILED, 0))
{ {
errstring = N_("cannot map zero-fill pages"); errstring = N_("cannot map zero-fill pages");

View File

@@ -1,5 +1,5 @@
/* Minimal replacements for basic facilities used in the dynamic linker. /* Minimal replacements for basic facilities used in the dynamic linker.
Copyright (C) 1995-1998,2000-2002,2004-2006,2007 Copyright (C) 1995-1998,2000-2002,2004-2006,2007,2009
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@@ -51,16 +51,6 @@ extern unsigned long int weak_function strtoul (const char *nptr,
void * weak_function void * weak_function
__libc_memalign (size_t align, size_t n) __libc_memalign (size_t align, size_t n)
{ {
#ifdef MAP_ANON
#define _dl_zerofd (-1)
#else
extern int _dl_zerofd;
if (_dl_zerofd == -1)
_dl_zerofd = _dl_sysdep_open_zero_fill ();
#define MAP_ANON 0
#endif
if (alloc_end == 0) if (alloc_end == 0)
{ {
/* Consume any unused space in the last page of our data segment. */ /* Consume any unused space in the last page of our data segment. */
@@ -87,7 +77,7 @@ __libc_memalign (size_t align, size_t n)
nup = GLRO(dl_pagesize); nup = GLRO(dl_pagesize);
} }
page = __mmap (0, nup, PROT_READ|PROT_WRITE, page = __mmap (0, nup, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, _dl_zerofd, 0); MAP_ANON|MAP_PRIVATE, -1, 0);
if (page == MAP_FAILED) if (page == MAP_FAILED)
return NULL; return NULL;
if (page != alloc_end) if (page != alloc_end)

View File

@@ -1,5 +1,5 @@
/* Miscellaneous support functions for dynamic linker /* Miscellaneous support functions for dynamic linker
Copyright (C) 1997-2002, 2003, 2004, 2006 Free Software Foundation, Inc. Copyright (C) 1997-2004, 2006, 2009 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
@@ -34,17 +34,6 @@
#include <stdio-common/_itoa.h> #include <stdio-common/_itoa.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#ifndef MAP_ANON
/* This is the only dl-sysdep.c function that is actually needed at run-time
by _dl_map_object. */
int
_dl_sysdep_open_zero_fill (void)
{
return __open ("/dev/zero", O_RDONLY);
}
#endif
/* Read the whole contents of FILE into new mmap'd space with given /* Read the whole contents of FILE into new mmap'd space with given
protections. *SIZEP gets the size of the file. On error MAP_FAILED protections. *SIZEP gets the size of the file. On error MAP_FAILED
is returned. */ is returned. */

View File

@@ -24,7 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> /* Check if MAP_ANON is defined. */ #include <sys/mman.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ldsodefs.h> #include <ldsodefs.h>
@@ -1782,12 +1782,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
for (i = main_map->l_searchlist.r_nlist; i > 0; ) for (i = main_map->l_searchlist.r_nlist; i > 0; )
main_map->l_searchlist.r_list[--i]->l_global = 1; main_map->l_searchlist.r_list[--i]->l_global = 1;
#ifndef MAP_ANON
/* We are done mapping things, so close the zero-fill descriptor. */
__close (_dl_zerofd);
_dl_zerofd = -1;
#endif
/* Remove _dl_rtld_map from the chain. */ /* Remove _dl_rtld_map from the chain. */
GL(dl_rtld_map).l_prev->l_next = GL(dl_rtld_map).l_next; GL(dl_rtld_map).l_prev->l_next = GL(dl_rtld_map).l_next;
if (GL(dl_rtld_map).l_next != NULL) if (GL(dl_rtld_map).l_next != NULL)

View File

@@ -399,11 +399,6 @@ struct rtld_global
/* Incremented whenever something may have been added to dl_loaded. */ /* Incremented whenever something may have been added to dl_loaded. */
EXTERN unsigned long long _dl_load_adds; EXTERN unsigned long long _dl_load_adds;
#ifndef MAP_ANON
/* File descriptor referring to the zero-fill device. */
EXTERN int _dl_zerofd;
#endif
/* The object to be initialized first. */ /* The object to be initialized first. */
EXTERN struct link_map *_dl_initfirst; EXTERN struct link_map *_dl_initfirst;