12061Sjkh/* tc-ia64.h -- Header file for tc-ia64.c. 250479Speter Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 32061Sjkh Free Software Foundation, Inc. 438666Sjb Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 532427Sjb 6111131Sru This file is part of GAS, the GNU Assembler. 7111131Sru 838666Sjb GAS is free software; you can redistribute it and/or modify 938666Sjb it under the terms of the GNU General Public License as published by 1038666Sjb the Free Software Foundation; either version 2, or (at your option) 11159363Strhodes any later version. 1264049Salex 1364049Salex GAS is distributed in the hope that it will be useful, 14116679Ssimokawa but WITHOUT ANY WARRANTY; without even the implied warranty of 1566071Smarkm MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16116679Ssimokawa GNU General Public License for more details. 1773504Sobrien 18204661Simp You should have received a copy of the GNU General Public License 19158962Snetchild along with GAS; see the file COPYING. If not, write to 2038666Sjb the Free Software Foundation, 51 Franklin Street - Fifth Floor, 21169597Sdes Boston, MA 02110-1301, USA. */ 22169597Sdes 23169597Sdes#include "opcode/ia64.h" 24169597Sdes#include "elf/ia64.h" 25169597Sdes 26169597Sdes#define TC_IA64 27169597Sdes 28169597Sdes/* Linux is little endian by default. HPUX is big endian by default. */ 2932427Sjb#ifdef TE_HPUX 3038666Sjb#define TARGET_BYTES_BIG_ENDIAN 1 31108451Sschweikh#define MD_FLAGS_DEFAULT EF_IA_64_BE 3238666Sjb#else 3338666Sjb#define TARGET_BYTES_BIG_ENDIAN 0 3438666Sjb#define MD_FLAGS_DEFAULT EF_IA_64_ABI64 3538666Sjb#endif /* TE_HPUX */ 3617308Speter 3791606Skeramidaextern void (*ia64_number_to_chars) PARAMS ((char *, valueT, int)); 3819175Sbde#define md_number_to_chars (*ia64_number_to_chars) 3996205Sjwd 40177794Spavextern void ia64_elf_section_change_hook PARAMS ((void)); 4138042Sbde#define md_elf_section_change_hook ia64_elf_section_change_hook 4296205Sjwd 4396205Sjwd/* We record the endian for this section. 0 means default, 1 means 4438042Sbde big endian and 2 means little endian. */ 4596205Sjwdstruct ia64_segment_info_type 46159363Strhodes{ 47159363Strhodes unsigned int endian : 2; 4817308Speter}; 4996205Sjwd 5096205Sjwd#define TC_SEGMENT_INFO_TYPE struct ia64_segment_info_type 5117308Speter 52148330Snetchildextern void ia64_adjust_symtab PARAMS ((void)); 53148330Snetchild#define tc_adjust_symtab() ia64_adjust_symtab () 54148330Snetchild 55148330Snetchildextern void ia64_frob_file PARAMS ((void)); 56159831Sobrien#define tc_frob_file() ia64_frob_file () 57148330Snetchild 58148330Snetchild/* We need to set the default object file format in ia64_init and not in 59148330Snetchild md_begin. This is because parse_args is called before md_begin, and we 60148330Snetchild do not want md_begin to wipe out the flag settings set by options parsed in 61178653Srwatson md_parse_args. */ 62148330Snetchild 63148330Snetchild#define HOST_SPECIAL_INIT ia64_init 6496205Sjwdextern void ia64_init PARAMS ((int, char **)); 6596205Sjwd 6696205Sjwd#define TARGET_FORMAT ia64_target_format() 67162147Sruextern const char *ia64_target_format PARAMS ((void)); 68162147Sru 6998723Sdillon#define TARGET_ARCH bfd_arch_ia64 7098723Sdillon#define DOUBLESLASH_LINE_COMMENTS /* allow //-style comments */ 7198723Sdillon 7238666Sjb#define NEED_LITERAL_POOL /* need gp literal pool */ 7338666Sjb#define RELOC_REQUIRES_SYMBOL 7417308Speter#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */ 75123311Speter#define NEED_INDEX_OPERATOR /* [ ] is index operator */ 76123311Speter 77123311Speter#define QUOTES_IN_INSN /* allow `string "foo;bar"' */ 78123311Speter#define LEX_AT (LEX_NAME|LEX_BEGIN_NAME) /* allow `@' inside name */ 79175833Sjhb#define LEX_QM (LEX_NAME|LEX_BEGIN_NAME) /* allow `?' inside name */ 80175833Sjhb#define LEX_HASH LEX_END_NAME /* allow `#' ending a name */ 81169597Sdes 82169597Sdesextern const char ia64_symbol_chars[]; 83169597Sdes#define tc_symbol_chars ia64_symbol_chars 84169597Sdes 85159349Simp#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0 86158962Snetchild 87158962Snetchildstruct ia64_fix 88158962Snetchild { 89156840Sru int bigendian; /* byte order at fix location */ 90123311Speter enum ia64_opnd opnd; 91137288Speter }; 92209128Sraj 93209128Srajextern void ia64_end_of_source PARAMS((void)); 94156740Sruextern void ia64_start_line PARAMS((void)); 952061Sjkhextern int ia64_unrecognized_line PARAMS((int ch)); 9697769Sruextern void ia64_frob_label PARAMS((struct symbol *sym)); 9797252Sru#ifdef TE_HPUX 98119579Sruextern int ia64_frob_symbol PARAMS((struct symbol *sym)); 9997252Sru#endif 10095730Sruextern void ia64_flush_pending_output PARAMS((void)); 10195793Sruextern int ia64_parse_name PARAMS((char *name, expressionS *e, char *nextP)); 102111617Sruextern int ia64_optimize_expr PARAMS((expressionS *l, operatorT op, 10395730Sru expressionS *r)); 104116679Ssimokawaextern void ia64_cons_align PARAMS((int)); 10595730Sruextern void ia64_flush_insns PARAMS((void)); 106116679Ssimokawaextern int ia64_fix_adjustable PARAMS((struct fix *fix)); 10795730Sruextern int ia64_force_relocation PARAMS((struct fix *)); 108110035Sruextern void ia64_cons_fix_new PARAMS ((fragS *f, int where, int nbytes, 109107516Sru expressionS *exp)); 110138921Sruextern void ia64_validate_fix PARAMS ((struct fix *fix)); 111156145Syarextern char * ia64_canonicalize_symbol_name PARAMS ((char *)); 112138921Sruextern int ia64_elf_section_letter PARAMS ((int, char **)); 113133942Sruextern flagword ia64_elf_section_flags PARAMS ((flagword, int, int)); 114133942Sruextern int ia64_elf_section_type PARAMS ((const char *, size_t len)); 115156145Syarextern long ia64_pcrel_from_section PARAMS ((struct fix *fix, segT sec)); 116133942Sruextern void ia64_md_do_align PARAMS ((int, const char *, int, int)); 117110035Sruextern void ia64_handle_align PARAMS ((fragS *f)); 118117234Sruextern void ia64_after_parse_args PARAMS ((void)); 119110035Sruextern void ia64_dwarf2_emit_offset PARAMS ((symbolS *, unsigned int)); 120117229Sruextern void ia64_check_label PARAMS ((symbolS *)); 121117234Sruextern int ia64_estimate_size_before_relax (fragS *, asection *); 12254324Smarcelextern void ia64_convert_frag (fragS *); 12317308Speter 124119519Smarcel#define md_end() ia64_end_of_source () 125119519Smarcel#define md_start_line_hook() ia64_start_line () 126119519Smarcel#define tc_unrecognized_line(ch) ia64_unrecognized_line (ch) 127119519Smarcel#define tc_frob_label(s) ia64_frob_label (s) 128119519Smarcel#ifdef TE_HPUX 129119519Smarcel#define tc_frob_symbol(s,p) p |= ia64_frob_symbol (s) 130119579Sru#endif /* TE_HPUX */ 131119519Smarcel#define md_flush_pending_output() ia64_flush_pending_output () 132119519Smarcel#define md_parse_name(s,e,m,c) ia64_parse_name (s, e, c) 133119519Smarcel#define tc_canonicalize_symbol_name(s) ia64_canonicalize_symbol_name (s) 134119519Smarcel#define tc_canonicalize_section_name(s) ia64_canonicalize_symbol_name (s) 135119519Smarcel#define md_optimize_expr(l,o,r) ia64_optimize_expr (l, o, r) 136126031Sgad#define md_cons_align(n) ia64_cons_align (n) 137126024Sgad#define TC_FORCE_RELOCATION(f) ia64_force_relocation (f) 138126024Sgad#define tc_fix_adjustable(f) ia64_fix_adjustable (f) 139126024Sgad#define MD_APPLY_SYM_VALUE(FIX) 0 140126024Sgad#define md_convert_frag(b,s,f) ia64_convert_frag (f) 141126024Sgad#define md_create_long_jump(p,f,t,fr,s) as_fatal ("ia64_create_long_jump") 142126024Sgad#define md_create_short_jump(p,f,t,fr,s) \ 143126024Sgad as_fatal ("ia64_create_short_jump") 144126024Sgad#define md_estimate_size_before_relax(f,s) \ 145126024Sgad ia64_estimate_size_before_relax(f,s) 146126024Sgad#define md_elf_section_letter ia64_elf_section_letter 147126024Sgad#define md_elf_section_flags ia64_elf_section_flags 148126024Sgad#define TC_FIX_TYPE struct ia64_fix 149126024Sgad#define TC_INIT_FIX_DATA(f) { f->tc_fix_data.opnd = 0; } 150126031Sgad#define TC_CONS_FIX_NEW(f,o,l,e) ia64_cons_fix_new (f, o, l, e) 151126024Sgad#define TC_VALIDATE_FIX(fix,seg,skip) ia64_validate_fix (fix) 152126024Sgad#define MD_PCREL_FROM_SECTION(fix,sec) ia64_pcrel_from_section (fix, sec) 153126024Sgad#define md_section_align(seg,size) (size) 154172744Sdelphij#define md_do_align(n,f,l,m,j) ia64_md_do_align (n,f,l,m) 155126024Sgad#define HANDLE_ALIGN(f) ia64_handle_align (f) 156126024Sgad#define md_elf_section_type(str,len) ia64_elf_section_type (str, len) 157126024Sgad#define md_after_parse_args() ia64_after_parse_args () 158133376Sharti#define TC_DWARF2_EMIT_OFFSET ia64_dwarf2_emit_offset 159126024Sgad#define tc_check_label(l) ia64_check_label (l) 160126024Sgad 161172744Sdelphij/* Record if an alignment frag should end with a stop bit. */ 162126024Sgad#define TC_FRAG_TYPE int 163126024Sgad#define TC_FRAG_INIT(FRAGP) do {(FRAGP)->tc_frag_data = 0;}while (0) 164125885Sgad 165125885Sgad/* Give an error if a frag containing code is not aligned to a 16 byte 16638666Sjb boundary. */ 16717308Speter#define md_frag_check(FRAGP) \ 168119519Smarcel if ((FRAGP)->has_code \ 169119579Sru && (((FRAGP)->fr_address + (FRAGP)->insn_addr) & 15) != 0) \ 170133376Sharti as_bad_where ((FRAGP)->fr_file, (FRAGP)->fr_line, \ 171110035Sru _("instruction address is not a multiple of 16")); 1722302Spaul 17339206Sjkh#define MAX_MEM_FOR_RS_ALIGN_CODE (15 + 16) 17439206Sjkh 17539206Sjkh#define WORKING_DOT_WORD /* don't do broken word processing for now */ 176133945Sru 177177609Sru#define DWARF2_LINE_MIN_INSN_LENGTH 1 /* so slot-multipliers can be 1 */ 178177609Sru 179177609Sru/* This is the information required for unwind records in an ia64 180177609Sru object file. This is required by GAS and the compiler runtime. */ 181133945Sru 182132358Smarkm/* These are the starting point masks for the various types of 18317308Speter unwind records. To create a record of type R3 for instance, one 18454324Smarcel starts by using the value UNW_R3 and or-ing in any other required values. 18554324Smarcel These values are also unique (in context), so they can be used to identify 186132234Smarcel the various record types as well. UNW_Bx and some UNW_Px do have the 187132234Smarcel same value, but Px can only occur in a prologue context, and Bx in 188132234Smarcel a body context. */ 189132234Smarcel 19054324Smarcel#define UNW_R1 0x00 19154324Smarcel#define UNW_R2 0x40 19254324Smarcel#define UNW_R3 0x60 193118531Sru#define UNW_P1 0x80 19454324Smarcel#define UNW_P2 0xA0 19554324Smarcel#define UNW_P3 0xB0 19654324Smarcel#define UNW_P4 0xB8 19754324Smarcel#define UNW_P5 0xB9 19854324Smarcel#define UNW_P6 0xC0 19954324Smarcel#define UNW_P7 0xE0 200133376Sharti#define UNW_P8 0xF0 20154324Smarcel#define UNW_P9 0xF1 202133376Sharti#define UNW_P10 0xFF 203133376Sharti#define UNW_X1 0xF9 20454324Smarcel#define UNW_X2 0xFA 20554324Smarcel#define UNW_X3 0xFB 20654324Smarcel#define UNW_X4 0xFC 20754324Smarcel#define UNW_B1 0x80 20854324Smarcel#define UNW_B2 0xC0 209133376Sharti#define UNW_B3 0xE0 21054324Smarcel#define UNW_B4 0xF0 21154324Smarcel 21254324Smarcel/* These are all the various types of unwind records. */ 213118531Sru 214118531Srutypedef enum 21554324Smarcel{ 216132234Smarcel prologue, prologue_gr, body, mem_stack_f, mem_stack_v, psp_gr, psp_sprel, 217132234Smarcel rp_when, rp_gr, rp_br, rp_psprel, rp_sprel, pfs_when, pfs_gr, pfs_psprel, 218132234Smarcel pfs_sprel, preds_when, preds_gr, preds_psprel, preds_sprel, 219132234Smarcel fr_mem, frgr_mem, gr_gr, gr_mem, br_mem, br_gr, spill_base, spill_mask, 220132234Smarcel unat_when, unat_gr, unat_psprel, unat_sprel, lc_when, lc_gr, lc_psprel, 221132588Skensmith lc_sprel, fpsr_when, fpsr_gr, fpsr_psprel, fpsr_sprel, 222132358Smarkm priunat_when_gr, priunat_when_mem, priunat_gr, priunat_psprel, 223132234Smarcel priunat_sprel, bsp_when, bsp_gr, bsp_psprel, bsp_sprel, bspstore_when, 224132358Smarkm bspstore_gr, bspstore_psprel, bspstore_sprel, rnat_when, rnat_gr, 225132234Smarcel rnat_psprel, rnat_sprel, epilogue, label_state, copy_state, 226132234Smarcel spill_psprel, spill_sprel, spill_reg, spill_psprel_p, spill_sprel_p, 227132234Smarcel spill_reg_p, unwabi, endp 22854324Smarcel} unw_record_type; 22954324Smarcel 23095730Sru/* These structures declare the fields that can be used in each of the 23195730Sru 4 record formats, R, P, B and X. */ 23295730Sru 23395730Srutypedef struct unw_r_record 23495730Sru{ 23595730Sru unsigned long rlen; 23695730Sru unsigned short grmask; 23738666Sjb unsigned short grsave; 238107374Sru /* masks to represent the union of save.g, save.f, save.b, and 23917308Speter save.gf: */ 24055678Smarcel unsigned long imask_size; 241143032Sharti struct 242138515Sharti { 243117793Sru unsigned char *i; 244110035Sru unsigned int fr_mem; 245174564Simp unsigned char gr_mem; 246110035Sru unsigned char br_mem; 2472061Sjkh } mask; 24817308Speter} unw_r_record; 249107516Sru 250174539Simptypedef struct unw_p_record 251174539Simp{ 25255678Smarcel struct unw_rec_list *next; 253107516Sru unsigned long t; 254107516Sru unsigned long size; 255107516Sru union 256174564Simp { 257107516Sru unsigned long sp; 258139112Sru unsigned long psp; 259164470Sjb } off; 260107516Sru union 261122204Skris { 26255678Smarcel unsigned short gr; 26355678Smarcel unsigned short br; 264116696Sru } r; 26555678Smarcel unsigned char grmask; 266133376Sharti unsigned char brmask; 267107516Sru unsigned int frmask; 268107516Sru unsigned char abi; 269107516Sru unsigned char context; 270107516Sru} unw_p_record; 27155678Smarcel 272185499Salfredtypedef struct unw_b_record 273185499Salfred{ 274216487Sjhb unsigned long t; 275185499Salfred unsigned long label; 27655678Smarcel unsigned short ecount; 277111131Sru} unw_b_record; 278111131Sru 279111131Srutypedef struct unw_x_record 280133945Sru{ 281111131Sru unsigned long t; 282111131Sru union 283201815Sbz { 284216520Snwhitehorn unsigned long spoff; 285216520Snwhitehorn unsigned long pspoff; 286217123Simp unsigned int reg; 287216520Snwhitehorn } where; 288216520Snwhitehorn unsigned short reg; 289216520Snwhitehorn unsigned short qp; 290216520Snwhitehorn unsigned short ab; /* Value of the AB field.. */ 291216520Snwhitehorn unsigned short xy; /* Value of the XY field.. */ 292216520Snwhitehorn} unw_x_record; 293168280Smarcel 294185499Salfred/* This structure is used to determine the specific record type and 295185499Salfred its fields. */ 296185499Salfredtypedef struct unwind_record 297185499Salfred{ 298185499Salfred unw_record_type type; 299185499Salfred union { 300185499Salfred unw_r_record r; 301133945Sru unw_p_record p; 302133945Sru unw_b_record b; 303103985Sphk unw_x_record x; 304103985Sphk } record; 305103985Sphk} unwind_record; 306185499Salfred 307185499Salfred/* This expression evaluates to true if the relocation is for a local 308185499Salfred object for which we still want to do the relocation at runtime. 309168280Smarcel False if we are willing to perform this relocation while building 310162147Sru the .o file. */ 311162147Sru 312216520Snwhitehorn/* If the reloc type is BFD_RELOC_UNUSED, then this is for a TAG13/TAG13b field 313216520Snwhitehorn which has no external reloc, so we must resolve the value now. */ 314216520Snwhitehorn 315179232Sjb#define TC_FORCE_RELOCATION_LOCAL(FIX) \ 316216520Snwhitehorn ((FIX)->fx_r_type != BFD_RELOC_UNUSED \ 317216520Snwhitehorn && (!(FIX)->fx_pcrel \ 318216520Snwhitehorn || (FIX)->fx_r_type == BFD_RELOC_IA64_PLTOFF22 \ 319216520Snwhitehorn || TC_FORCE_RELOCATION (FIX))) 320185250Sdes