~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/frv/mm/elf-fdpic.c

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* elf-fdpic.c: ELF FDPIC memory layout management
  2  *
  3  * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4  * Written by David Howells (dhowells@redhat.com)
  5  *
  6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU General Public License
  8  * as published by the Free Software Foundation; either version
  9  * 2 of the License, or (at your option) any later version.
 10  */
 11 
 12 #include <linux/sched.h>
 13 #include <linux/mm.h>
 14 #include <linux/fs.h>
 15 #include <linux/elf-fdpic.h>
 16 #include <asm/mman.h>
 17 
 18 /*****************************************************************************/
 19 /*
 20  * lay out the userspace VM according to our grand design
 21  */
 22 #ifdef CONFIG_MMU
 23 void elf_fdpic_arch_lay_out_mm(struct elf_fdpic_params *exec_params,
 24                                struct elf_fdpic_params *interp_params,
 25                                unsigned long *start_stack,
 26                                unsigned long *start_brk)
 27 {
 28         *start_stack = 0x02200000UL;
 29 
 30         /* if the only executable is a shared object, assume that it is an interpreter rather than
 31          * a true executable, and map it such that "ld.so --list" comes out right
 32          */
 33         if (!(interp_params->flags & ELF_FDPIC_FLAG_PRESENT) &&
 34             exec_params->hdr.e_type != ET_EXEC
 35             ) {
 36                 exec_params->load_addr = PAGE_SIZE;
 37 
 38                 *start_brk = 0x80000000UL;
 39         }
 40         else {
 41                 exec_params->load_addr = 0x02200000UL;
 42 
 43                 if ((exec_params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) ==
 44                     ELF_FDPIC_FLAG_INDEPENDENT
 45                     ) {
 46                         exec_params->flags &= ~ELF_FDPIC_FLAG_ARRANGEMENT;
 47                         exec_params->flags |= ELF_FDPIC_FLAG_CONSTDISP;
 48                 }
 49         }
 50 
 51 } /* end elf_fdpic_arch_lay_out_mm() */
 52 #endif
 53 
 54 /*****************************************************************************/
 55 /*
 56  * place non-fixed mmaps firstly in the bottom part of memory, working up, and then in the top part
 57  * of memory, working down
 58  */
 59 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len,
 60                                      unsigned long pgoff, unsigned long flags)
 61 {
 62         struct vm_area_struct *vma;
 63         unsigned long limit;
 64 
 65         if (len > TASK_SIZE)
 66                 return -ENOMEM;
 67 
 68         /* handle MAP_FIXED */
 69         if (flags & MAP_FIXED)
 70                 return addr;
 71 
 72         /* only honour a hint if we're not going to clobber something doing so */
 73         if (addr) {
 74                 addr = PAGE_ALIGN(addr);
 75                 vma = find_vma(current->mm, addr);
 76                 if (TASK_SIZE - len >= addr &&
 77                     (!vma || addr + len <= vma->vm_start))
 78                         goto success;
 79         }
 80 
 81         /* search between the bottom of user VM and the stack grow area */
 82         addr = PAGE_SIZE;
 83         limit = (current->mm->start_stack - 0x00200000);
 84         if (addr + len <= limit) {
 85                 limit -= len;
 86 
 87                 if (addr <= limit) {
 88                         vma = find_vma(current->mm, PAGE_SIZE);
 89                         for (; vma; vma = vma->vm_next) {
 90                                 if (addr > limit)
 91                                         break;
 92                                 if (addr + len <= vma->vm_start)
 93                                         goto success;
 94                                 addr = vma->vm_end;
 95                         }
 96                 }
 97         }
 98 
 99         /* search from just above the WorkRAM area to the top of memory */
100         addr = PAGE_ALIGN(0x80000000);
101         limit = TASK_SIZE - len;
102         if (addr <= limit) {
103                 vma = find_vma(current->mm, addr);
104                 for (; vma; vma = vma->vm_next) {
105                         if (addr > limit)
106                                 break;
107                         if (addr + len <= vma->vm_start)
108                                 goto success;
109                         addr = vma->vm_end;
110                 }
111 
112                 if (!vma && addr <= limit)
113                         goto success;
114         }
115 
116 #if 0
117         printk("[area] l=%lx (ENOMEM) f='%s'\n",
118                len, filp ? filp->f_path.dentry->d_name.name : "");
119 #endif
120         return -ENOMEM;
121 
122  success:
123 #if 0
124         printk("[area] l=%lx ad=%lx f='%s'\n",
125                len, addr, filp ? filp->f_path.dentry->d_name.name : "");
126 #endif
127         return addr;
128 } /* end arch_get_unmapped_area() */
129 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp