Back to home page

LXR

 
 

    


0001 /*
0002  * 32-bit compatibility support for ELF format executables and core dumps.
0003  *
0004  * Copyright (C) 2007 Red Hat, Inc.  All rights reserved.
0005  *
0006  * This copyrighted material is made available to anyone wishing to use,
0007  * modify, copy, or redistribute it subject to the terms and conditions
0008  * of the GNU General Public License v.2.
0009  *
0010  * Red Hat Author: Roland McGrath.
0011  *
0012  * This file is used in a 64-bit kernel that wants to support 32-bit ELF.
0013  * asm/elf.h is responsible for defining the compat_* and COMPAT_* macros
0014  * used below, with definitions appropriate for 32-bit ABI compatibility.
0015  *
0016  * We use macros to rename the ABI types and machine-dependent
0017  * functions used in binfmt_elf.c to compat versions.
0018  */
0019 
0020 #include <linux/elfcore-compat.h>
0021 #include <linux/time.h>
0022 
0023 /*
0024  * Rename the basic ELF layout types to refer to the 32-bit class of files.
0025  */
0026 #undef  ELF_CLASS
0027 #define ELF_CLASS   ELFCLASS32
0028 
0029 #undef  elfhdr
0030 #undef  elf_phdr
0031 #undef  elf_shdr
0032 #undef  elf_note
0033 #undef  elf_addr_t
0034 #define elfhdr      elf32_hdr
0035 #define elf_phdr    elf32_phdr
0036 #define elf_shdr    elf32_shdr
0037 #define elf_note    elf32_note
0038 #define elf_addr_t  Elf32_Addr
0039 
0040 /*
0041  * Some data types as stored in coredump.
0042  */
0043 #define user_long_t     compat_long_t
0044 #define user_siginfo_t      compat_siginfo_t
0045 #define copy_siginfo_to_user    copy_siginfo_to_user32
0046 
0047 /*
0048  * The machine-dependent core note format types are defined in elfcore-compat.h,
0049  * which requires asm/elf.h to define compat_elf_gregset_t et al.
0050  */
0051 #define elf_prstatus    compat_elf_prstatus
0052 #define elf_prpsinfo    compat_elf_prpsinfo
0053 
0054 /*
0055  * Compat version of cputime_to_compat_timeval, perhaps this
0056  * should be an inline in <linux/compat.h>.
0057  */
0058 static void cputime_to_compat_timeval(const cputime_t cputime,
0059                       struct compat_timeval *value)
0060 {
0061     struct timeval tv;
0062     cputime_to_timeval(cputime, &tv);
0063     value->tv_sec = tv.tv_sec;
0064     value->tv_usec = tv.tv_usec;
0065 }
0066 
0067 #undef cputime_to_timeval
0068 #define cputime_to_timeval cputime_to_compat_timeval
0069 
0070 
0071 /*
0072  * To use this file, asm/elf.h must define compat_elf_check_arch.
0073  * The other following macros can be defined if the compat versions
0074  * differ from the native ones, or omitted when they match.
0075  */
0076 
0077 #undef  ELF_ARCH
0078 #undef  elf_check_arch
0079 #define elf_check_arch  compat_elf_check_arch
0080 
0081 #ifdef  COMPAT_ELF_PLATFORM
0082 #undef  ELF_PLATFORM
0083 #define ELF_PLATFORM        COMPAT_ELF_PLATFORM
0084 #endif
0085 
0086 #ifdef  COMPAT_ELF_HWCAP
0087 #undef  ELF_HWCAP
0088 #define ELF_HWCAP       COMPAT_ELF_HWCAP
0089 #endif
0090 
0091 #ifdef  COMPAT_ELF_HWCAP2
0092 #undef  ELF_HWCAP2
0093 #define ELF_HWCAP2      COMPAT_ELF_HWCAP2
0094 #endif
0095 
0096 #ifdef  COMPAT_ARCH_DLINFO
0097 #undef  ARCH_DLINFO
0098 #define ARCH_DLINFO     COMPAT_ARCH_DLINFO
0099 #endif
0100 
0101 #ifdef  COMPAT_ELF_ET_DYN_BASE
0102 #undef  ELF_ET_DYN_BASE
0103 #define ELF_ET_DYN_BASE     COMPAT_ELF_ET_DYN_BASE
0104 #endif
0105 
0106 #ifdef COMPAT_ELF_EXEC_PAGESIZE
0107 #undef  ELF_EXEC_PAGESIZE
0108 #define ELF_EXEC_PAGESIZE   COMPAT_ELF_EXEC_PAGESIZE
0109 #endif
0110 
0111 #ifdef  COMPAT_ELF_PLAT_INIT
0112 #undef  ELF_PLAT_INIT
0113 #define ELF_PLAT_INIT       COMPAT_ELF_PLAT_INIT
0114 #endif
0115 
0116 #ifdef  COMPAT_SET_PERSONALITY
0117 #undef  SET_PERSONALITY
0118 #define SET_PERSONALITY     COMPAT_SET_PERSONALITY
0119 #endif
0120 
0121 #ifdef  compat_start_thread
0122 #undef  start_thread
0123 #define start_thread        compat_start_thread
0124 #endif
0125 
0126 #ifdef  compat_arch_setup_additional_pages
0127 #undef  ARCH_HAS_SETUP_ADDITIONAL_PAGES
0128 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
0129 #undef  arch_setup_additional_pages
0130 #define arch_setup_additional_pages compat_arch_setup_additional_pages
0131 #endif
0132 
0133 /*
0134  * Rename a few of the symbols that binfmt_elf.c will define.
0135  * These are all local so the names don't really matter, but it
0136  * might make some debugging less confusing not to duplicate them.
0137  */
0138 #define elf_format      compat_elf_format
0139 #define init_elf_binfmt     init_compat_elf_binfmt
0140 #define exit_elf_binfmt     exit_compat_elf_binfmt
0141 
0142 /*
0143  * We share all the actual code with the native (64-bit) version.
0144  */
0145 #include "binfmt_elf.c"