1258945Sroberto/* coff information for Renesas SH
2280849Scy
3258945Sroberto   Copyright (C) 2000-2017 Free Software Foundation, Inc.
4258945Sroberto
5258945Sroberto   This program is free software; you can redistribute it and/or modify
6258945Sroberto   it under the terms of the GNU General Public License as published by
7258945Sroberto   the Free Software Foundation; either version 3 of the License, or
8258945Sroberto   (at your option) any later version.
9258945Sroberto
10258945Sroberto   This program is distributed in the hope that it will be useful,
11258945Sroberto   but WITHOUT ANY WARRANTY; without even the implied warranty of
12258945Sroberto   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13258945Sroberto   GNU General Public License for more details.
14258945Sroberto
15258945Sroberto   You should have received a copy of the GNU General Public License
16258945Sroberto   along with this program; if not, write to the Free Software
17258945Sroberto   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18280849Scy   MA 02110-1301, USA.  */
19258945Sroberto
20258945Sroberto#ifdef COFF_WITH_PE
21258945Sroberto#define L_LNNO_SIZE 2
22258945Sroberto#else
23258945Sroberto#define L_LNNO_SIZE 4
24258945Sroberto#endif
25258945Sroberto#define INCLUDE_COMDAT_FIELDS_IN_AUXENT
26258945Sroberto#include "coff/external.h"
27258945Sroberto
28258945Sroberto#define	SH_ARCH_MAGIC_BIG	0x0500
29258945Sroberto#define	SH_ARCH_MAGIC_LITTLE	0x0550  /* Little endian SH */
30258945Sroberto#define SH_ARCH_MAGIC_WINCE	0x01a2  /* Windows CE - little endian */
31258945Sroberto#define SH_PE_MAGIC		0x010b
32258945Sroberto
33258945Sroberto#define SHBADMAG(x) \
34258945Sroberto (((x).f_magic != SH_ARCH_MAGIC_BIG) && \
35258945Sroberto  ((x).f_magic != SH_ARCH_MAGIC_WINCE) && \
36258945Sroberto  ((x).f_magic != SH_ARCH_MAGIC_LITTLE))
37258945Sroberto
38258945Sroberto/* Define some NT default values.  */
39258945Sroberto/*  #define NT_IMAGE_BASE        0x400000 moved to internal.h */
40258945Sroberto#define NT_SECTION_ALIGNMENT 0x1000
41258945Sroberto#define NT_FILE_ALIGNMENT    0x200
42258945Sroberto#define NT_DEF_RESERVE       0x100000
43258945Sroberto#define NT_DEF_COMMIT        0x1000
44258945Sroberto
45258945Sroberto/********************** RELOCATION DIRECTIVES **********************/
46258945Sroberto
47258945Sroberto/* The external reloc has an offset field, because some of the reloc
48258945Sroberto   types on the h8 don't have room in the instruction for the entire
49258945Sroberto   offset - eg the strange jump and high page addressing modes.  */
50258945Sroberto
51258945Sroberto#ifndef COFF_WITH_PE
52258945Srobertostruct external_reloc
53258945Sroberto{
54258945Sroberto  char r_vaddr[4];
55258945Sroberto  char r_symndx[4];
56258945Sroberto  char r_offset[4];
57258945Sroberto  char r_type[2];
58258945Sroberto  char r_stuff[2];
59258945Sroberto};
60258945Sroberto#else
61258945Srobertostruct external_reloc
62258945Sroberto{
63258945Sroberto  char r_vaddr[4];
64258945Sroberto  char r_symndx[4];
65258945Sroberto  char r_type[2];
66258945Sroberto};
67258945Sroberto#endif
68258945Sroberto
69258945Sroberto#define RELOC struct external_reloc
70258945Sroberto#ifdef COFF_WITH_PE
71258945Sroberto#define RELSZ 10
72258945Sroberto#else
73258945Sroberto#define RELSZ 16
74258945Sroberto#endif
75258945Sroberto
76258945Sroberto/* SH relocation types.  Not all of these are actually used.  */
77258945Sroberto
78258945Sroberto#define R_SH_UNUSED	0		/* only used internally */
79258945Sroberto#define R_SH_IMM32CE	2		/* 32 bit immediate for WinCE */
80258945Sroberto#define R_SH_PCREL8 	3		/*  8 bit pcrel 	*/
81258945Sroberto#define R_SH_PCREL16 	4		/* 16 bit pcrel 	*/
82258945Sroberto#define R_SH_HIGH8  	5		/* high 8 bits of 24 bit address */
83258945Sroberto#define R_SH_LOW16 	7		/* low 16 bits of 24 bit immediate */
84258945Sroberto#define R_SH_IMM24	6		/* 24 bit immediate */
85258945Sroberto#define R_SH_PCDISP8BY4	9  		/* PC rel 8 bits *4 +ve */
86258945Sroberto#define R_SH_PCDISP8BY2	10  		/* PC rel 8 bits *2 +ve */
87258945Sroberto#define R_SH_PCDISP8    11  		/* 8 bit branch */
88258945Sroberto#define R_SH_PCDISP     12  		/* 12 bit branch */
89258945Sroberto#define R_SH_IMM32      14    		/* 32 bit immediate */
90258945Sroberto#define R_SH_IMM8   	16		/* 8 bit immediate */
91258945Sroberto#define R_SH_IMAGEBASE	16		/* Windows CE */
92258945Sroberto#define R_SH_IMM8BY2    17		/* 8 bit immediate *2 */
93258945Sroberto#define R_SH_IMM8BY4    18		/* 8 bit immediate *4 */
94258945Sroberto#define R_SH_IMM4   	19		/* 4 bit immediate */
95258945Sroberto#define R_SH_IMM4BY2    20		/* 4 bit immediate *2 */
96258945Sroberto#define R_SH_IMM4BY4    21		/* 4 bit immediate *4 */
97258945Sroberto#define R_SH_PCRELIMM8BY2   22		/* PC rel 8 bits *2 unsigned */
98258945Sroberto#define R_SH_PCRELIMM8BY4   23		/* PC rel 8 bits *4 unsigned */
99258945Sroberto#define R_SH_IMM16      24    		/* 16 bit immediate */
100258945Sroberto
101258945Sroberto/* The switch table reloc types are used for relaxing.  They are
102258945Sroberto   generated for expressions such as
103258945Sroberto     .word L1 - L2
104258945Sroberto   The r_offset field holds the difference between the reloc address
105258945Sroberto   and L2.  */
106258945Sroberto#define R_SH_SWITCH8	33		/* 8 bit switch table entry */
107258945Sroberto#define R_SH_SWITCH16	25		/* 16 bit switch table entry */
108258945Sroberto#define R_SH_SWITCH32	26		/* 32 bit switch table entry */
109258945Sroberto
110258945Sroberto/* The USES reloc type is used for relaxing.  The compiler will
111258945Sroberto   generate .uses pseudo-ops when it finds a function call which it
112258945Sroberto   can relax.  The r_offset field of the USES reloc holds the PC
113258945Sroberto   relative offset to the instruction which loads the register used in
114258945Sroberto   the function call.  */
115258945Sroberto#define R_SH_USES	27		/* .uses pseudo-op */
116258945Sroberto
117258945Sroberto/* The COUNT reloc type is used for relaxing.  The assembler will
118258945Sroberto   generate COUNT relocs for addresses referred to by the register
119258945Sroberto   loads associated with USES relocs.  The r_offset field of the COUNT
120258945Sroberto   reloc holds the number of times the address is referenced in the
121258945Sroberto   object file.  */
122258945Sroberto#define R_SH_COUNT	28		/* Count of constant pool uses */
123258945Sroberto
124258945Sroberto/* The ALIGN reloc type is used for relaxing.  The r_offset field is
125258945Sroberto   the power of two to which subsequent portions of the object file
126258945Sroberto   must be aligned.  */
127258945Sroberto#define R_SH_ALIGN	29		/* .align pseudo-op */
128258945Sroberto
129258945Sroberto/* The CODE and DATA reloc types are used for aligning load and store
130258945Sroberto   instructions.  The assembler will generate a CODE reloc before a
131258945Sroberto   block of instructions.  It will generate a DATA reloc before data.
132258945Sroberto   A section should be processed assuming it contains data, unless a
133258945Sroberto   CODE reloc is seen.  The only relevant pieces of information in the
134258945Sroberto   CODE and DATA relocs are the section and the address.  The symbol
135258945Sroberto   and offset are meaningless.  */
136258945Sroberto#define R_SH_CODE	30		/* start of code */
137258945Sroberto#define R_SH_DATA	31		/* start of data */
138258945Sroberto
139258945Sroberto/* The LABEL reloc type is used for aligning load and store
140258945Sroberto   instructions.  The assembler will generate a LABEL reloc for each
141258945Sroberto   label within a block of instructions.  This permits the linker to
142258945Sroberto   avoid swapping instructions which are the targets of branches.  */
143258945Sroberto#define R_SH_LABEL	32		/* label */
144258945Sroberto
145258945Sroberto/* NB: R_SH_SWITCH8 is 33 */
146258945Sroberto
147258945Sroberto#define R_SH_LOOP_START	34
148258945Sroberto#define R_SH_LOOP_END	35
149258945Sroberto