1ed0d50c3Schristos /* RL78 ELF support for BFD. 2*b88e3e88Schristos Copyright (C) 2008-2020 Free Software Foundation, Inc. 3ed0d50c3Schristos 4ed0d50c3Schristos This file is part of BFD, the Binary File Descriptor library. 5ed0d50c3Schristos 6ed0d50c3Schristos This program is free software; you can redistribute it and/or modify 7ed0d50c3Schristos it under the terms of the GNU General Public License as published by 8ed0d50c3Schristos the Free Software Foundation; either version 3 of the License, or 9ed0d50c3Schristos (at your option) any later version. 10ed0d50c3Schristos 11ed0d50c3Schristos This program is distributed in the hope that it will be useful, 12ed0d50c3Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 13ed0d50c3Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14ed0d50c3Schristos GNU General Public License for more details. 15ed0d50c3Schristos 16ed0d50c3Schristos You should have received a copy of the GNU General Public License 17ed0d50c3Schristos along with this program; if not, write to the Free Software Foundation, 18ed0d50c3Schristos Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 19ed0d50c3Schristos 20ed0d50c3Schristos #ifndef _ELF_RL78_H 21ed0d50c3Schristos #define _ELF_RL78_H 22ed0d50c3Schristos 23ed0d50c3Schristos #include "elf/reloc-macros.h" 24ed0d50c3Schristos 25ed0d50c3Schristos /* Note that there are a few internal relocation types used by the 26ed0d50c3Schristos linker to do link-time relaxation. If you update this file, please 27ed0d50c3Schristos check elf32-rl78.c to see if any of the internal relocations need to 28ed0d50c3Schristos be, er, relocated. */ 29ed0d50c3Schristos 30ed0d50c3Schristos /* Preliminary relocations. */ 31ed0d50c3Schristos START_RELOC_NUMBERS (elf_rl78_reloc_type) 32ed0d50c3Schristos 33ed0d50c3Schristos RELOC_NUMBER (R_RL78_NONE, 0x00) 34ed0d50c3Schristos /* These are for data, and are bi-endian. */ 35ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR32, 0x01) /* Was: R_RL78_32. */ 36ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR24S, 0x02) /* Was: R_RL78_24. */ 37ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16, 0x03) 38ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16U, 0x04) /* Was: R_RL78_16_UNS. */ 39ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16S, 0x05) /* Was: R_RL78_16. */ 40ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR8, 0x06) 41ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR8U, 0x07) /* Was: R_RL78_8_UNS. */ 42ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR8S, 0x08) /* Was: R_RL78_8. */ 43ed0d50c3Schristos 44ed0d50c3Schristos /* Signed pc-relative values. */ 45ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR24S_PCREL, 0x09) /* Was: R_RL78_24_PCREL. */ 46ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16S_PCREL, 0x0a) /* Was: R_RL78_16_PCREL. */ 47ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR8S_PCREL, 0x0b) /* Was: R_RL78_8_PCREL. */ 48ed0d50c3Schristos 49ed0d50c3Schristos /* These are for fields in the instructions. */ 50ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16UL, 0x0c) 51ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16UW, 0x0d) 52ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR8UL, 0x0e) 53ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR8UW, 0x0f) 54ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR32_REV, 0x10) 55ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR16_REV, 0x11) 56ed0d50c3Schristos RELOC_NUMBER (R_RL78_DIR3U_PCREL, 0x12) 57ed0d50c3Schristos 58ed0d50c3Schristos /* These are extensions added by Red Hat. */ 59ed0d50c3Schristos RELOC_NUMBER (R_RL78_RH_RELAX, 0x2d) /* Marks opcodes suitable for linker relaxation. */ 60ed0d50c3Schristos RELOC_NUMBER (R_RL78_RH_SFR, 0x2e) /* SFR addresses - internal use only. */ 61ed0d50c3Schristos RELOC_NUMBER (R_RL78_RH_SADDR, 0x2f) /* SADDR addresses - internal use only.. */ 62ed0d50c3Schristos 63ed0d50c3Schristos /* These are for complex relocs. */ 64ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS32, 0x41) 65ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS24S, 0x42) 66ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16, 0x43) 67ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16U, 0x44) 68ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16S, 0x45) 69ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS8, 0x46) 70ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS8U, 0x47) 71ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS8S, 0x48) 72ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS24S_PCREL, 0x49) 73ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16S_PCREL, 0x4a) 74ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS8S_PCREL, 0x4b) 75ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16UL, 0x4c) 76ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16UW, 0x4d) 77ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS8UL, 0x4e) 78ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS8UW, 0x4f) 79ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS32_REV, 0x50) 80ed0d50c3Schristos RELOC_NUMBER (R_RL78_ABS16_REV, 0x51) 81ed0d50c3Schristos 82ed0d50c3Schristos RELOC_NUMBER (R_RL78_SYM, 0x80) 83ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPneg, 0x81) 84ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPadd, 0x82) 85ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPsub, 0x83) 86ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPmul, 0x84) 87ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPdiv, 0x85) 88ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPshla, 0x86) 89ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPshra, 0x87) 90ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPsctsize, 0x88) 91ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPscttop, 0x8d) 92ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPand, 0x90) 93ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPor, 0x91) 94ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPxor, 0x92) 95ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPnot, 0x93) 96ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPmod, 0x94) 97ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPromtop, 0x95) 98ed0d50c3Schristos RELOC_NUMBER (R_RL78_OPramtop, 0x96) 99ed0d50c3Schristos 100ed0d50c3Schristos END_RELOC_NUMBERS (R_RL78_max) 101ed0d50c3Schristos 102ed0d50c3Schristos #define EF_RL78_CPU_RL78 0x00000079 /* FIXME: correct value? */ 103ed0d50c3Schristos #define EF_RL78_CPU_MASK 0x0000007F /* specific cpu bits. */ 104ed0d50c3Schristos #define EF_RL78_ALL_FLAGS (EF_RL78_CPU_MASK) 105ed0d50c3Schristos 106ed0d50c3Schristos /* Values for the e_flags field in the ELF header. */ 107ed0d50c3Schristos #define E_FLAG_RL78_64BIT_DOUBLES (1 << 0) 108ed0d50c3Schristos #define E_FLAG_RL78_DSP (1 << 1) /* Defined in the RL78 CPU Object file specification, but not explained. */ 109ed0d50c3Schristos #define E_FLAG_RL78_CPU_MASK 0x0c 110ed0d50c3Schristos #define E_FLAG_RL78_ANY_CPU 0x00 /* CPU not specified. Assume no CPU specific code usage. */ 111ed0d50c3Schristos #define E_FLAG_RL78_G10 0x04 /* CPU is missing register banks 1-3, so uses different ABI. */ 112ed0d50c3Schristos #define E_FLAG_RL78_G13 0x08 /* CPU uses a peripheral for multiply/divide. */ 113ed0d50c3Schristos #define E_FLAG_RL78_G14 0x0c /* CPU has multiply/divide instructions. */ 114ed0d50c3Schristos 115ed0d50c3Schristos /* These define the addend field of R_RL78_RH_RELAX relocations. */ 116ed0d50c3Schristos #define RL78_RELAXA_MASK 0x000000f0 /* Mask for relax types */ 117ed0d50c3Schristos #define RL78_RELAXA_BRA 0x00000010 /* Any type of branch (must be decoded). */ 118ed0d50c3Schristos #define RL78_RELAXA_ADDR16 0x00000020 /* addr16->sfr/saddr opportunity */ 119ed0d50c3Schristos #define RL78_RELAXA_RNUM 0x0000000f /* Number of associated relocations. */ 120ed0d50c3Schristos /* These mark the place where alignment is requested, and the place where the filler bytes end. */ 121ed0d50c3Schristos #define RL78_RELAXA_ALIGN 0x10000000 /* Start alignment; the remaining bits are the alignment value. */ 122ed0d50c3Schristos #define RL78_RELAXA_ELIGN 0x20000000 /* End alignment; the remaining bits are the alignment value. */ 123ed0d50c3Schristos #define RL78_RELAXA_ANUM 0x00ffffff /* Alignment amount, in bytes (i.e. .balign). */ 124ed0d50c3Schristos 125ed0d50c3Schristos #endif /* _ELF_RL78_H */ 126