OSDN Git Service

Use PAGE_SIZE rather than hard coding 4096
authorEric Andersen <andersen@codepoet.org>
Wed, 17 Dec 2003 18:34:15 +0000 (18:34 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 17 Dec 2003 18:34:15 +0000 (18:34 -0000)
ldso/include/ldso.h
ldso/ldso/arm/elfinterp.c
ldso/ldso/dl-elf.c
ldso/ldso/ldso.c
ldso/ldso/readelflib1.c

index b5ccbfa..a7e885a 100644 (file)
@@ -9,3 +9,5 @@
 #include <ld_syscall.h>
 #include <ld_hash.h>
 #include <ld_string.h>
+/* Pull in the arch specific page size */
+#include <asm/page.h>
index 23f2f55..6c908a6 100644 (file)
@@ -249,7 +249,7 @@ fix_bad_pc24 (unsigned long *const reloc_addr, unsigned long value)
   unsigned int *fix_address;
   if (! fix_page)
     {
-      fix_page = _dl_mmap (NULL,  4096   , PROT_READ | PROT_WRITE | PROT_EXEC,
+      fix_page = _dl_mmap (NULL,  PAGE_SIZE   , PROT_READ | PROT_WRITE | PROT_EXEC,
                        MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
       fix_offset = 0;
     }
@@ -259,7 +259,7 @@ fix_bad_pc24 (unsigned long *const reloc_addr, unsigned long value)
   fix_address[1] = value;
 
   fix_offset += 8;
-  if (fix_offset >= 4096)
+  if (fix_offset >= PAGE_SIZE)
     fix_page = NULL;
 
   return (unsigned long)fix_address;
index 136f7b1..9650b2f 100644 (file)
@@ -449,7 +449,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                return NULL;
        }
 
-        header = _dl_mmap((void *) 0, 4096, PROT_READ | PROT_WRITE,
+        header = _dl_mmap((void *) 0, PAGE_SIZE, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
        if (_dl_mmap_check_error(header)) {
                _dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
@@ -458,7 +458,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                return NULL;
        };
         
-       _dl_read(infile, header, 4096);
+       _dl_read(infile, header, PAGE_SIZE);
        epnt = (ElfW(Ehdr) *) (intptr_t) header;
        if (epnt->e_ident[0] != 0x7f ||
                epnt->e_ident[1] != 'E' || 
@@ -469,7 +469,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                                         libname);
                _dl_internal_error_number = LD_ERROR_NOTELF;
                _dl_close(infile);
-               _dl_munmap(header, 4096);
+               _dl_munmap(header, PAGE_SIZE);
                return NULL;
        };
 
@@ -484,7 +484,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_dprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET 
                        "\n", _dl_progname, libname);
                _dl_close(infile);
-               _dl_munmap(header, 4096);
+               _dl_munmap(header, PAGE_SIZE);
                return NULL;
        };
 
@@ -530,7 +530,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_dprintf(2, "%s: can't map %s\n", _dl_progname, libname);
                _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
                _dl_close(infile);
-               _dl_munmap(header, 4096);
+               _dl_munmap(header, PAGE_SIZE);
                return NULL;
        };
        libaddr = (unsigned long) status;
@@ -565,7 +565,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                                        _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
                                        _dl_munmap((char *) libaddr, maxvma - minvma);
                                        _dl_close(infile);
-                                       _dl_munmap(header, 4096);
+                                       _dl_munmap(header, PAGE_SIZE);
                                        return NULL;
                                };
 
@@ -598,7 +598,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                                _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
                                _dl_munmap((char *) libaddr, maxvma - minvma);
                                _dl_close(infile);
-                               _dl_munmap(header, 4096);
+                               _dl_munmap(header, PAGE_SIZE);
                                return NULL;
                        };
 
@@ -627,7 +627,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_internal_error_number = LD_ERROR_NODYNAMIC;
                _dl_dprintf(2, "%s: '%s' is missing a dynamic section\n", 
                        _dl_progname, libname);
-                       _dl_munmap(header, 4096);
+                       _dl_munmap(header, PAGE_SIZE);
                return NULL;
        }
 
@@ -730,7 +730,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
 
        }
 #endif
-       _dl_munmap(header, 4096);
+       _dl_munmap(header, PAGE_SIZE);
 
        return tpnt;
 }
@@ -784,7 +784,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
        char *start, *ptr, *string;
        static char *buf;
 
-       buf = _dl_mmap((void *) 0, 4096, PROT_READ | PROT_WRITE,
+       buf = _dl_mmap((void *) 0, PAGE_SIZE, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
        if (_dl_mmap_check_error(buf)) {
                        _dl_write(fd, "mmap of a spare page failed!\n", 29); 
@@ -796,7 +796,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
        if (!fmt)
                return;
 
-       if (_dl_strlen(fmt) >= (4096 - 1)) {
+       if (_dl_strlen(fmt) >= (PAGE_SIZE - 1)) {
                _dl_write(fd, "overflow\n", 11);
                _dl_exit(20);
        }
@@ -854,7 +854,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
                        start = NULL;
                }
        }
-       _dl_munmap(buf, 4096);
+       _dl_munmap(buf, PAGE_SIZE);
        return;
 }
 
@@ -883,7 +883,7 @@ void *_dl_malloc(int size)
        if (_dl_malloc_function)
                return (*_dl_malloc_function) (size);
 
-       if (_dl_malloc_addr - _dl_mmap_zero + size > 4096) {
+       if (_dl_malloc_addr - _dl_mmap_zero + size > PAGE_SIZE) {
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
                _dl_dprintf(2, "malloc: mmapping more memory\n");
 #endif
index 601da62..768ff24 100644 (file)
@@ -359,7 +359,7 @@ LD_BOOT(unsigned long args)
 
        /* Call mmap to get a page of writable memory that can be used 
         * for _dl_malloc throughout the shared lib loader. */
-       mmap_zero = malloc_buffer = _dl_mmap((void *) 0, 4096
+       mmap_zero = malloc_buffer = _dl_mmap((void *) 0, PAGE_SIZE
                        PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
        if (_dl_mmap_check_error(mmap_zero)) {
                SEND_STDERR("dl_boot: mmap of a spare page failed!\n");
index 136f7b1..9650b2f 100644 (file)
@@ -449,7 +449,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                return NULL;
        }
 
-        header = _dl_mmap((void *) 0, 4096, PROT_READ | PROT_WRITE,
+        header = _dl_mmap((void *) 0, PAGE_SIZE, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
        if (_dl_mmap_check_error(header)) {
                _dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
@@ -458,7 +458,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                return NULL;
        };
         
-       _dl_read(infile, header, 4096);
+       _dl_read(infile, header, PAGE_SIZE);
        epnt = (ElfW(Ehdr) *) (intptr_t) header;
        if (epnt->e_ident[0] != 0x7f ||
                epnt->e_ident[1] != 'E' || 
@@ -469,7 +469,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                                         libname);
                _dl_internal_error_number = LD_ERROR_NOTELF;
                _dl_close(infile);
-               _dl_munmap(header, 4096);
+               _dl_munmap(header, PAGE_SIZE);
                return NULL;
        };
 
@@ -484,7 +484,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_dprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET 
                        "\n", _dl_progname, libname);
                _dl_close(infile);
-               _dl_munmap(header, 4096);
+               _dl_munmap(header, PAGE_SIZE);
                return NULL;
        };
 
@@ -530,7 +530,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_dprintf(2, "%s: can't map %s\n", _dl_progname, libname);
                _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
                _dl_close(infile);
-               _dl_munmap(header, 4096);
+               _dl_munmap(header, PAGE_SIZE);
                return NULL;
        };
        libaddr = (unsigned long) status;
@@ -565,7 +565,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                                        _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
                                        _dl_munmap((char *) libaddr, maxvma - minvma);
                                        _dl_close(infile);
-                                       _dl_munmap(header, 4096);
+                                       _dl_munmap(header, PAGE_SIZE);
                                        return NULL;
                                };
 
@@ -598,7 +598,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                                _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
                                _dl_munmap((char *) libaddr, maxvma - minvma);
                                _dl_close(infile);
-                               _dl_munmap(header, 4096);
+                               _dl_munmap(header, PAGE_SIZE);
                                return NULL;
                        };
 
@@ -627,7 +627,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
                _dl_internal_error_number = LD_ERROR_NODYNAMIC;
                _dl_dprintf(2, "%s: '%s' is missing a dynamic section\n", 
                        _dl_progname, libname);
-                       _dl_munmap(header, 4096);
+                       _dl_munmap(header, PAGE_SIZE);
                return NULL;
        }
 
@@ -730,7 +730,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
 
        }
 #endif
-       _dl_munmap(header, 4096);
+       _dl_munmap(header, PAGE_SIZE);
 
        return tpnt;
 }
@@ -784,7 +784,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
        char *start, *ptr, *string;
        static char *buf;
 
-       buf = _dl_mmap((void *) 0, 4096, PROT_READ | PROT_WRITE,
+       buf = _dl_mmap((void *) 0, PAGE_SIZE, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
        if (_dl_mmap_check_error(buf)) {
                        _dl_write(fd, "mmap of a spare page failed!\n", 29); 
@@ -796,7 +796,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
        if (!fmt)
                return;
 
-       if (_dl_strlen(fmt) >= (4096 - 1)) {
+       if (_dl_strlen(fmt) >= (PAGE_SIZE - 1)) {
                _dl_write(fd, "overflow\n", 11);
                _dl_exit(20);
        }
@@ -854,7 +854,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
                        start = NULL;
                }
        }
-       _dl_munmap(buf, 4096);
+       _dl_munmap(buf, PAGE_SIZE);
        return;
 }
 
@@ -883,7 +883,7 @@ void *_dl_malloc(int size)
        if (_dl_malloc_function)
                return (*_dl_malloc_function) (size);
 
-       if (_dl_malloc_addr - _dl_mmap_zero + size > 4096) {
+       if (_dl_malloc_addr - _dl_mmap_zero + size > PAGE_SIZE) {
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
                _dl_dprintf(2, "malloc: mmapping more memory\n");
 #endif