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

TOMOYO Linux Cross Reference
Linux/arch/arm/kernel/elf.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm/kernel/elf.c (Version linux-6.12-rc7) and /arch/m68k/kernel/elf.c (Version linux-5.15.171)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 #include <linux/export.h>                         
  3 #include <linux/sched.h>                          
  4 #include <linux/personality.h>                    
  5 #include <linux/binfmts.h>                        
  6 #include <linux/elf.h>                            
  7 #include <linux/elf-fdpic.h>                      
  8 #include <asm/system_info.h>                      
  9                                                   
 10 int elf_check_arch(const struct elf32_hdr *x)     
 11 {                                                 
 12         unsigned int eflags;                      
 13                                                   
 14         /* Make sure it's an ARM executable */    
 15         if (x->e_machine != EM_ARM)               
 16                 return 0;                         
 17                                                   
 18         /* Make sure the entry address is reas    
 19         if (x->e_entry & 1) {                     
 20                 if (!(elf_hwcap & HWCAP_THUMB)    
 21                         return 0;                 
 22         } else if (x->e_entry & 3)                
 23                 return 0;                         
 24                                                   
 25         eflags = x->e_flags;                      
 26         if ((eflags & EF_ARM_EABI_MASK) == EF_    
 27                 unsigned int flt_fmt;             
 28                                                   
 29                 /* APCS26 is only allowed if t    
 30                 if ((eflags & EF_ARM_APCS_26)     
 31                         return 0;                 
 32                                                   
 33                 flt_fmt = eflags & (EF_ARM_VFP    
 34                                                   
 35                 /* VFP requires the supporting    
 36                 if (flt_fmt == EF_ARM_VFP_FLOA    
 37                         return 0;                 
 38         }                                         
 39         return 1;                                 
 40 }                                                 
 41 EXPORT_SYMBOL(elf_check_arch);                    
 42                                                   
 43 void elf_set_personality(const struct elf32_hd    
 44 {                                                 
 45         unsigned int eflags = x->e_flags;         
 46         unsigned int personality = current->pe    
 47                                                   
 48         /*                                        
 49          * We only support Linux ELF executabl    
 50          * personality to LINUX.                  
 51          */                                       
 52         personality |= PER_LINUX;                 
 53                                                   
 54         /*                                        
 55          * APCS-26 is only valid for OABI exec    
 56          */                                       
 57         if ((eflags & EF_ARM_EABI_MASK) == EF_    
 58             (eflags & EF_ARM_APCS_26))            
 59                 personality &= ~ADDR_LIMIT_32B    
 60         else                                      
 61                 personality |= ADDR_LIMIT_32BI    
 62                                                   
 63         set_personality(personality);             
 64                                                   
 65         /*                                        
 66          * Since the FPA coprocessor uses CP1     
 67          * and CP1, we only enable access to t    
 68          * binary is EABI or softfloat (and th    
 69          * FPA instructions.)                     
 70          */                                       
 71         if (elf_hwcap & HWCAP_IWMMXT &&           
 72             eflags & (EF_ARM_EABI_MASK | EF_AR    
 73                 set_thread_flag(TIF_USING_IWMM    
 74         } else {                                  
 75                 clear_thread_flag(TIF_USING_IW    
 76         }                                         
 77 }                                                 
 78 EXPORT_SYMBOL(elf_set_personality);               
 79                                                   
 80 /*                                                
 81  * An executable for which elf_read_implies_ex    
 82  * have the READ_IMPLIES_EXEC personality flag    
 83  *                                                
 84  * The decision process for determining the re    
 85  *                                                
 86  *                 CPU: | lacks NX*  |    
 87  * ELF:                 |             
 88  * ---------------------|------------|--------    
 89  * missing PT_GNU_STACK | exec-all   | exec-a    
 90  * PT_GNU_STACK == RWX  | exec-all   | exec-    
 91  * PT_GNU_STACK == RW   | exec-all   | exec-    
 92  *                                                
 93  *  exec-all  : all PROT_READ user mappings ar    
 94  *              backed by files on a noexec-fi    
 95  *  exec-none : only PROT_EXEC user mappings a    
 96  *  exec-stack: only the stack and PROT_EXEC u    
 97  *                                                
 98  *  *this column has no architectural effect:     
 99  *   hardware, but may have behavioral effects    
100  *   "cannot be X" constraints in memory permi    
101  *   https://lkml.kernel.org/r/20190418055759.    
102  *                                                
103  */                                               
104 int arm_elf_read_implies_exec(int executable_s    
105 {                                                 
106         if (executable_stack == EXSTACK_DEFAUL    
107                 return 1;                         
108         if (cpu_architecture() < CPU_ARCH_ARMv    
109                 return 1;                         
110         return 0;                                 
111 }                                                 
112 EXPORT_SYMBOL(arm_elf_read_implies_exec);         
113                                                   
114 #if defined(CONFIG_MMU) && defined(CONFIG_BINF    
115                                                   
116 void elf_fdpic_arch_lay_out_mm(struct elf_fdpi    
117                                struct elf_fdpi    
118                                unsigned long *    
119                                unsigned long *    
120 {                                                 
121         elf_set_personality(&exec_params->hdr)    
122                                                   
123         exec_params->load_addr = 0x8000;          
124         interp_params->load_addr = ELF_ET_DYN_    
125         *start_stack = TASK_SIZE - SZ_16M;        
126                                                   
127         if ((exec_params->flags & ELF_FDPIC_FL    
128                 exec_params->flags &= ~ELF_FDP    
129                 exec_params->flags |= ELF_FDPI    
130         }                                         
131 }                                                 
132                                                   
133 #endif                                            
134                                                   

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php