18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci#ifndef _UAPI_LINUX_ELF_H 38c2ecf20Sopenharmony_ci#define _UAPI_LINUX_ELF_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/types.h> 68c2ecf20Sopenharmony_ci#include <linux/elf-em.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* 32-bit ELF base types. */ 98c2ecf20Sopenharmony_citypedef __u32 Elf32_Addr; 108c2ecf20Sopenharmony_citypedef __u16 Elf32_Half; 118c2ecf20Sopenharmony_citypedef __u32 Elf32_Off; 128c2ecf20Sopenharmony_citypedef __s32 Elf32_Sword; 138c2ecf20Sopenharmony_citypedef __u32 Elf32_Word; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 64-bit ELF base types. */ 168c2ecf20Sopenharmony_citypedef __u64 Elf64_Addr; 178c2ecf20Sopenharmony_citypedef __u16 Elf64_Half; 188c2ecf20Sopenharmony_citypedef __s16 Elf64_SHalf; 198c2ecf20Sopenharmony_citypedef __u64 Elf64_Off; 208c2ecf20Sopenharmony_citypedef __s32 Elf64_Sword; 218c2ecf20Sopenharmony_citypedef __u32 Elf64_Word; 228c2ecf20Sopenharmony_citypedef __u64 Elf64_Xword; 238c2ecf20Sopenharmony_citypedef __s64 Elf64_Sxword; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* These constants are for the segment types stored in the image headers */ 268c2ecf20Sopenharmony_ci#define PT_NULL 0 278c2ecf20Sopenharmony_ci#define PT_LOAD 1 288c2ecf20Sopenharmony_ci#define PT_DYNAMIC 2 298c2ecf20Sopenharmony_ci#define PT_INTERP 3 308c2ecf20Sopenharmony_ci#define PT_NOTE 4 318c2ecf20Sopenharmony_ci#define PT_SHLIB 5 328c2ecf20Sopenharmony_ci#define PT_PHDR 6 338c2ecf20Sopenharmony_ci#define PT_TLS 7 /* Thread local storage segment */ 348c2ecf20Sopenharmony_ci#define PT_LOOS 0x60000000 /* OS-specific */ 358c2ecf20Sopenharmony_ci#define PT_HIOS 0x6fffffff /* OS-specific */ 368c2ecf20Sopenharmony_ci#define PT_LOPROC 0x70000000 378c2ecf20Sopenharmony_ci#define PT_HIPROC 0x7fffffff 388c2ecf20Sopenharmony_ci#define PT_GNU_EH_FRAME 0x6474e550 398c2ecf20Sopenharmony_ci#define PT_GNU_PROPERTY 0x6474e553 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define PT_OHOS_RANDOMDATA 0x6788fc60 /* ohos-specific segment */ 428c2ecf20Sopenharmony_ci#define PT_OHOS_RANDOMDATA_SIZE_LIMIT 1024 * 128 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define PT_GNU_STACK (PT_LOOS + 0x474e551) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* 478c2ecf20Sopenharmony_ci * Extended Numbering 488c2ecf20Sopenharmony_ci * 498c2ecf20Sopenharmony_ci * If the real number of program header table entries is larger than 508c2ecf20Sopenharmony_ci * or equal to PN_XNUM(0xffff), it is set to sh_info field of the 518c2ecf20Sopenharmony_ci * section header at index 0, and PN_XNUM is set to e_phnum 528c2ecf20Sopenharmony_ci * field. Otherwise, the section header at index 0 is zero 538c2ecf20Sopenharmony_ci * initialized, if it exists. 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * Specifications are available in: 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * - Oracle: Linker and Libraries. 588c2ecf20Sopenharmony_ci * Part No: 817–1984–19, August 2011. 598c2ecf20Sopenharmony_ci * https://docs.oracle.com/cd/E18752_01/pdf/817-1984.pdf 608c2ecf20Sopenharmony_ci * 618c2ecf20Sopenharmony_ci * - System V ABI AMD64 Architecture Processor Supplement 628c2ecf20Sopenharmony_ci * Draft Version 0.99.4, 638c2ecf20Sopenharmony_ci * January 13, 2010. 648c2ecf20Sopenharmony_ci * http://www.cs.washington.edu/education/courses/cse351/12wi/supp-docs/abi.pdf 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_ci#define PN_XNUM 0xffff 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* These constants define the different elf file types */ 698c2ecf20Sopenharmony_ci#define ET_NONE 0 708c2ecf20Sopenharmony_ci#define ET_REL 1 718c2ecf20Sopenharmony_ci#define ET_EXEC 2 728c2ecf20Sopenharmony_ci#define ET_DYN 3 738c2ecf20Sopenharmony_ci#define ET_CORE 4 748c2ecf20Sopenharmony_ci#define ET_LOPROC 0xff00 758c2ecf20Sopenharmony_ci#define ET_HIPROC 0xffff 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* This is the info that is needed to parse the dynamic section of the file */ 788c2ecf20Sopenharmony_ci#define DT_NULL 0 798c2ecf20Sopenharmony_ci#define DT_NEEDED 1 808c2ecf20Sopenharmony_ci#define DT_PLTRELSZ 2 818c2ecf20Sopenharmony_ci#define DT_PLTGOT 3 828c2ecf20Sopenharmony_ci#define DT_HASH 4 838c2ecf20Sopenharmony_ci#define DT_STRTAB 5 848c2ecf20Sopenharmony_ci#define DT_SYMTAB 6 858c2ecf20Sopenharmony_ci#define DT_RELA 7 868c2ecf20Sopenharmony_ci#define DT_RELASZ 8 878c2ecf20Sopenharmony_ci#define DT_RELAENT 9 888c2ecf20Sopenharmony_ci#define DT_STRSZ 10 898c2ecf20Sopenharmony_ci#define DT_SYMENT 11 908c2ecf20Sopenharmony_ci#define DT_INIT 12 918c2ecf20Sopenharmony_ci#define DT_FINI 13 928c2ecf20Sopenharmony_ci#define DT_SONAME 14 938c2ecf20Sopenharmony_ci#define DT_RPATH 15 948c2ecf20Sopenharmony_ci#define DT_SYMBOLIC 16 958c2ecf20Sopenharmony_ci#define DT_REL 17 968c2ecf20Sopenharmony_ci#define DT_RELSZ 18 978c2ecf20Sopenharmony_ci#define DT_RELENT 19 988c2ecf20Sopenharmony_ci#define DT_PLTREL 20 998c2ecf20Sopenharmony_ci#define DT_DEBUG 21 1008c2ecf20Sopenharmony_ci#define DT_TEXTREL 22 1018c2ecf20Sopenharmony_ci#define DT_JMPREL 23 1028c2ecf20Sopenharmony_ci#define DT_ENCODING 32 1038c2ecf20Sopenharmony_ci#define OLD_DT_LOOS 0x60000000 1048c2ecf20Sopenharmony_ci#define DT_LOOS 0x6000000d 1058c2ecf20Sopenharmony_ci#define DT_HIOS 0x6ffff000 1068c2ecf20Sopenharmony_ci#define DT_VALRNGLO 0x6ffffd00 1078c2ecf20Sopenharmony_ci#define DT_VALRNGHI 0x6ffffdff 1088c2ecf20Sopenharmony_ci#define DT_ADDRRNGLO 0x6ffffe00 1098c2ecf20Sopenharmony_ci#define DT_ADDRRNGHI 0x6ffffeff 1108c2ecf20Sopenharmony_ci#define DT_VERSYM 0x6ffffff0 1118c2ecf20Sopenharmony_ci#define DT_RELACOUNT 0x6ffffff9 1128c2ecf20Sopenharmony_ci#define DT_RELCOUNT 0x6ffffffa 1138c2ecf20Sopenharmony_ci#define DT_FLAGS_1 0x6ffffffb 1148c2ecf20Sopenharmony_ci#define DT_VERDEF 0x6ffffffc 1158c2ecf20Sopenharmony_ci#define DT_VERDEFNUM 0x6ffffffd 1168c2ecf20Sopenharmony_ci#define DT_VERNEED 0x6ffffffe 1178c2ecf20Sopenharmony_ci#define DT_VERNEEDNUM 0x6fffffff 1188c2ecf20Sopenharmony_ci#define OLD_DT_HIOS 0x6fffffff 1198c2ecf20Sopenharmony_ci#define DT_LOPROC 0x70000000 1208c2ecf20Sopenharmony_ci#define DT_HIPROC 0x7fffffff 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* This info is needed when parsing the symbol table */ 1238c2ecf20Sopenharmony_ci#define STB_LOCAL 0 1248c2ecf20Sopenharmony_ci#define STB_GLOBAL 1 1258c2ecf20Sopenharmony_ci#define STB_WEAK 2 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define STT_NOTYPE 0 1288c2ecf20Sopenharmony_ci#define STT_OBJECT 1 1298c2ecf20Sopenharmony_ci#define STT_FUNC 2 1308c2ecf20Sopenharmony_ci#define STT_SECTION 3 1318c2ecf20Sopenharmony_ci#define STT_FILE 4 1328c2ecf20Sopenharmony_ci#define STT_COMMON 5 1338c2ecf20Sopenharmony_ci#define STT_TLS 6 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci#define ELF_ST_BIND(x) ((x) >> 4) 1368c2ecf20Sopenharmony_ci#define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf) 1378c2ecf20Sopenharmony_ci#define ELF32_ST_BIND(x) ELF_ST_BIND(x) 1388c2ecf20Sopenharmony_ci#define ELF32_ST_TYPE(x) ELF_ST_TYPE(x) 1398c2ecf20Sopenharmony_ci#define ELF64_ST_BIND(x) ELF_ST_BIND(x) 1408c2ecf20Sopenharmony_ci#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x) 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_citypedef struct dynamic{ 1438c2ecf20Sopenharmony_ci Elf32_Sword d_tag; 1448c2ecf20Sopenharmony_ci union{ 1458c2ecf20Sopenharmony_ci Elf32_Sword d_val; 1468c2ecf20Sopenharmony_ci Elf32_Addr d_ptr; 1478c2ecf20Sopenharmony_ci } d_un; 1488c2ecf20Sopenharmony_ci} Elf32_Dyn; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_citypedef struct { 1518c2ecf20Sopenharmony_ci Elf64_Sxword d_tag; /* entry tag value */ 1528c2ecf20Sopenharmony_ci union { 1538c2ecf20Sopenharmony_ci Elf64_Xword d_val; 1548c2ecf20Sopenharmony_ci Elf64_Addr d_ptr; 1558c2ecf20Sopenharmony_ci } d_un; 1568c2ecf20Sopenharmony_ci} Elf64_Dyn; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci/* The following are used with relocations */ 1598c2ecf20Sopenharmony_ci#define ELF32_R_SYM(x) ((x) >> 8) 1608c2ecf20Sopenharmony_ci#define ELF32_R_TYPE(x) ((x) & 0xff) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define ELF64_R_SYM(i) ((i) >> 32) 1638c2ecf20Sopenharmony_ci#define ELF64_R_TYPE(i) ((i) & 0xffffffff) 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_citypedef struct elf32_rel { 1668c2ecf20Sopenharmony_ci Elf32_Addr r_offset; 1678c2ecf20Sopenharmony_ci Elf32_Word r_info; 1688c2ecf20Sopenharmony_ci} Elf32_Rel; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_citypedef struct elf64_rel { 1718c2ecf20Sopenharmony_ci Elf64_Addr r_offset; /* Location at which to apply the action */ 1728c2ecf20Sopenharmony_ci Elf64_Xword r_info; /* index and type of relocation */ 1738c2ecf20Sopenharmony_ci} Elf64_Rel; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_citypedef struct elf32_rela{ 1768c2ecf20Sopenharmony_ci Elf32_Addr r_offset; 1778c2ecf20Sopenharmony_ci Elf32_Word r_info; 1788c2ecf20Sopenharmony_ci Elf32_Sword r_addend; 1798c2ecf20Sopenharmony_ci} Elf32_Rela; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_citypedef struct elf64_rela { 1828c2ecf20Sopenharmony_ci Elf64_Addr r_offset; /* Location at which to apply the action */ 1838c2ecf20Sopenharmony_ci Elf64_Xword r_info; /* index and type of relocation */ 1848c2ecf20Sopenharmony_ci Elf64_Sxword r_addend; /* Constant addend used to compute value */ 1858c2ecf20Sopenharmony_ci} Elf64_Rela; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_citypedef struct elf32_sym{ 1888c2ecf20Sopenharmony_ci Elf32_Word st_name; 1898c2ecf20Sopenharmony_ci Elf32_Addr st_value; 1908c2ecf20Sopenharmony_ci Elf32_Word st_size; 1918c2ecf20Sopenharmony_ci unsigned char st_info; 1928c2ecf20Sopenharmony_ci unsigned char st_other; 1938c2ecf20Sopenharmony_ci Elf32_Half st_shndx; 1948c2ecf20Sopenharmony_ci} Elf32_Sym; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_citypedef struct elf64_sym { 1978c2ecf20Sopenharmony_ci Elf64_Word st_name; /* Symbol name, index in string tbl */ 1988c2ecf20Sopenharmony_ci unsigned char st_info; /* Type and binding attributes */ 1998c2ecf20Sopenharmony_ci unsigned char st_other; /* No defined meaning, 0 */ 2008c2ecf20Sopenharmony_ci Elf64_Half st_shndx; /* Associated section index */ 2018c2ecf20Sopenharmony_ci Elf64_Addr st_value; /* Value of the symbol */ 2028c2ecf20Sopenharmony_ci Elf64_Xword st_size; /* Associated symbol size */ 2038c2ecf20Sopenharmony_ci} Elf64_Sym; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#define EI_NIDENT 16 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_citypedef struct elf32_hdr{ 2098c2ecf20Sopenharmony_ci unsigned char e_ident[EI_NIDENT]; 2108c2ecf20Sopenharmony_ci Elf32_Half e_type; 2118c2ecf20Sopenharmony_ci Elf32_Half e_machine; 2128c2ecf20Sopenharmony_ci Elf32_Word e_version; 2138c2ecf20Sopenharmony_ci Elf32_Addr e_entry; /* Entry point */ 2148c2ecf20Sopenharmony_ci Elf32_Off e_phoff; 2158c2ecf20Sopenharmony_ci Elf32_Off e_shoff; 2168c2ecf20Sopenharmony_ci Elf32_Word e_flags; 2178c2ecf20Sopenharmony_ci Elf32_Half e_ehsize; 2188c2ecf20Sopenharmony_ci Elf32_Half e_phentsize; 2198c2ecf20Sopenharmony_ci Elf32_Half e_phnum; 2208c2ecf20Sopenharmony_ci Elf32_Half e_shentsize; 2218c2ecf20Sopenharmony_ci Elf32_Half e_shnum; 2228c2ecf20Sopenharmony_ci Elf32_Half e_shstrndx; 2238c2ecf20Sopenharmony_ci} Elf32_Ehdr; 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_citypedef struct elf64_hdr { 2268c2ecf20Sopenharmony_ci unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ 2278c2ecf20Sopenharmony_ci Elf64_Half e_type; 2288c2ecf20Sopenharmony_ci Elf64_Half e_machine; 2298c2ecf20Sopenharmony_ci Elf64_Word e_version; 2308c2ecf20Sopenharmony_ci Elf64_Addr e_entry; /* Entry point virtual address */ 2318c2ecf20Sopenharmony_ci Elf64_Off e_phoff; /* Program header table file offset */ 2328c2ecf20Sopenharmony_ci Elf64_Off e_shoff; /* Section header table file offset */ 2338c2ecf20Sopenharmony_ci Elf64_Word e_flags; 2348c2ecf20Sopenharmony_ci Elf64_Half e_ehsize; 2358c2ecf20Sopenharmony_ci Elf64_Half e_phentsize; 2368c2ecf20Sopenharmony_ci Elf64_Half e_phnum; 2378c2ecf20Sopenharmony_ci Elf64_Half e_shentsize; 2388c2ecf20Sopenharmony_ci Elf64_Half e_shnum; 2398c2ecf20Sopenharmony_ci Elf64_Half e_shstrndx; 2408c2ecf20Sopenharmony_ci} Elf64_Ehdr; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci/* These constants define the permissions on sections in the program 2438c2ecf20Sopenharmony_ci header, p_flags. */ 2448c2ecf20Sopenharmony_ci#define PF_R 0x4 2458c2ecf20Sopenharmony_ci#define PF_W 0x2 2468c2ecf20Sopenharmony_ci#define PF_X 0x1 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_citypedef struct elf32_phdr{ 2498c2ecf20Sopenharmony_ci Elf32_Word p_type; 2508c2ecf20Sopenharmony_ci Elf32_Off p_offset; 2518c2ecf20Sopenharmony_ci Elf32_Addr p_vaddr; 2528c2ecf20Sopenharmony_ci Elf32_Addr p_paddr; 2538c2ecf20Sopenharmony_ci Elf32_Word p_filesz; 2548c2ecf20Sopenharmony_ci Elf32_Word p_memsz; 2558c2ecf20Sopenharmony_ci Elf32_Word p_flags; 2568c2ecf20Sopenharmony_ci Elf32_Word p_align; 2578c2ecf20Sopenharmony_ci} Elf32_Phdr; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_citypedef struct elf64_phdr { 2608c2ecf20Sopenharmony_ci Elf64_Word p_type; 2618c2ecf20Sopenharmony_ci Elf64_Word p_flags; 2628c2ecf20Sopenharmony_ci Elf64_Off p_offset; /* Segment file offset */ 2638c2ecf20Sopenharmony_ci Elf64_Addr p_vaddr; /* Segment virtual address */ 2648c2ecf20Sopenharmony_ci Elf64_Addr p_paddr; /* Segment physical address */ 2658c2ecf20Sopenharmony_ci Elf64_Xword p_filesz; /* Segment size in file */ 2668c2ecf20Sopenharmony_ci Elf64_Xword p_memsz; /* Segment size in memory */ 2678c2ecf20Sopenharmony_ci Elf64_Xword p_align; /* Segment alignment, file & memory */ 2688c2ecf20Sopenharmony_ci} Elf64_Phdr; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* sh_type */ 2718c2ecf20Sopenharmony_ci#define SHT_NULL 0 2728c2ecf20Sopenharmony_ci#define SHT_PROGBITS 1 2738c2ecf20Sopenharmony_ci#define SHT_SYMTAB 2 2748c2ecf20Sopenharmony_ci#define SHT_STRTAB 3 2758c2ecf20Sopenharmony_ci#define SHT_RELA 4 2768c2ecf20Sopenharmony_ci#define SHT_HASH 5 2778c2ecf20Sopenharmony_ci#define SHT_DYNAMIC 6 2788c2ecf20Sopenharmony_ci#define SHT_NOTE 7 2798c2ecf20Sopenharmony_ci#define SHT_NOBITS 8 2808c2ecf20Sopenharmony_ci#define SHT_REL 9 2818c2ecf20Sopenharmony_ci#define SHT_SHLIB 10 2828c2ecf20Sopenharmony_ci#define SHT_DYNSYM 11 2838c2ecf20Sopenharmony_ci#define SHT_NUM 12 2848c2ecf20Sopenharmony_ci#define SHT_LOPROC 0x70000000 2858c2ecf20Sopenharmony_ci#define SHT_HIPROC 0x7fffffff 2868c2ecf20Sopenharmony_ci#define SHT_LOUSER 0x80000000 2878c2ecf20Sopenharmony_ci#define SHT_HIUSER 0xffffffff 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci/* sh_flags */ 2908c2ecf20Sopenharmony_ci#define SHF_WRITE 0x1 2918c2ecf20Sopenharmony_ci#define SHF_ALLOC 0x2 2928c2ecf20Sopenharmony_ci#define SHF_EXECINSTR 0x4 2938c2ecf20Sopenharmony_ci#define SHF_RELA_LIVEPATCH 0x00100000 2948c2ecf20Sopenharmony_ci#define SHF_RO_AFTER_INIT 0x00200000 2958c2ecf20Sopenharmony_ci#define SHF_MASKPROC 0xf0000000 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci/* special section indexes */ 2988c2ecf20Sopenharmony_ci#define SHN_UNDEF 0 2998c2ecf20Sopenharmony_ci#define SHN_LORESERVE 0xff00 3008c2ecf20Sopenharmony_ci#define SHN_LOPROC 0xff00 3018c2ecf20Sopenharmony_ci#define SHN_HIPROC 0xff1f 3028c2ecf20Sopenharmony_ci#define SHN_LIVEPATCH 0xff20 3038c2ecf20Sopenharmony_ci#define SHN_ABS 0xfff1 3048c2ecf20Sopenharmony_ci#define SHN_COMMON 0xfff2 3058c2ecf20Sopenharmony_ci#define SHN_HIRESERVE 0xffff 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_citypedef struct elf32_shdr { 3088c2ecf20Sopenharmony_ci Elf32_Word sh_name; 3098c2ecf20Sopenharmony_ci Elf32_Word sh_type; 3108c2ecf20Sopenharmony_ci Elf32_Word sh_flags; 3118c2ecf20Sopenharmony_ci Elf32_Addr sh_addr; 3128c2ecf20Sopenharmony_ci Elf32_Off sh_offset; 3138c2ecf20Sopenharmony_ci Elf32_Word sh_size; 3148c2ecf20Sopenharmony_ci Elf32_Word sh_link; 3158c2ecf20Sopenharmony_ci Elf32_Word sh_info; 3168c2ecf20Sopenharmony_ci Elf32_Word sh_addralign; 3178c2ecf20Sopenharmony_ci Elf32_Word sh_entsize; 3188c2ecf20Sopenharmony_ci} Elf32_Shdr; 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_citypedef struct elf64_shdr { 3218c2ecf20Sopenharmony_ci Elf64_Word sh_name; /* Section name, index in string tbl */ 3228c2ecf20Sopenharmony_ci Elf64_Word sh_type; /* Type of section */ 3238c2ecf20Sopenharmony_ci Elf64_Xword sh_flags; /* Miscellaneous section attributes */ 3248c2ecf20Sopenharmony_ci Elf64_Addr sh_addr; /* Section virtual addr at execution */ 3258c2ecf20Sopenharmony_ci Elf64_Off sh_offset; /* Section file offset */ 3268c2ecf20Sopenharmony_ci Elf64_Xword sh_size; /* Size of section in bytes */ 3278c2ecf20Sopenharmony_ci Elf64_Word sh_link; /* Index of another section */ 3288c2ecf20Sopenharmony_ci Elf64_Word sh_info; /* Additional section information */ 3298c2ecf20Sopenharmony_ci Elf64_Xword sh_addralign; /* Section alignment */ 3308c2ecf20Sopenharmony_ci Elf64_Xword sh_entsize; /* Entry size if section holds table */ 3318c2ecf20Sopenharmony_ci} Elf64_Shdr; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci#define EI_MAG0 0 /* e_ident[] indexes */ 3348c2ecf20Sopenharmony_ci#define EI_MAG1 1 3358c2ecf20Sopenharmony_ci#define EI_MAG2 2 3368c2ecf20Sopenharmony_ci#define EI_MAG3 3 3378c2ecf20Sopenharmony_ci#define EI_CLASS 4 3388c2ecf20Sopenharmony_ci#define EI_DATA 5 3398c2ecf20Sopenharmony_ci#define EI_VERSION 6 3408c2ecf20Sopenharmony_ci#define EI_OSABI 7 3418c2ecf20Sopenharmony_ci#define EI_PAD 8 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#define ELFMAG0 0x7f /* EI_MAG */ 3448c2ecf20Sopenharmony_ci#define ELFMAG1 'E' 3458c2ecf20Sopenharmony_ci#define ELFMAG2 'L' 3468c2ecf20Sopenharmony_ci#define ELFMAG3 'F' 3478c2ecf20Sopenharmony_ci#define ELFMAG "\177ELF" 3488c2ecf20Sopenharmony_ci#define SELFMAG 4 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci#define ELFCLASSNONE 0 /* EI_CLASS */ 3518c2ecf20Sopenharmony_ci#define ELFCLASS32 1 3528c2ecf20Sopenharmony_ci#define ELFCLASS64 2 3538c2ecf20Sopenharmony_ci#define ELFCLASSNUM 3 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci#define ELFDATANONE 0 /* e_ident[EI_DATA] */ 3568c2ecf20Sopenharmony_ci#define ELFDATA2LSB 1 3578c2ecf20Sopenharmony_ci#define ELFDATA2MSB 2 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci#define EV_NONE 0 /* e_version, EI_VERSION */ 3608c2ecf20Sopenharmony_ci#define EV_CURRENT 1 3618c2ecf20Sopenharmony_ci#define EV_NUM 2 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci#define ELFOSABI_NONE 0 3648c2ecf20Sopenharmony_ci#define ELFOSABI_LINUX 3 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci#ifndef ELF_OSABI 3678c2ecf20Sopenharmony_ci#define ELF_OSABI ELFOSABI_NONE 3688c2ecf20Sopenharmony_ci#endif 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci/* 3718c2ecf20Sopenharmony_ci * Notes used in ET_CORE. Architectures export some of the arch register sets 3728c2ecf20Sopenharmony_ci * using the corresponding note types via the PTRACE_GETREGSET and 3738c2ecf20Sopenharmony_ci * PTRACE_SETREGSET requests. 3748c2ecf20Sopenharmony_ci * The note name for all these is "LINUX". 3758c2ecf20Sopenharmony_ci */ 3768c2ecf20Sopenharmony_ci#define NT_PRSTATUS 1 3778c2ecf20Sopenharmony_ci#define NT_PRFPREG 2 3788c2ecf20Sopenharmony_ci#define NT_PRPSINFO 3 3798c2ecf20Sopenharmony_ci#define NT_TASKSTRUCT 4 3808c2ecf20Sopenharmony_ci#define NT_AUXV 6 3818c2ecf20Sopenharmony_ci/* 3828c2ecf20Sopenharmony_ci * Note to userspace developers: size of NT_SIGINFO note may increase 3838c2ecf20Sopenharmony_ci * in the future to accomodate more fields, don't assume it is fixed! 3848c2ecf20Sopenharmony_ci */ 3858c2ecf20Sopenharmony_ci#define NT_SIGINFO 0x53494749 3868c2ecf20Sopenharmony_ci#define NT_FILE 0x46494c45 3878c2ecf20Sopenharmony_ci#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ 3888c2ecf20Sopenharmony_ci#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ 3898c2ecf20Sopenharmony_ci#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ 3908c2ecf20Sopenharmony_ci#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ 3918c2ecf20Sopenharmony_ci#define NT_PPC_TAR 0x103 /* Target Address Register */ 3928c2ecf20Sopenharmony_ci#define NT_PPC_PPR 0x104 /* Program Priority Register */ 3938c2ecf20Sopenharmony_ci#define NT_PPC_DSCR 0x105 /* Data Stream Control Register */ 3948c2ecf20Sopenharmony_ci#define NT_PPC_EBB 0x106 /* Event Based Branch Registers */ 3958c2ecf20Sopenharmony_ci#define NT_PPC_PMU 0x107 /* Performance Monitor Registers */ 3968c2ecf20Sopenharmony_ci#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */ 3978c2ecf20Sopenharmony_ci#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */ 3988c2ecf20Sopenharmony_ci#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */ 3998c2ecf20Sopenharmony_ci#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */ 4008c2ecf20Sopenharmony_ci#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */ 4018c2ecf20Sopenharmony_ci#define NT_PPC_TM_CTAR 0x10d /* TM checkpointed Target Address Register */ 4028c2ecf20Sopenharmony_ci#define NT_PPC_TM_CPPR 0x10e /* TM checkpointed Program Priority Register */ 4038c2ecf20Sopenharmony_ci#define NT_PPC_TM_CDSCR 0x10f /* TM checkpointed Data Stream Control Register */ 4048c2ecf20Sopenharmony_ci#define NT_PPC_PKEY 0x110 /* Memory Protection Keys registers */ 4058c2ecf20Sopenharmony_ci#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ 4068c2ecf20Sopenharmony_ci#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */ 4078c2ecf20Sopenharmony_ci#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ 4088c2ecf20Sopenharmony_ci#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */ 4098c2ecf20Sopenharmony_ci#define NT_S390_TIMER 0x301 /* s390 timer register */ 4108c2ecf20Sopenharmony_ci#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ 4118c2ecf20Sopenharmony_ci#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ 4128c2ecf20Sopenharmony_ci#define NT_S390_CTRS 0x304 /* s390 control registers */ 4138c2ecf20Sopenharmony_ci#define NT_S390_PREFIX 0x305 /* s390 prefix register */ 4148c2ecf20Sopenharmony_ci#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ 4158c2ecf20Sopenharmony_ci#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */ 4168c2ecf20Sopenharmony_ci#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */ 4178c2ecf20Sopenharmony_ci#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 upper half */ 4188c2ecf20Sopenharmony_ci#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31 */ 4198c2ecf20Sopenharmony_ci#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers */ 4208c2ecf20Sopenharmony_ci#define NT_S390_GS_BC 0x30c /* s390 guarded storage broadcast control block */ 4218c2ecf20Sopenharmony_ci#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation */ 4228c2ecf20Sopenharmony_ci#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */ 4238c2ecf20Sopenharmony_ci#define NT_ARM_TLS 0x401 /* ARM TLS register */ 4248c2ecf20Sopenharmony_ci#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ 4258c2ecf20Sopenharmony_ci#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ 4268c2ecf20Sopenharmony_ci#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */ 4278c2ecf20Sopenharmony_ci#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension registers */ 4288c2ecf20Sopenharmony_ci#define NT_ARM_PAC_MASK 0x406 /* ARM pointer authentication code masks */ 4298c2ecf20Sopenharmony_ci#define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication address keys */ 4308c2ecf20Sopenharmony_ci#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */ 4318c2ecf20Sopenharmony_ci#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */ 4328c2ecf20Sopenharmony_ci#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */ 4338c2ecf20Sopenharmony_ci#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */ 4348c2ecf20Sopenharmony_ci#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */ 4358c2ecf20Sopenharmony_ci#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode */ 4368c2ecf20Sopenharmony_ci#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers */ 4378c2ecf20Sopenharmony_ci#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */ 4388c2ecf20Sopenharmony_ci#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */ 4398c2ecf20Sopenharmony_ci#define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */ 4408c2ecf20Sopenharmony_ci#define NT_LOONGARCH_LASX 0xa03 /* LoongArch Loongson Advanced SIMD Extension registers */ 4418c2ecf20Sopenharmony_ci#define NT_LOONGARCH_LBT 0xa04 /* LoongArch Loongson Binary Translation registers */ 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci/* Note types with note name "GNU" */ 4448c2ecf20Sopenharmony_ci#define NT_GNU_PROPERTY_TYPE_0 5 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci/* Note header in a PT_NOTE section */ 4478c2ecf20Sopenharmony_citypedef struct elf32_note { 4488c2ecf20Sopenharmony_ci Elf32_Word n_namesz; /* Name size */ 4498c2ecf20Sopenharmony_ci Elf32_Word n_descsz; /* Content size */ 4508c2ecf20Sopenharmony_ci Elf32_Word n_type; /* Content type */ 4518c2ecf20Sopenharmony_ci} Elf32_Nhdr; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci/* Note header in a PT_NOTE section */ 4548c2ecf20Sopenharmony_citypedef struct elf64_note { 4558c2ecf20Sopenharmony_ci Elf64_Word n_namesz; /* Name size */ 4568c2ecf20Sopenharmony_ci Elf64_Word n_descsz; /* Content size */ 4578c2ecf20Sopenharmony_ci Elf64_Word n_type; /* Content type */ 4588c2ecf20Sopenharmony_ci} Elf64_Nhdr; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci/* .note.gnu.property types for EM_AARCH64: */ 4618c2ecf20Sopenharmony_ci#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci/* Bits for GNU_PROPERTY_AARCH64_FEATURE_1_BTI */ 4648c2ecf20Sopenharmony_ci#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0) 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci#endif /* _UAPI_LINUX_ELF_H */ 467