1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #ifndef _LINUX_ELF_FDPIC_H
9 #define _LINUX_ELF_FDPIC_H
11 #include <uapi/linux/elf-fdpic.h>
13 #if ELF_CLASS == ELFCLASS32
14 #define Elf_Sword Elf32_Sword
15 #define elf_fdpic_loadseg elf32_fdpic_loadseg
16 #define elf_fdpic_loadmap elf32_fdpic_loadmap
17 #define ELF_FDPIC_LOADMAP_VERSION ELF32_FDPIC_LOADMAP_VERSION
19 #define Elf_Sword Elf64_Sxword
20 #define elf_fdpic_loadmap elf64_fdpic_loadmap
21 #define elf_fdpic_loadseg elf64_fdpic_loadseg
22 #define ELF_FDPIC_LOADMAP_VERSION ELF64_FDPIC_LOADMAP_VERSION
26 * binfmt binary parameters structure
28 struct elf_fdpic_params {
29 struct elfhdr hdr; /* ref copy of ELF header */
30 struct elf_phdr *phdrs; /* ref copy of PT_PHDR table */
31 struct elf_fdpic_loadmap *loadmap; /* loadmap to be passed to userspace */
32 unsigned long elfhdr_addr; /* mapped ELF header user address */
33 unsigned long ph_addr; /* mapped PT_PHDR user address */
34 unsigned long map_addr; /* mapped loadmap user address */
35 unsigned long entry_addr; /* mapped entry user address */
36 unsigned long stack_size; /* stack size requested (PT_GNU_STACK) */
37 unsigned long dynamic_addr; /* mapped PT_DYNAMIC user address */
38 unsigned long load_addr; /* user address at which to map binary */
40 #define ELF_FDPIC_FLAG_ARRANGEMENT 0x0000000f /* PT_LOAD arrangement flags */
41 #define ELF_FDPIC_FLAG_INDEPENDENT 0x00000000 /* PT_LOADs can be put anywhere */
42 #define ELF_FDPIC_FLAG_HONOURVADDR 0x00000001 /* PT_LOAD.vaddr must be honoured */
43 #define ELF_FDPIC_FLAG_CONSTDISP 0x00000002 /* PT_LOADs require constant
45 #define ELF_FDPIC_FLAG_CONTIGUOUS 0x00000003 /* PT_LOADs should be contiguous */
46 #define ELF_FDPIC_FLAG_EXEC_STACK 0x00000010 /* T if stack to be executable */
47 #define ELF_FDPIC_FLAG_NOEXEC_STACK 0x00000020 /* T if stack not to be executable */
48 #define ELF_FDPIC_FLAG_EXECUTABLE 0x00000040 /* T if this object is the executable */
49 #define ELF_FDPIC_FLAG_PRESENT 0x80000000 /* T if this object is present */
53 extern void elf_fdpic_arch_lay_out_mm(struct elf_fdpic_params *exec_params,
54 struct elf_fdpic_params *interp_params,
55 unsigned long *start_stack,
56 unsigned long *start_brk);
59 #endif /* _LINUX_ELF_FDPIC_H */