Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_ELF_H
0003 #define _LINUX_ELF_H
0004 
0005 #include <linux/types.h>
0006 #include <asm/elf.h>
0007 #include <uapi/linux/elf.h>
0008 
0009 #ifndef elf_read_implies_exec
0010   /* Executables for which elf_read_implies_exec() returns TRUE will
0011      have the READ_IMPLIES_EXEC personality flag set automatically.
0012      Override in asm/elf.h as needed.  */
0013 # define elf_read_implies_exec(ex, have_pt_gnu_stack)   0
0014 #endif
0015 #ifndef SET_PERSONALITY
0016 #define SET_PERSONALITY(ex) \
0017     set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
0018 #endif
0019 
0020 #ifndef SET_PERSONALITY2
0021 #define SET_PERSONALITY2(ex, state) \
0022     SET_PERSONALITY(ex)
0023 #endif
0024 
0025 #ifndef START_THREAD
0026 #define START_THREAD(elf_ex, regs, elf_entry, start_stack)  \
0027     start_thread(regs, elf_entry, start_stack)
0028 #endif
0029 
0030 #if defined(ARCH_HAS_SETUP_ADDITIONAL_PAGES) && !defined(ARCH_SETUP_ADDITIONAL_PAGES)
0031 #define ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \
0032     arch_setup_additional_pages(bprm, interpreter)
0033 #endif
0034 
0035 #define ELF32_GNU_PROPERTY_ALIGN    4
0036 #define ELF64_GNU_PROPERTY_ALIGN    8
0037 
0038 #if ELF_CLASS == ELFCLASS32
0039 
0040 extern Elf32_Dyn _DYNAMIC [];
0041 #define elfhdr      elf32_hdr
0042 #define elf_phdr    elf32_phdr
0043 #define elf_shdr    elf32_shdr
0044 #define elf_note    elf32_note
0045 #define elf_addr_t  Elf32_Off
0046 #define Elf_Half    Elf32_Half
0047 #define Elf_Word    Elf32_Word
0048 #define ELF_GNU_PROPERTY_ALIGN  ELF32_GNU_PROPERTY_ALIGN
0049 
0050 #else
0051 
0052 extern Elf64_Dyn _DYNAMIC [];
0053 #define elfhdr      elf64_hdr
0054 #define elf_phdr    elf64_phdr
0055 #define elf_shdr    elf64_shdr
0056 #define elf_note    elf64_note
0057 #define elf_addr_t  Elf64_Off
0058 #define Elf_Half    Elf64_Half
0059 #define Elf_Word    Elf64_Word
0060 #define ELF_GNU_PROPERTY_ALIGN  ELF64_GNU_PROPERTY_ALIGN
0061 
0062 #endif
0063 
0064 /* Optional callbacks to write extra ELF notes. */
0065 struct file;
0066 struct coredump_params;
0067 
0068 #ifndef ARCH_HAVE_EXTRA_ELF_NOTES
0069 static inline int elf_coredump_extra_notes_size(void) { return 0; }
0070 static inline int elf_coredump_extra_notes_write(struct coredump_params *cprm) { return 0; }
0071 #else
0072 extern int elf_coredump_extra_notes_size(void);
0073 extern int elf_coredump_extra_notes_write(struct coredump_params *cprm);
0074 #endif
0075 
0076 /*
0077  * NT_GNU_PROPERTY_TYPE_0 header:
0078  * Keep this internal until/unless there is an agreed UAPI definition.
0079  * pr_type values (GNU_PROPERTY_*) are public and defined in the UAPI header.
0080  */
0081 struct gnu_property {
0082     u32 pr_type;
0083     u32 pr_datasz;
0084 };
0085 
0086 struct arch_elf_state;
0087 
0088 #ifndef CONFIG_ARCH_USE_GNU_PROPERTY
0089 static inline int arch_parse_elf_property(u32 type, const void *data,
0090                       size_t datasz, bool compat,
0091                       struct arch_elf_state *arch)
0092 {
0093     return 0;
0094 }
0095 #else
0096 extern int arch_parse_elf_property(u32 type, const void *data, size_t datasz,
0097                    bool compat, struct arch_elf_state *arch);
0098 #endif
0099 
0100 #ifdef CONFIG_ARCH_HAVE_ELF_PROT
0101 int arch_elf_adjust_prot(int prot, const struct arch_elf_state *state,
0102              bool has_interp, bool is_interp);
0103 #else
0104 static inline int arch_elf_adjust_prot(int prot,
0105                        const struct arch_elf_state *state,
0106                        bool has_interp, bool is_interp)
0107 {
0108     return prot;
0109 }
0110 #endif
0111 
0112 #endif /* _LINUX_ELF_H */