* the loader.  We need to make sure that it is out of the way of the program
  * that it will "exec", and that there is sufficient room for the brk.
  */
-extern unsigned long randomize_et_dyn(unsigned long base);
 #define ELF_ET_DYN_BASE        (2 * TASK_SIZE_64 / 3)
 
 /*
 
 
 static unsigned long mmap_rnd(void)
 {
-       unsigned long rnd = 0;
+       unsigned long rnd;
 
-       if (current->flags & PF_RANDOMIZE)
-               rnd = (long)get_random_int() & STACK_RND_MASK;
+       rnd = (unsigned long)get_random_int() & STACK_RND_MASK;
 
        return rnd << PAGE_SHIFT;
 }
 
-static unsigned long mmap_base(void)
+static unsigned long mmap_base(unsigned long rnd)
 {
        unsigned long gap = rlimit(RLIMIT_STACK);
 
        else if (gap > MAX_GAP)
                gap = MAX_GAP;
 
-       return PAGE_ALIGN(STACK_TOP - gap - mmap_rnd());
+       return PAGE_ALIGN(STACK_TOP - gap - rnd);
 }
 
 /*
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
+       unsigned long random_factor = 0UL;
+
+       if (current->flags & PF_RANDOMIZE)
+               random_factor = mmap_rnd();
+
        /*
         * Fall back to the standard layout if the personality bit is set, or
         * if the expected stack growth is unlimited:
         */
        if (mmap_is_legacy()) {
-               mm->mmap_base = TASK_UNMAPPED_BASE;
+               mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
                mm->get_unmapped_area = arch_get_unmapped_area;
        } else {
-               mm->mmap_base = mmap_base();
+               mm->mmap_base = mmap_base(random_factor);
                mm->get_unmapped_area = arch_get_unmapped_area_topdown;
        }
 }