ELF: UAPI and Kconfig additions for ELF program properties
[linux-2.6-microblaze.git] / include / linux / elf.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_ELF_H
3 #define _LINUX_ELF_H
4
5 #include <linux/types.h>
6 #include <asm/elf.h>
7 #include <uapi/linux/elf.h>
8
9 #ifndef elf_read_implies_exec
10   /* Executables for which elf_read_implies_exec() returns TRUE will
11      have the READ_IMPLIES_EXEC personality flag set automatically.
12      Override in asm/elf.h as needed.  */
13 # define elf_read_implies_exec(ex, have_pt_gnu_stack)   0
14 #endif
15 #ifndef SET_PERSONALITY
16 #define SET_PERSONALITY(ex) \
17         set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
18 #endif
19
20 #ifndef SET_PERSONALITY2
21 #define SET_PERSONALITY2(ex, state) \
22         SET_PERSONALITY(ex)
23 #endif
24
25 #if ELF_CLASS == ELFCLASS32
26
27 extern Elf32_Dyn _DYNAMIC [];
28 #define elfhdr          elf32_hdr
29 #define elf_phdr        elf32_phdr
30 #define elf_shdr        elf32_shdr
31 #define elf_note        elf32_note
32 #define elf_addr_t      Elf32_Off
33 #define Elf_Half        Elf32_Half
34 #define Elf_Word        Elf32_Word
35
36 #else
37
38 extern Elf64_Dyn _DYNAMIC [];
39 #define elfhdr          elf64_hdr
40 #define elf_phdr        elf64_phdr
41 #define elf_shdr        elf64_shdr
42 #define elf_note        elf64_note
43 #define elf_addr_t      Elf64_Off
44 #define Elf_Half        Elf64_Half
45 #define Elf_Word        Elf64_Word
46
47 #endif
48
49 /* Optional callbacks to write extra ELF notes. */
50 struct file;
51 struct coredump_params;
52
53 #ifndef ARCH_HAVE_EXTRA_ELF_NOTES
54 static inline int elf_coredump_extra_notes_size(void) { return 0; }
55 static inline int elf_coredump_extra_notes_write(struct coredump_params *cprm) { return 0; }
56 #else
57 extern int elf_coredump_extra_notes_size(void);
58 extern int elf_coredump_extra_notes_write(struct coredump_params *cprm);
59 #endif
60
61 /*
62  * NT_GNU_PROPERTY_TYPE_0 header:
63  * Keep this internal until/unless there is an agreed UAPI definition.
64  * pr_type values (GNU_PROPERTY_*) are public and defined in the UAPI header.
65  */
66 struct gnu_property {
67         u32 pr_type;
68         u32 pr_datasz;
69 };
70
71 #endif /* _LINUX_ELF_H */