LCOV - code coverage report
Current view: top level - arch/arm/kernel - elf.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 25 64.0 %
Date: 2014-04-16 Functions: 3 3 100.0 %
Branches: 11 28 39.3 %

           Branch data     Line data    Source code
       1                 :            : #include <linux/export.h>
       2                 :            : #include <linux/sched.h>
       3                 :            : #include <linux/personality.h>
       4                 :            : #include <linux/binfmts.h>
       5                 :            : #include <linux/elf.h>
       6                 :            : #include <asm/system_info.h>
       7                 :            : 
       8                 :          0 : int elf_check_arch(const struct elf32_hdr *x)
       9                 :            : {
      10                 :            :         unsigned int eflags;
      11                 :            : 
      12                 :            :         /* Make sure it's an ARM executable */
      13         [ +  + ]:      81728 :         if (x->e_machine != EM_ARM)
      14                 :            :                 return 0;
      15                 :            : 
      16                 :            :         /* Make sure the entry address is reasonable */
      17         [ +  - ]:      81726 :         if (x->e_entry & 1) {
      18            [ + ]:      81726 :                 if (!(elf_hwcap & HWCAP_THUMB))
      19                 :            :                         return 0;
      20         [ #  # ]:          0 :         } else if (x->e_entry & 3)
      21                 :            :                 return 0;
      22                 :            : 
      23                 :      81731 :         eflags = x->e_flags;
      24         [ -  + ]:     163459 :         if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN) {
      25                 :            :                 unsigned int flt_fmt;
      26                 :            : 
      27                 :            :                 /* APCS26 is only allowed if the CPU supports it */
      28 [ #  # ][ #  # ]:          0 :                 if ((eflags & EF_ARM_APCS_26) && !(elf_hwcap & HWCAP_26BIT))
      29                 :            :                         return 0;
      30                 :            : 
      31                 :          0 :                 flt_fmt = eflags & (EF_ARM_VFP_FLOAT | EF_ARM_SOFT_FLOAT);
      32                 :            : 
      33                 :            :                 /* VFP requires the supporting code */
      34 [ #  # ][ #  # ]:          0 :                 if (flt_fmt == EF_ARM_VFP_FLOAT && !(elf_hwcap & HWCAP_VFP))
      35                 :            :                         return 0;
      36                 :            :         }
      37                 :      81731 :         return 1;
      38                 :            : }
      39                 :            : EXPORT_SYMBOL(elf_check_arch);
      40                 :            : 
      41                 :          0 : void elf_set_personality(const struct elf32_hdr *x)
      42                 :            : {
      43                 :      27244 :         unsigned int eflags = x->e_flags;
      44                 :      27244 :         unsigned int personality = current->personality & ~PER_MASK;
      45                 :            : 
      46                 :            :         /*
      47                 :            :          * We only support Linux ELF executables, so always set the
      48                 :            :          * personality to LINUX.
      49                 :            :          */
      50                 :            :         personality |= PER_LINUX;
      51                 :            : 
      52                 :            :         /*
      53                 :            :          * APCS-26 is only valid for OABI executables
      54                 :            :          */
      55         [ -  + ]:      27244 :         if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN &&
      56                 :            :             (eflags & EF_ARM_APCS_26))
      57                 :          0 :                 personality &= ~ADDR_LIMIT_32BIT;
      58                 :            :         else
      59                 :      27244 :                 personality |= ADDR_LIMIT_32BIT;
      60                 :            : 
      61         [ +  + ]:      27244 :         set_personality(personality);
      62                 :            : 
      63                 :            :         /*
      64                 :            :          * Since the FPA coprocessor uses CP1 and CP2, and iWMMXt uses CP0
      65                 :            :          * and CP1, we only enable access to the iWMMXt coprocessor if the
      66                 :            :          * binary is EABI or softfloat (and thus, guaranteed not to use
      67                 :            :          * FPA instructions.)
      68                 :            :          */
      69 [ -  + ][ #  # ]:      27243 :         if (elf_hwcap & HWCAP_IWMMXT &&
      70                 :          0 :             eflags & (EF_ARM_EABI_MASK | EF_ARM_SOFT_FLOAT)) {
      71                 :            :                 set_thread_flag(TIF_USING_IWMMXT);
      72                 :            :         } else {
      73                 :            :                 clear_thread_flag(TIF_USING_IWMMXT);
      74                 :            :         }
      75                 :      27244 : }
      76                 :            : EXPORT_SYMBOL(elf_set_personality);
      77                 :            : 
      78                 :            : /*
      79                 :            :  * Set READ_IMPLIES_EXEC if:
      80                 :            :  *  - the binary requires an executable stack
      81                 :            :  *  - we're running on a CPU which doesn't support NX.
      82                 :            :  */
      83                 :          0 : int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack)
      84                 :            : {
      85            [ + ]:      27242 :         if (executable_stack != EXSTACK_DISABLE_X)
      86                 :            :                 return 1;
      87         [ +  - ]:      27246 :         if (cpu_architecture() < CPU_ARCH_ARMv6)
      88                 :            :                 return 1;
      89                 :      27244 :         return 0;
      90                 :            : }
      91                 :            : EXPORT_SYMBOL(arm_elf_read_implies_exec);

Generated by: LCOV version 1.9