1130561Sobrien/* coff information for Renesas SH 285815Sobrien 3218822Sdim Copyright 2000, 2003 Free Software Foundation, Inc. 433965Sjdp 585815Sobrien This program is free software; you can redistribute it and/or modify 685815Sobrien it under the terms of the GNU General Public License as published by 785815Sobrien the Free Software Foundation; either version 2 of the License, or 885815Sobrien (at your option) any later version. 985815Sobrien 1085815Sobrien This program is distributed in the hope that it will be useful, 1185815Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1285815Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1385815Sobrien GNU General Public License for more details. 1485815Sobrien 1585815Sobrien You should have received a copy of the GNU General Public License 1685815Sobrien along with this program; if not, write to the Free Software 17218822Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 1885815Sobrien 1989857Sobrien#ifdef COFF_WITH_PE 2089857Sobrien#define L_LNNO_SIZE 2 2189857Sobrien#else 2289857Sobrien#define L_LNNO_SIZE 4 2389857Sobrien#endif 2489857Sobrien#define INCLUDE_COMDAT_FIELDS_IN_AUXENT 2589857Sobrien#include "coff/external.h" 2633965Sjdp 2733965Sjdp#define SH_ARCH_MAGIC_BIG 0x0500 2833965Sjdp#define SH_ARCH_MAGIC_LITTLE 0x0550 /* Little endian SH */ 2960484Sobrien#define SH_ARCH_MAGIC_WINCE 0x01a2 /* Windows CE - little endian */ 3060484Sobrien#define SH_PE_MAGIC 0x010b 3133965Sjdp 3233965Sjdp#define SHBADMAG(x) \ 3389857Sobrien (((x).f_magic != SH_ARCH_MAGIC_BIG) && \ 3489857Sobrien ((x).f_magic != SH_ARCH_MAGIC_WINCE) && \ 3589857Sobrien ((x).f_magic != SH_ARCH_MAGIC_LITTLE)) 3633965Sjdp 3760484Sobrien/* Define some NT default values. */ 3860484Sobrien/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ 3960484Sobrien#define NT_SECTION_ALIGNMENT 0x1000 4060484Sobrien#define NT_FILE_ALIGNMENT 0x200 4160484Sobrien#define NT_DEF_RESERVE 0x100000 4260484Sobrien#define NT_DEF_COMMIT 0x1000 4333965Sjdp 4433965Sjdp/********************** RELOCATION DIRECTIVES **********************/ 4533965Sjdp 4633965Sjdp/* The external reloc has an offset field, because some of the reloc 4733965Sjdp types on the h8 don't have room in the instruction for the entire 4889857Sobrien offset - eg the strange jump and high page addressing modes. */ 4933965Sjdp 5060484Sobrien#ifndef COFF_WITH_PE 5189857Sobrienstruct external_reloc 5289857Sobrien{ 5333965Sjdp char r_vaddr[4]; 5433965Sjdp char r_symndx[4]; 5533965Sjdp char r_offset[4]; 5633965Sjdp char r_type[2]; 5733965Sjdp char r_stuff[2]; 5833965Sjdp}; 5960484Sobrien#else 6089857Sobrienstruct external_reloc 6189857Sobrien{ 6260484Sobrien char r_vaddr[4]; 6360484Sobrien char r_symndx[4]; 6460484Sobrien char r_type[2]; 6560484Sobrien}; 6660484Sobrien#endif 6733965Sjdp 6833965Sjdp#define RELOC struct external_reloc 6960484Sobrien#ifdef COFF_WITH_PE 7060484Sobrien#define RELSZ 10 7160484Sobrien#else 7233965Sjdp#define RELSZ 16 7360484Sobrien#endif 7433965Sjdp 7533965Sjdp/* SH relocation types. Not all of these are actually used. */ 7633965Sjdp 7733965Sjdp#define R_SH_UNUSED 0 /* only used internally */ 7860484Sobrien#define R_SH_IMM32CE 2 /* 32 bit immediate for WinCE */ 7933965Sjdp#define R_SH_PCREL8 3 /* 8 bit pcrel */ 8033965Sjdp#define R_SH_PCREL16 4 /* 16 bit pcrel */ 8133965Sjdp#define R_SH_HIGH8 5 /* high 8 bits of 24 bit address */ 8233965Sjdp#define R_SH_LOW16 7 /* low 16 bits of 24 bit immediate */ 8333965Sjdp#define R_SH_IMM24 6 /* 24 bit immediate */ 8433965Sjdp#define R_SH_PCDISP8BY4 9 /* PC rel 8 bits *4 +ve */ 8533965Sjdp#define R_SH_PCDISP8BY2 10 /* PC rel 8 bits *2 +ve */ 8633965Sjdp#define R_SH_PCDISP8 11 /* 8 bit branch */ 8733965Sjdp#define R_SH_PCDISP 12 /* 12 bit branch */ 8833965Sjdp#define R_SH_IMM32 14 /* 32 bit immediate */ 8933965Sjdp#define R_SH_IMM8 16 /* 8 bit immediate */ 9060484Sobrien#define R_SH_IMAGEBASE 16 /* Windows CE */ 9133965Sjdp#define R_SH_IMM8BY2 17 /* 8 bit immediate *2 */ 9233965Sjdp#define R_SH_IMM8BY4 18 /* 8 bit immediate *4 */ 9333965Sjdp#define R_SH_IMM4 19 /* 4 bit immediate */ 9433965Sjdp#define R_SH_IMM4BY2 20 /* 4 bit immediate *2 */ 9533965Sjdp#define R_SH_IMM4BY4 21 /* 4 bit immediate *4 */ 9633965Sjdp#define R_SH_PCRELIMM8BY2 22 /* PC rel 8 bits *2 unsigned */ 9733965Sjdp#define R_SH_PCRELIMM8BY4 23 /* PC rel 8 bits *4 unsigned */ 9833965Sjdp#define R_SH_IMM16 24 /* 16 bit immediate */ 9933965Sjdp 10033965Sjdp/* The switch table reloc types are used for relaxing. They are 10133965Sjdp generated for expressions such as 10233965Sjdp .word L1 - L2 10333965Sjdp The r_offset field holds the difference between the reloc address 10433965Sjdp and L2. */ 10538889Sjdp#define R_SH_SWITCH8 33 /* 8 bit switch table entry */ 10633965Sjdp#define R_SH_SWITCH16 25 /* 16 bit switch table entry */ 10733965Sjdp#define R_SH_SWITCH32 26 /* 32 bit switch table entry */ 10833965Sjdp 10933965Sjdp/* The USES reloc type is used for relaxing. The compiler will 11033965Sjdp generate .uses pseudo-ops when it finds a function call which it 11133965Sjdp can relax. The r_offset field of the USES reloc holds the PC 11233965Sjdp relative offset to the instruction which loads the register used in 11333965Sjdp the function call. */ 11433965Sjdp#define R_SH_USES 27 /* .uses pseudo-op */ 11533965Sjdp 11633965Sjdp/* The COUNT reloc type is used for relaxing. The assembler will 11733965Sjdp generate COUNT relocs for addresses referred to by the register 11833965Sjdp loads associated with USES relocs. The r_offset field of the COUNT 11933965Sjdp reloc holds the number of times the address is referenced in the 12033965Sjdp object file. */ 12133965Sjdp#define R_SH_COUNT 28 /* Count of constant pool uses */ 12233965Sjdp 12333965Sjdp/* The ALIGN reloc type is used for relaxing. The r_offset field is 12433965Sjdp the power of two to which subsequent portions of the object file 12533965Sjdp must be aligned. */ 12633965Sjdp#define R_SH_ALIGN 29 /* .align pseudo-op */ 12733965Sjdp 12833965Sjdp/* The CODE and DATA reloc types are used for aligning load and store 12933965Sjdp instructions. The assembler will generate a CODE reloc before a 13033965Sjdp block of instructions. It will generate a DATA reloc before data. 13133965Sjdp A section should be processed assuming it contains data, unless a 13233965Sjdp CODE reloc is seen. The only relevant pieces of information in the 13333965Sjdp CODE and DATA relocs are the section and the address. The symbol 13433965Sjdp and offset are meaningless. */ 13533965Sjdp#define R_SH_CODE 30 /* start of code */ 13633965Sjdp#define R_SH_DATA 31 /* start of data */ 13733965Sjdp 13833965Sjdp/* The LABEL reloc type is used for aligning load and store 13933965Sjdp instructions. The assembler will generate a LABEL reloc for each 14033965Sjdp label within a block of instructions. This permits the linker to 14133965Sjdp avoid swapping instructions which are the targets of branches. */ 14233965Sjdp#define R_SH_LABEL 32 /* label */ 14338889Sjdp 14438889Sjdp/* NB: R_SH_SWITCH8 is 33 */ 14585815Sobrien 14685815Sobrien#define R_SH_LOOP_START 34 14785815Sobrien#define R_SH_LOOP_END 35 148