linux/include/uapi/linux/elf.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_LINUX_ELF_H
#define _UAPI_LINUX_ELF_H

#include <linux/types.h>
#include <linux/elf-em.h>

/* 32-bit ELF base types. */
Elf32_Addr;
Elf32_Half;
Elf32_Off;
Elf32_Sword;
Elf32_Word;

/* 64-bit ELF base types. */
Elf64_Addr;
Elf64_Half;
Elf64_SHalf;
Elf64_Off;
Elf64_Sword;
Elf64_Word;
Elf64_Xword;
Elf64_Sxword;

/* These constants are for the segment types stored in the image headers */
#define PT_NULL
#define PT_LOAD
#define PT_DYNAMIC
#define PT_INTERP
#define PT_NOTE
#define PT_SHLIB
#define PT_PHDR
#define PT_TLS
#define PT_LOOS
#define PT_HIOS
#define PT_LOPROC
#define PT_HIPROC
#define PT_GNU_EH_FRAME
#define PT_GNU_STACK
#define PT_GNU_RELRO
#define PT_GNU_PROPERTY


/* ARM MTE memory tag segment type */
#define PT_AARCH64_MEMTAG_MTE

/*
 * Extended Numbering
 *
 * If the real number of program header table entries is larger than
 * or equal to PN_XNUM(0xffff), it is set to sh_info field of the
 * section header at index 0, and PN_XNUM is set to e_phnum
 * field. Otherwise, the section header at index 0 is zero
 * initialized, if it exists.
 *
 * Specifications are available in:
 *
 * - Oracle: Linker and Libraries.
 *   Part No: 817–1984–19, August 2011.
 *   https://docs.oracle.com/cd/E18752_01/pdf/817-1984.pdf
 *
 * - System V ABI AMD64 Architecture Processor Supplement
 *   Draft Version 0.99.4,
 *   January 13, 2010.
 *   http://www.cs.washington.edu/education/courses/cse351/12wi/supp-docs/abi.pdf
 */
#define PN_XNUM

/* These constants define the different elf file types */
#define ET_NONE
#define ET_REL
#define ET_EXEC
#define ET_DYN
#define ET_CORE
#define ET_LOPROC
#define ET_HIPROC

/* This is the info that is needed to parse the dynamic section of the file */
#define DT_NULL
#define DT_NEEDED
#define DT_PLTRELSZ
#define DT_PLTGOT
#define DT_HASH
#define DT_STRTAB
#define DT_SYMTAB
#define DT_RELA
#define DT_RELASZ
#define DT_RELAENT
#define DT_STRSZ
#define DT_SYMENT
#define DT_INIT
#define DT_FINI
#define DT_SONAME
#define DT_RPATH
#define DT_SYMBOLIC
#define DT_REL
#define DT_RELSZ
#define DT_RELENT
#define DT_PLTREL
#define DT_DEBUG
#define DT_TEXTREL
#define DT_JMPREL
#define DT_ENCODING
#define OLD_DT_LOOS
#define DT_LOOS
#define DT_HIOS
#define DT_VALRNGLO
#define DT_VALRNGHI
#define DT_ADDRRNGLO
#define DT_ADDRRNGHI
#define DT_VERSYM
#define DT_RELACOUNT
#define DT_RELCOUNT
#define DT_FLAGS_1
#define DT_VERDEF
#define DT_VERDEFNUM
#define DT_VERNEED
#define DT_VERNEEDNUM
#define OLD_DT_HIOS
#define DT_LOPROC
#define DT_HIPROC

/* This info is needed when parsing the symbol table */
#define STB_LOCAL
#define STB_GLOBAL
#define STB_WEAK

#define STT_NOTYPE
#define STT_OBJECT
#define STT_FUNC
#define STT_SECTION
#define STT_FILE
#define STT_COMMON
#define STT_TLS

#define ELF_ST_BIND(x)
#define ELF_ST_TYPE(x)
#define ELF32_ST_BIND(x)
#define ELF32_ST_TYPE(x)
#define ELF64_ST_BIND(x)
#define ELF64_ST_TYPE(x)

Elf32_Dyn;

Elf64_Dyn;

/* The following are used with relocations */
#define ELF32_R_SYM(x)
#define ELF32_R_TYPE(x)

#define ELF64_R_SYM(i)
#define ELF64_R_TYPE(i)

Elf32_Rel;

Elf64_Rel;

Elf32_Rela;

Elf64_Rela;

Elf32_Sym;

Elf64_Sym;


#define EI_NIDENT

Elf32_Ehdr;

Elf64_Ehdr;

/* These constants define the permissions on sections in the program
   header, p_flags. */
#define PF_R
#define PF_W
#define PF_X

Elf32_Phdr;

Elf64_Phdr;

/* sh_type */
#define SHT_NULL
#define SHT_PROGBITS
#define SHT_SYMTAB
#define SHT_STRTAB
#define SHT_RELA
#define SHT_HASH
#define SHT_DYNAMIC
#define SHT_NOTE
#define SHT_NOBITS
#define SHT_REL
#define SHT_SHLIB
#define SHT_DYNSYM
#define SHT_NUM
#define SHT_LOPROC
#define SHT_HIPROC
#define SHT_LOUSER
#define SHT_HIUSER

/* sh_flags */
#define SHF_WRITE
#define SHF_ALLOC
#define SHF_EXECINSTR
#define SHF_RELA_LIVEPATCH
#define SHF_RO_AFTER_INIT
#define SHF_MASKPROC

/* special section indexes */
#define SHN_UNDEF
#define SHN_LORESERVE
#define SHN_LOPROC
#define SHN_HIPROC
#define SHN_LIVEPATCH
#define SHN_ABS
#define SHN_COMMON
#define SHN_HIRESERVE
 
Elf32_Shdr;

Elf64_Shdr;

#define EI_MAG0
#define EI_MAG1
#define EI_MAG2
#define EI_MAG3
#define EI_CLASS
#define EI_DATA
#define EI_VERSION
#define EI_OSABI
#define EI_PAD

#define ELFMAG0
#define ELFMAG1
#define ELFMAG2
#define ELFMAG3
#define ELFMAG
#define SELFMAG

#define ELFCLASSNONE
#define ELFCLASS32
#define ELFCLASS64
#define ELFCLASSNUM

#define ELFDATANONE
#define ELFDATA2LSB
#define ELFDATA2MSB

#define EV_NONE
#define EV_CURRENT
#define EV_NUM

#define ELFOSABI_NONE
#define ELFOSABI_LINUX

#ifndef ELF_OSABI
#define ELF_OSABI
#endif

/*
 * Notes used in ET_CORE. Architectures export some of the arch register sets
 * using the corresponding note types via the PTRACE_GETREGSET and
 * PTRACE_SETREGSET requests.
 * The note name for these types is "LINUX", except NT_PRFPREG that is named
 * "CORE".
 */
#define NT_PRSTATUS
#define NT_PRFPREG
#define NT_PRPSINFO
#define NT_TASKSTRUCT
#define NT_AUXV
/*
 * Note to userspace developers: size of NT_SIGINFO note may increase
 * in the future to accomodate more fields, don't assume it is fixed!
 */
#define NT_SIGINFO
#define NT_FILE
#define NT_PRXFPREG
#define NT_PPC_VMX
#define NT_PPC_SPE
#define NT_PPC_VSX
#define NT_PPC_TAR
#define NT_PPC_PPR
#define NT_PPC_DSCR
#define NT_PPC_EBB
#define NT_PPC_PMU
#define NT_PPC_TM_CGPR
#define NT_PPC_TM_CFPR
#define NT_PPC_TM_CVMX
#define NT_PPC_TM_CVSX
#define NT_PPC_TM_SPR
#define NT_PPC_TM_CTAR
#define NT_PPC_TM_CPPR
#define NT_PPC_TM_CDSCR
#define NT_PPC_PKEY
#define NT_PPC_DEXCR
#define NT_PPC_HASHKEYR
#define NT_386_TLS
#define NT_386_IOPERM
#define NT_X86_XSTATE
/* Old binutils treats 0x203 as a CET state */
#define NT_X86_SHSTK
#define NT_S390_HIGH_GPRS
#define NT_S390_TIMER
#define NT_S390_TODCMP
#define NT_S390_TODPREG
#define NT_S390_CTRS
#define NT_S390_PREFIX
#define NT_S390_LAST_BREAK
#define NT_S390_SYSTEM_CALL
#define NT_S390_TDB
#define NT_S390_VXRS_LOW
#define NT_S390_VXRS_HIGH
#define NT_S390_GS_CB
#define NT_S390_GS_BC
#define NT_S390_RI_CB
#define NT_S390_PV_CPU_DATA
#define NT_ARM_VFP
#define NT_ARM_TLS
#define NT_ARM_HW_BREAK
#define NT_ARM_HW_WATCH
#define NT_ARM_SYSTEM_CALL
#define NT_ARM_SVE
#define NT_ARM_PAC_MASK
#define NT_ARM_PACA_KEYS
#define NT_ARM_PACG_KEYS
#define NT_ARM_TAGGED_ADDR_CTRL
#define NT_ARM_PAC_ENABLED_KEYS
#define NT_ARM_SSVE
#define NT_ARM_ZA
#define NT_ARM_ZT
#define NT_ARM_FPMR
#define NT_ARC_V2
#define NT_VMCOREDD
#define NT_MIPS_DSP
#define NT_MIPS_FP_MODE
#define NT_MIPS_MSA
#define NT_RISCV_CSR
#define NT_RISCV_VECTOR
#define NT_LOONGARCH_CPUCFG
#define NT_LOONGARCH_CSR
#define NT_LOONGARCH_LSX
#define NT_LOONGARCH_LASX
#define NT_LOONGARCH_LBT
#define NT_LOONGARCH_HW_BREAK
#define NT_LOONGARCH_HW_WATCH

/* Note types with note name "GNU" */
#define NT_GNU_PROPERTY_TYPE_0

/* Note header in a PT_NOTE section */
Elf32_Nhdr;

/* Note header in a PT_NOTE section */
Elf64_Nhdr;

/* .note.gnu.property types for EM_AARCH64: */
#define GNU_PROPERTY_AARCH64_FEATURE_1_AND

/* Bits for GNU_PROPERTY_AARCH64_FEATURE_1_BTI */
#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI

#endif /* _UAPI_LINUX_ELF_H */