OSDN Git Service

Remove poor man's malloc. Not needed anymore.
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>
Thu, 19 Aug 2004 09:34:11 +0000 (09:34 -0000)
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>
Thu, 19 Aug 2004 09:34:11 +0000 (09:34 -0000)
ldso/include/ldso.h
ldso/ldso/dl-startup.c
ldso/ldso/ldso.c

index f34fe17..3d36a25 100644 (file)
@@ -68,8 +68,7 @@ extern char *_dl_strdup(const char *string);
 extern void _dl_dprintf(int, const char *, ...);
 
 extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
-               Elf32_auxv_t auxvt[AT_EGID + 1], char **envp,
-               unsigned char *malloc_buffer, unsigned char *mmap_zero, char **argv);
+               Elf32_auxv_t auxvt[AT_EGID + 1], char **envp, char **argv);
 
 
 #endif /* _LDSO_H_ */
index 88ca8bd..3ffbf3d 100644 (file)
 
 #include "ldso.h"
 
-/* This is a poor man's malloc, used prior to resolving our internal poor man's malloc */
-#define LD_MALLOC(SIZE) ((void *) (malloc_buffer += SIZE, malloc_buffer - SIZE)) ;  REALIGN();
-
-/* Make sure that the malloc buffer is aligned on 4 byte boundary.  For 64 bit
- * platforms we may need to increase this to 8, but this is good enough for
- * now.  This is typically called after LD_MALLOC.  */
-#define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3))
-
 /* Pull in all the arch specific stuff */
 #include "dl-startup.h"
 
@@ -126,11 +118,10 @@ DL_BOOT(unsigned long args)
        unsigned long *aux_dat;
        int goof = 0;
        ElfW(Ehdr) *header;
-       struct elf_resolve *tpnt;
+       struct elf_resolve tpnt_tmp;
+       struct elf_resolve *tpnt = &tpnt_tmp;
        Elf32_auxv_t auxvt[AT_EGID + 1];
-       unsigned char *malloc_buffer, *mmap_zero;
        Elf32_Dyn *dpnt;
-       size_t pagesize;
        int indx;
 #if defined(__i386__)
        int status = 0;
@@ -283,19 +274,6 @@ found_got:
        SEND_STDERR("First Dynamic section entry=");
        SEND_ADDRESS_STDERR(dpnt, 1);
 #endif
-
-
-       /* Call mmap to get a page of writable memory that can be used
-        * for _dl_malloc throughout the shared lib loader. */
-       pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
-       mmap_zero = malloc_buffer = _dl_mmap((void *) 0, pagesize,
-                       PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-       if (_dl_mmap_check_error(mmap_zero)) {
-               SEND_STDERR("dl_boot: mmap of a spare page failed!\n");
-               _dl_exit(13);
-       }
-
-       tpnt = LD_MALLOC(sizeof(struct elf_resolve));
        _dl_memset(tpnt, 0, sizeof(struct elf_resolve));
 
        /* OK, that was easy.  Next scan the DYNAMIC section of the image.
@@ -425,8 +403,7 @@ found_got:
           free to start using global variables, since these things have all been
           fixed up by now.  Still no function calls outside of this library ,
           since the dynamic resolver is not yet ready. */
-       _dl_get_ready_to_run(tpnt, load_addr, auxvt, envp,
-                            malloc_buffer, mmap_zero, argv);
+       _dl_get_ready_to_run(tpnt, load_addr, auxvt, envp, argv);
 
 
        /* Transfer control to the application.  */
index ce15d0e..7fe1f3f 100644 (file)
@@ -85,8 +85,7 @@ static void debug_fini (int status, void *arg)
 #endif
 
 void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
-               Elf32_auxv_t auxvt[AT_EGID + 1], char **envp,
-               unsigned char *malloc_buffer, unsigned char *mmap_zero, char **argv)
+               Elf32_auxv_t auxvt[AT_EGID + 1], char **envp, char **argv)
 {
        ElfW(Phdr) *ppnt;
        Elf32_Dyn *dpnt;
@@ -109,14 +108,14 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
        SEND_STDERR("Cool, we managed to make a function call.\n");
 #endif
 
+       /* Store the page size for later use */
+       _dl_pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
        /* Make it so _dl_malloc can use the page of memory we have already
         * allocated.  We shouldn't need to grab any more memory.  This must
         * be first since things like _dl_dprintf() use _dl_malloc().... */
-       _dl_malloc_addr = malloc_buffer;
-       _dl_mmap_zero = mmap_zero;
+       _dl_malloc_addr = (unsigned char *)_dl_pagesize;
+       _dl_mmap_zero = 0;
 
-       /* Store the page size for later use */
-       _dl_pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
 
        /* Now we have done the mandatory linking of some things.  We are now
         * free to start using global variables, since these things have all been