18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * include/asm-xtensa/elf.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * ELF register definitions 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 78c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 88c2ecf20Sopenharmony_ci * for more details. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright (C) 2001 - 2005 Tensilica Inc. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef _XTENSA_ELF_H 148c2ecf20Sopenharmony_ci#define _XTENSA_ELF_H 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 178c2ecf20Sopenharmony_ci#include <asm/coprocessor.h> 188c2ecf20Sopenharmony_ci#include <linux/elf-em.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* Xtensa processor ELF architecture-magic number */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define EM_XTENSA_OLD 0xABC7 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* Xtensa relocations defined by the ABIs */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define R_XTENSA_NONE 0 278c2ecf20Sopenharmony_ci#define R_XTENSA_32 1 288c2ecf20Sopenharmony_ci#define R_XTENSA_RTLD 2 298c2ecf20Sopenharmony_ci#define R_XTENSA_GLOB_DAT 3 308c2ecf20Sopenharmony_ci#define R_XTENSA_JMP_SLOT 4 318c2ecf20Sopenharmony_ci#define R_XTENSA_RELATIVE 5 328c2ecf20Sopenharmony_ci#define R_XTENSA_PLT 6 338c2ecf20Sopenharmony_ci#define R_XTENSA_OP0 8 348c2ecf20Sopenharmony_ci#define R_XTENSA_OP1 9 358c2ecf20Sopenharmony_ci#define R_XTENSA_OP2 10 368c2ecf20Sopenharmony_ci#define R_XTENSA_ASM_EXPAND 11 378c2ecf20Sopenharmony_ci#define R_XTENSA_ASM_SIMPLIFY 12 388c2ecf20Sopenharmony_ci#define R_XTENSA_GNU_VTINHERIT 15 398c2ecf20Sopenharmony_ci#define R_XTENSA_GNU_VTENTRY 16 408c2ecf20Sopenharmony_ci#define R_XTENSA_DIFF8 17 418c2ecf20Sopenharmony_ci#define R_XTENSA_DIFF16 18 428c2ecf20Sopenharmony_ci#define R_XTENSA_DIFF32 19 438c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT0_OP 20 448c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT1_OP 21 458c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT2_OP 22 468c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT3_OP 23 478c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT4_OP 24 488c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT5_OP 25 498c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT6_OP 26 508c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT7_OP 27 518c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT8_OP 28 528c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT9_OP 29 538c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT10_OP 30 548c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT11_OP 31 558c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT12_OP 32 568c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT13_OP 33 578c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT14_OP 34 588c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT0_ALT 35 598c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT1_ALT 36 608c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT2_ALT 37 618c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT3_ALT 38 628c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT4_ALT 39 638c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT5_ALT 40 648c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT6_ALT 41 658c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT7_ALT 42 668c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT8_ALT 43 678c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT9_ALT 44 688c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT10_ALT 45 698c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT11_ALT 46 708c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT12_ALT 47 718c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT13_ALT 48 728c2ecf20Sopenharmony_ci#define R_XTENSA_SLOT14_ALT 49 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* ELF register definitions. This is needed for core dump support. */ 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_citypedef struct user_pt_regs xtensa_gregset_t; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define ELF_NGREG (sizeof(xtensa_gregset_t) / sizeof(elf_greg_t)) 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG]; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define ELF_NFPREG 18 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_citypedef unsigned int elf_fpreg_t; 878c2ecf20Sopenharmony_citypedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* 908c2ecf20Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture. 918c2ecf20Sopenharmony_ci */ 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define elf_check_arch(x) ( ( (x)->e_machine == EM_XTENSA ) || \ 948c2ecf20Sopenharmony_ci ( (x)->e_machine == EM_XTENSA_OLD ) ) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* 978c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#ifdef __XTENSA_EL__ 1018c2ecf20Sopenharmony_ci# define ELF_DATA ELFDATA2LSB 1028c2ecf20Sopenharmony_ci#elif defined(__XTENSA_EB__) 1038c2ecf20Sopenharmony_ci# define ELF_DATA ELFDATA2MSB 1048c2ecf20Sopenharmony_ci#else 1058c2ecf20Sopenharmony_ci# error processor byte order undefined! 1068c2ecf20Sopenharmony_ci#endif 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#define ELF_CLASS ELFCLASS32 1098c2ecf20Sopenharmony_ci#define ELF_ARCH EM_XTENSA 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define ELF_EXEC_PAGESIZE PAGE_SIZE 1128c2ecf20Sopenharmony_ci#define CORE_DUMP_USE_REGSET 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* 1158c2ecf20Sopenharmony_ci * This is the location that an ET_DYN program is loaded if exec'ed. Typical 1168c2ecf20Sopenharmony_ci * use of this is to invoke "./ld.so someprog" to test out a new version of 1178c2ecf20Sopenharmony_ci * the loader. We need to make sure that it is out of the way of the program 1188c2ecf20Sopenharmony_ci * that it will "exec", and that there is sufficient room for the brk. 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* 1248c2ecf20Sopenharmony_ci * This yields a mask that user programs can use to figure out what 1258c2ecf20Sopenharmony_ci * instruction set this CPU supports. This could be done in user space, 1268c2ecf20Sopenharmony_ci * but it's not easy, and we've already done it here. 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define ELF_HWCAP (0) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* 1328c2ecf20Sopenharmony_ci * This yields a string that ld.so will use to load implementation 1338c2ecf20Sopenharmony_ci * specific libraries for optimization. This is more specific in 1348c2ecf20Sopenharmony_ci * intent than poking at uname or /proc/cpuinfo. 1358c2ecf20Sopenharmony_ci * For the moment, we have only optimizations for the Intel generations, 1368c2ecf20Sopenharmony_ci * but that could change... 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define ELF_PLATFORM (NULL) 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* 1428c2ecf20Sopenharmony_ci * The Xtensa processor ABI says that when the program starts, a2 1438c2ecf20Sopenharmony_ci * contains a pointer to a function which might be registered using 1448c2ecf20Sopenharmony_ci * `atexit'. This provides a mean for the dynamic linker to call 1458c2ecf20Sopenharmony_ci * DT_FINI functions for shared libraries that have been loaded before 1468c2ecf20Sopenharmony_ci * the code runs. 1478c2ecf20Sopenharmony_ci * 1488c2ecf20Sopenharmony_ci * A value of 0 tells we have no such handler. 1498c2ecf20Sopenharmony_ci * 1508c2ecf20Sopenharmony_ci * We might as well make sure everything else is cleared too (except 1518c2ecf20Sopenharmony_ci * for the stack pointer in a1), just to make things more 1528c2ecf20Sopenharmony_ci * deterministic. Also, clearing a0 terminates debugger backtraces. 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr) \ 1568c2ecf20Sopenharmony_ci do { _r->areg[0]=0; /*_r->areg[1]=0;*/ _r->areg[2]=0; _r->areg[3]=0; \ 1578c2ecf20Sopenharmony_ci _r->areg[4]=0; _r->areg[5]=0; _r->areg[6]=0; _r->areg[7]=0; \ 1588c2ecf20Sopenharmony_ci _r->areg[8]=0; _r->areg[9]=0; _r->areg[10]=0; _r->areg[11]=0; \ 1598c2ecf20Sopenharmony_ci _r->areg[12]=0; _r->areg[13]=0; _r->areg[14]=0; _r->areg[15]=0; \ 1608c2ecf20Sopenharmony_ci } while (0) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_citypedef struct { 1638c2ecf20Sopenharmony_ci xtregs_opt_t opt; 1648c2ecf20Sopenharmony_ci xtregs_user_t user; 1658c2ecf20Sopenharmony_ci#if XTENSA_HAVE_COPROCESSORS 1668c2ecf20Sopenharmony_ci xtregs_cp0_t cp0; 1678c2ecf20Sopenharmony_ci xtregs_cp1_t cp1; 1688c2ecf20Sopenharmony_ci xtregs_cp2_t cp2; 1698c2ecf20Sopenharmony_ci xtregs_cp3_t cp3; 1708c2ecf20Sopenharmony_ci xtregs_cp4_t cp4; 1718c2ecf20Sopenharmony_ci xtregs_cp5_t cp5; 1728c2ecf20Sopenharmony_ci xtregs_cp6_t cp6; 1738c2ecf20Sopenharmony_ci xtregs_cp7_t cp7; 1748c2ecf20Sopenharmony_ci#endif 1758c2ecf20Sopenharmony_ci} elf_xtregs_t; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci#define SET_PERSONALITY(ex) \ 1788c2ecf20Sopenharmony_ci set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK))) 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#endif /* _XTENSA_ELF_H */ 181