Linux Audio

Check our new training course

Loading...
v4.10.11
 
  1/*
  2 * 32-bit compatibility support for ELF format executables and core dumps.
  3 *
  4 * Copyright (C) 2007 Red Hat, Inc.  All rights reserved.
  5 *
  6 * This copyrighted material is made available to anyone wishing to use,
  7 * modify, copy, or redistribute it subject to the terms and conditions
  8 * of the GNU General Public License v.2.
  9 *
 10 * Red Hat Author: Roland McGrath.
 11 *
 12 * This file is used in a 64-bit kernel that wants to support 32-bit ELF.
 13 * asm/elf.h is responsible for defining the compat_* and COMPAT_* macros
 14 * used below, with definitions appropriate for 32-bit ABI compatibility.
 15 *
 16 * We use macros to rename the ABI types and machine-dependent
 17 * functions used in binfmt_elf.c to compat versions.
 18 */
 19
 20#include <linux/elfcore-compat.h>
 21#include <linux/time.h>
 22
 23/*
 24 * Rename the basic ELF layout types to refer to the 32-bit class of files.
 25 */
 26#undef	ELF_CLASS
 27#define ELF_CLASS	ELFCLASS32
 28
 29#undef	elfhdr
 30#undef	elf_phdr
 31#undef	elf_shdr
 32#undef	elf_note
 33#undef	elf_addr_t
 34#define elfhdr		elf32_hdr
 35#define elf_phdr	elf32_phdr
 36#define elf_shdr	elf32_shdr
 37#define elf_note	elf32_note
 38#define elf_addr_t	Elf32_Addr
 39
 40/*
 41 * Some data types as stored in coredump.
 42 */
 43#define user_long_t		compat_long_t
 44#define user_siginfo_t		compat_siginfo_t
 45#define copy_siginfo_to_user	copy_siginfo_to_user32
 46
 47/*
 48 * The machine-dependent core note format types are defined in elfcore-compat.h,
 49 * which requires asm/elf.h to define compat_elf_gregset_t et al.
 50 */
 51#define elf_prstatus	compat_elf_prstatus
 52#define elf_prpsinfo	compat_elf_prpsinfo
 53
 54/*
 55 * Compat version of cputime_to_compat_timeval, perhaps this
 56 * should be an inline in <linux/compat.h>.
 57 */
 58static void cputime_to_compat_timeval(const cputime_t cputime,
 59				      struct compat_timeval *value)
 60{
 61	struct timeval tv;
 62	cputime_to_timeval(cputime, &tv);
 63	value->tv_sec = tv.tv_sec;
 64	value->tv_usec = tv.tv_usec;
 65}
 66
 67#undef cputime_to_timeval
 68#define cputime_to_timeval cputime_to_compat_timeval
 69
 70
 71/*
 72 * To use this file, asm/elf.h must define compat_elf_check_arch.
 73 * The other following macros can be defined if the compat versions
 74 * differ from the native ones, or omitted when they match.
 75 */
 76
 77#undef	ELF_ARCH
 78#undef	elf_check_arch
 79#define	elf_check_arch	compat_elf_check_arch
 80
 81#ifdef	COMPAT_ELF_PLATFORM
 82#undef	ELF_PLATFORM
 83#define	ELF_PLATFORM		COMPAT_ELF_PLATFORM
 84#endif
 85
 86#ifdef	COMPAT_ELF_HWCAP
 87#undef	ELF_HWCAP
 88#define	ELF_HWCAP		COMPAT_ELF_HWCAP
 89#endif
 90
 91#ifdef	COMPAT_ELF_HWCAP2
 92#undef	ELF_HWCAP2
 93#define	ELF_HWCAP2		COMPAT_ELF_HWCAP2
 94#endif
 95
 96#ifdef	COMPAT_ARCH_DLINFO
 97#undef	ARCH_DLINFO
 98#define	ARCH_DLINFO		COMPAT_ARCH_DLINFO
 99#endif
100
101#ifdef	COMPAT_ELF_ET_DYN_BASE
102#undef	ELF_ET_DYN_BASE
103#define	ELF_ET_DYN_BASE		COMPAT_ELF_ET_DYN_BASE
104#endif
105
106#ifdef COMPAT_ELF_EXEC_PAGESIZE
107#undef	ELF_EXEC_PAGESIZE
108#define	ELF_EXEC_PAGESIZE	COMPAT_ELF_EXEC_PAGESIZE
109#endif
110
111#ifdef	COMPAT_ELF_PLAT_INIT
112#undef	ELF_PLAT_INIT
113#define	ELF_PLAT_INIT		COMPAT_ELF_PLAT_INIT
114#endif
115
116#ifdef	COMPAT_SET_PERSONALITY
117#undef	SET_PERSONALITY
118#define	SET_PERSONALITY		COMPAT_SET_PERSONALITY
119#endif
120
121#ifdef	compat_start_thread
122#undef	start_thread
123#define	start_thread		compat_start_thread
124#endif
125
126#ifdef	compat_arch_setup_additional_pages
127#undef	ARCH_HAS_SETUP_ADDITIONAL_PAGES
128#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
129#undef	arch_setup_additional_pages
130#define	arch_setup_additional_pages compat_arch_setup_additional_pages
131#endif
132
133/*
134 * Rename a few of the symbols that binfmt_elf.c will define.
135 * These are all local so the names don't really matter, but it
136 * might make some debugging less confusing not to duplicate them.
137 */
138#define elf_format		compat_elf_format
139#define init_elf_binfmt		init_compat_elf_binfmt
140#define exit_elf_binfmt		exit_compat_elf_binfmt
141
142/*
143 * We share all the actual code with the native (64-bit) version.
144 */
145#include "binfmt_elf.c"
v5.4
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * 32-bit compatibility support for ELF format executables and core dumps.
  4 *
  5 * Copyright (C) 2007 Red Hat, Inc.  All rights reserved.
  6 *
 
 
 
 
  7 * Red Hat Author: Roland McGrath.
  8 *
  9 * This file is used in a 64-bit kernel that wants to support 32-bit ELF.
 10 * asm/elf.h is responsible for defining the compat_* and COMPAT_* macros
 11 * used below, with definitions appropriate for 32-bit ABI compatibility.
 12 *
 13 * We use macros to rename the ABI types and machine-dependent
 14 * functions used in binfmt_elf.c to compat versions.
 15 */
 16
 17#include <linux/elfcore-compat.h>
 18#include <linux/time.h>
 19
 20/*
 21 * Rename the basic ELF layout types to refer to the 32-bit class of files.
 22 */
 23#undef	ELF_CLASS
 24#define ELF_CLASS	ELFCLASS32
 25
 26#undef	elfhdr
 27#undef	elf_phdr
 28#undef	elf_shdr
 29#undef	elf_note
 30#undef	elf_addr_t
 31#define elfhdr		elf32_hdr
 32#define elf_phdr	elf32_phdr
 33#define elf_shdr	elf32_shdr
 34#define elf_note	elf32_note
 35#define elf_addr_t	Elf32_Addr
 36
 37/*
 38 * Some data types as stored in coredump.
 39 */
 40#define user_long_t		compat_long_t
 41#define user_siginfo_t		compat_siginfo_t
 42#define copy_siginfo_to_user	copy_siginfo_to_user32
 43
 44/*
 45 * The machine-dependent core note format types are defined in elfcore-compat.h,
 46 * which requires asm/elf.h to define compat_elf_gregset_t et al.
 47 */
 48#define elf_prstatus	compat_elf_prstatus
 49#define elf_prpsinfo	compat_elf_prpsinfo
 50
 51#undef ns_to_timeval
 52#define ns_to_timeval ns_to_old_timeval32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 53
 54/*
 55 * To use this file, asm/elf.h must define compat_elf_check_arch.
 56 * The other following macros can be defined if the compat versions
 57 * differ from the native ones, or omitted when they match.
 58 */
 59
 60#undef	ELF_ARCH
 61#undef	elf_check_arch
 62#define	elf_check_arch	compat_elf_check_arch
 63
 64#ifdef	COMPAT_ELF_PLATFORM
 65#undef	ELF_PLATFORM
 66#define	ELF_PLATFORM		COMPAT_ELF_PLATFORM
 67#endif
 68
 69#ifdef	COMPAT_ELF_HWCAP
 70#undef	ELF_HWCAP
 71#define	ELF_HWCAP		COMPAT_ELF_HWCAP
 72#endif
 73
 74#ifdef	COMPAT_ELF_HWCAP2
 75#undef	ELF_HWCAP2
 76#define	ELF_HWCAP2		COMPAT_ELF_HWCAP2
 77#endif
 78
 79#ifdef	COMPAT_ARCH_DLINFO
 80#undef	ARCH_DLINFO
 81#define	ARCH_DLINFO		COMPAT_ARCH_DLINFO
 82#endif
 83
 84#ifdef	COMPAT_ELF_ET_DYN_BASE
 85#undef	ELF_ET_DYN_BASE
 86#define	ELF_ET_DYN_BASE		COMPAT_ELF_ET_DYN_BASE
 87#endif
 88
 89#ifdef COMPAT_ELF_EXEC_PAGESIZE
 90#undef	ELF_EXEC_PAGESIZE
 91#define	ELF_EXEC_PAGESIZE	COMPAT_ELF_EXEC_PAGESIZE
 92#endif
 93
 94#ifdef	COMPAT_ELF_PLAT_INIT
 95#undef	ELF_PLAT_INIT
 96#define	ELF_PLAT_INIT		COMPAT_ELF_PLAT_INIT
 97#endif
 98
 99#ifdef	COMPAT_SET_PERSONALITY
100#undef	SET_PERSONALITY
101#define	SET_PERSONALITY		COMPAT_SET_PERSONALITY
102#endif
103
104#ifdef	compat_start_thread
105#undef	start_thread
106#define	start_thread		compat_start_thread
107#endif
108
109#ifdef	compat_arch_setup_additional_pages
110#undef	ARCH_HAS_SETUP_ADDITIONAL_PAGES
111#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
112#undef	arch_setup_additional_pages
113#define	arch_setup_additional_pages compat_arch_setup_additional_pages
114#endif
115
116/*
117 * Rename a few of the symbols that binfmt_elf.c will define.
118 * These are all local so the names don't really matter, but it
119 * might make some debugging less confusing not to duplicate them.
120 */
121#define elf_format		compat_elf_format
122#define init_elf_binfmt		init_compat_elf_binfmt
123#define exit_elf_binfmt		exit_compat_elf_binfmt
124
125/*
126 * We share all the actual code with the native (64-bit) version.
127 */
128#include "binfmt_elf.c"