blob: 20fa8d8ae31335744c4566eb8b6305997b44db8b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_ELF_H
2#define _LINUX_ELF_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/elf.h>
David Howells607ca462012-10-13 10:46:48 +01005#include <uapi/linux/elf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
David Howells267aed92011-12-12 13:54:36 +00007#ifndef elf_read_implies_exec
8 /* Executables for which elf_read_implies_exec() returns TRUE will
9 have the READ_IMPLIES_EXEC personality flag set automatically.
10 Override in asm/elf.h as needed. */
11# define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
12#endif
Al Viroe72837e2013-02-17 17:47:04 -050013#ifndef SET_PERSONALITY
14#define SET_PERSONALITY(ex) \
15 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
16#endif
David Howells267aed92011-12-12 13:54:36 +000017
Paul Burton774c1052014-09-11 08:30:16 +010018#ifndef SET_PERSONALITY2
19#define SET_PERSONALITY2(ex, state) \
20 SET_PERSONALITY(ex)
21#endif
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#if ELF_CLASS == ELFCLASS32
24
25extern Elf32_Dyn _DYNAMIC [];
26#define elfhdr elf32_hdr
27#define elf_phdr elf32_phdr
Daisuke HATAYAMA8d9032b2010-03-05 13:44:10 -080028#define elf_shdr elf32_shdr
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#define elf_note elf32_note
Magnus Damm386d9a72006-12-06 20:37:53 -080030#define elf_addr_t Elf32_Off
Daisuke HATAYAMA1fcccba2010-03-05 13:44:07 -080031#define Elf_Half Elf32_Half
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#else
34
35extern Elf64_Dyn _DYNAMIC [];
36#define elfhdr elf64_hdr
37#define elf_phdr elf64_phdr
Daisuke HATAYAMA8d9032b2010-03-05 13:44:10 -080038#define elf_shdr elf64_shdr
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define elf_note elf64_note
Magnus Damm386d9a72006-12-06 20:37:53 -080040#define elf_addr_t Elf64_Off
Daisuke HATAYAMA1fcccba2010-03-05 13:44:07 -080041#define Elf_Half Elf64_Half
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43#endif
44
Michael Ellermane5501492007-09-19 14:38:12 +100045/* Optional callbacks to write extra ELF notes. */
David Howells267aed92011-12-12 13:54:36 +000046struct file;
Al Virocdc3d562013-10-05 22:24:29 -040047struct coredump_params;
David Howells267aed92011-12-12 13:54:36 +000048
Dwayne Grant McConnellbf1ab972006-11-23 00:46:37 +010049#ifndef ARCH_HAVE_EXTRA_ELF_NOTES
Michael Ellermane5501492007-09-19 14:38:12 +100050static inline int elf_coredump_extra_notes_size(void) { return 0; }
Al Virocdc3d562013-10-05 22:24:29 -040051static inline int elf_coredump_extra_notes_write(struct coredump_params *cprm) { return 0; }
Michael Ellermane5501492007-09-19 14:38:12 +100052#else
53extern int elf_coredump_extra_notes_size(void);
Al Virocdc3d562013-10-05 22:24:29 -040054extern int elf_coredump_extra_notes_write(struct coredump_params *cprm);
Michael Ellermane5501492007-09-19 14:38:12 +100055#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#endif /* _LINUX_ELF_H */