Forráskód Böngészése

Remove poor man's malloc. Not needed anymore.

Joakim Tjernlund 21 éve
szülő
commit
85c39a6b66
3 módosított fájl, 9 hozzáadás és 34 törlés
  1. 1 2
      ldso/include/ldso.h
  2. 3 26
      ldso/ldso/dl-startup.c
  3. 5 6
      ldso/ldso/ldso.c

+ 1 - 2
ldso/include/ldso.h

@@ -68,8 +68,7 @@ extern char *_dl_strdup(const char *string);
 extern void _dl_dprintf(int, const char *, ...);
 extern void _dl_dprintf(int, const char *, ...);
 
 
 extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 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_ */
 #endif /* _LDSO_H_ */

+ 3 - 26
ldso/ldso/dl-startup.c

@@ -90,14 +90,6 @@
 
 
 #include "ldso.h"
 #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 */
 /* Pull in all the arch specific stuff */
 #include "dl-startup.h"
 #include "dl-startup.h"
 
 
@@ -126,11 +118,10 @@ DL_BOOT(unsigned long args)
 	unsigned long *aux_dat;
 	unsigned long *aux_dat;
 	int goof = 0;
 	int goof = 0;
 	ElfW(Ehdr) *header;
 	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];
 	Elf32_auxv_t auxvt[AT_EGID + 1];
-	unsigned char *malloc_buffer, *mmap_zero;
 	Elf32_Dyn *dpnt;
 	Elf32_Dyn *dpnt;
-	size_t pagesize;
 	int indx;
 	int indx;
 #if defined(__i386__)
 #if defined(__i386__)
 	int status = 0;
 	int status = 0;
@@ -283,19 +274,6 @@ found_got:
 	SEND_STDERR("First Dynamic section entry=");
 	SEND_STDERR("First Dynamic section entry=");
 	SEND_ADDRESS_STDERR(dpnt, 1);
 	SEND_ADDRESS_STDERR(dpnt, 1);
 #endif
 #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));
 	_dl_memset(tpnt, 0, sizeof(struct elf_resolve));
 
 
 	/* OK, that was easy.  Next scan the DYNAMIC section of the image.
 	/* 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
 	   free to start using global variables, since these things have all been
 	   fixed up by now.  Still no function calls outside of this library ,
 	   fixed up by now.  Still no function calls outside of this library ,
 	   since the dynamic resolver is not yet ready. */
 	   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.  */
 	/* Transfer control to the application.  */

+ 5 - 6
ldso/ldso/ldso.c

@@ -85,8 +85,7 @@ static void debug_fini (int status, void *arg)
 #endif
 #endif
 
 
 void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 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;
 	ElfW(Phdr) *ppnt;
 	Elf32_Dyn *dpnt;
 	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");
 	SEND_STDERR("Cool, we managed to make a function call.\n");
 #endif
 #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
 	/* 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
 	 * allocated.  We shouldn't need to grab any more memory.  This must
 	 * be first since things like _dl_dprintf() use _dl_malloc().... */
 	 * 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
 	/* 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
 	 * free to start using global variables, since these things have all been