184865Sobrien/* tc-ia64.h -- Header file for tc-ia64.c. 2218822Sdim Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 3218822Sdim Free Software Foundation, Inc. 484865Sobrien Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 584865Sobrien 684865Sobrien This file is part of GAS, the GNU Assembler. 784865Sobrien 884865Sobrien GAS is free software; you can redistribute it and/or modify 984865Sobrien it under the terms of the GNU General Public License as published by 1084865Sobrien the Free Software Foundation; either version 2, or (at your option) 1184865Sobrien any later version. 1284865Sobrien 1384865Sobrien GAS is distributed in the hope that it will be useful, 1484865Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1584865Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1684865Sobrien GNU General Public License for more details. 1784865Sobrien 1884865Sobrien You should have received a copy of the GNU General Public License 1984865Sobrien along with GAS; see the file COPYING. If not, write to 20218822Sdim the Free Software Foundation, 51 Franklin Street - Fifth Floor, 21218822Sdim Boston, MA 02110-1301, USA. */ 2284865Sobrien 23104834Sobrien#include "opcode/ia64.h" 24104834Sobrien#include "elf/ia64.h" 2584865Sobrien 2684865Sobrien#define TC_IA64 2784865Sobrien 2884865Sobrien/* Linux is little endian by default. HPUX is big endian by default. */ 2984865Sobrien#ifdef TE_HPUX 3084865Sobrien#define TARGET_BYTES_BIG_ENDIAN 1 3189857Sobrien#define MD_FLAGS_DEFAULT EF_IA_64_BE 3284865Sobrien#else 3384865Sobrien#define TARGET_BYTES_BIG_ENDIAN 0 3489857Sobrien#define MD_FLAGS_DEFAULT EF_IA_64_ABI64 3584865Sobrien#endif /* TE_HPUX */ 3684865Sobrien 37130561Sobrienextern void (*ia64_number_to_chars) PARAMS ((char *, valueT, int)); 38130561Sobrien#define md_number_to_chars (*ia64_number_to_chars) 39130561Sobrien 40130561Sobrienextern void ia64_elf_section_change_hook PARAMS ((void)); 41130561Sobrien#define md_elf_section_change_hook ia64_elf_section_change_hook 42130561Sobrien 43130561Sobrien/* We record the endian for this section. 0 means default, 1 means 44130561Sobrien big endian and 2 means little endian. */ 45130561Sobrienstruct ia64_segment_info_type 46130561Sobrien{ 47130561Sobrien unsigned int endian : 2; 48130561Sobrien}; 49130561Sobrien 50130561Sobrien#define TC_SEGMENT_INFO_TYPE struct ia64_segment_info_type 51130561Sobrien 52130561Sobrienextern void ia64_adjust_symtab PARAMS ((void)); 53130561Sobrien#define tc_adjust_symtab() ia64_adjust_symtab () 54130561Sobrien 55130561Sobrienextern void ia64_frob_file PARAMS ((void)); 56130561Sobrien#define tc_frob_file() ia64_frob_file () 57130561Sobrien 5884865Sobrien/* We need to set the default object file format in ia64_init and not in 5984865Sobrien md_begin. This is because parse_args is called before md_begin, and we 6084865Sobrien do not want md_begin to wipe out the flag settings set by options parsed in 6184865Sobrien md_parse_args. */ 6284865Sobrien 6384865Sobrien#define HOST_SPECIAL_INIT ia64_init 6484865Sobrienextern void ia64_init PARAMS ((int, char **)); 6584865Sobrien 6684865Sobrien#define TARGET_FORMAT ia64_target_format() 6784865Sobrienextern const char *ia64_target_format PARAMS ((void)); 6884865Sobrien 6984865Sobrien#define TARGET_ARCH bfd_arch_ia64 7084865Sobrien#define DOUBLESLASH_LINE_COMMENTS /* allow //-style comments */ 7184865Sobrien 7284865Sobrien#define NEED_LITERAL_POOL /* need gp literal pool */ 7384865Sobrien#define RELOC_REQUIRES_SYMBOL 7484865Sobrien#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */ 7584865Sobrien#define NEED_INDEX_OPERATOR /* [ ] is index operator */ 7684865Sobrien 7784865Sobrien#define QUOTES_IN_INSN /* allow `string "foo;bar"' */ 78218822Sdim#define LEX_AT (LEX_NAME|LEX_BEGIN_NAME) /* allow `@' inside name */ 79218822Sdim#define LEX_QM (LEX_NAME|LEX_BEGIN_NAME) /* allow `?' inside name */ 8084865Sobrien#define LEX_HASH LEX_END_NAME /* allow `#' ending a name */ 8184865Sobrien 82218822Sdimextern const char ia64_symbol_chars[]; 83218822Sdim#define tc_symbol_chars ia64_symbol_chars 84218822Sdim 85130561Sobrien#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0 86130561Sobrien 8784865Sobrienstruct ia64_fix 8884865Sobrien { 8984865Sobrien int bigendian; /* byte order at fix location */ 9084865Sobrien enum ia64_opnd opnd; 9184865Sobrien }; 9284865Sobrien 9384865Sobrienextern void ia64_end_of_source PARAMS((void)); 9484865Sobrienextern void ia64_start_line PARAMS((void)); 9584865Sobrienextern int ia64_unrecognized_line PARAMS((int ch)); 9684865Sobrienextern void ia64_frob_label PARAMS((struct symbol *sym)); 97130561Sobrien#ifdef TE_HPUX 98130561Sobrienextern int ia64_frob_symbol PARAMS((struct symbol *sym)); 99130561Sobrien#endif 10084865Sobrienextern void ia64_flush_pending_output PARAMS((void)); 101218822Sdimextern int ia64_parse_name PARAMS((char *name, expressionS *e, char *nextP)); 10284865Sobrienextern int ia64_optimize_expr PARAMS((expressionS *l, operatorT op, 10384865Sobrien expressionS *r)); 10484865Sobrienextern void ia64_cons_align PARAMS((int)); 10584865Sobrienextern void ia64_flush_insns PARAMS((void)); 10684865Sobrienextern int ia64_fix_adjustable PARAMS((struct fix *fix)); 10784865Sobrienextern int ia64_force_relocation PARAMS((struct fix *)); 10884865Sobrienextern void ia64_cons_fix_new PARAMS ((fragS *f, int where, int nbytes, 10984865Sobrien expressionS *exp)); 11084865Sobrienextern void ia64_validate_fix PARAMS ((struct fix *fix)); 11184865Sobrienextern char * ia64_canonicalize_symbol_name PARAMS ((char *)); 11289857Sobrienextern int ia64_elf_section_letter PARAMS ((int, char **)); 11384865Sobrienextern flagword ia64_elf_section_flags PARAMS ((flagword, int, int)); 11484865Sobrienextern int ia64_elf_section_type PARAMS ((const char *, size_t len)); 11584865Sobrienextern long ia64_pcrel_from_section PARAMS ((struct fix *fix, segT sec)); 11684865Sobrienextern void ia64_md_do_align PARAMS ((int, const char *, int, int)); 11784865Sobrienextern void ia64_handle_align PARAMS ((fragS *f)); 11889857Sobrienextern void ia64_after_parse_args PARAMS ((void)); 119130561Sobrienextern void ia64_dwarf2_emit_offset PARAMS ((symbolS *, unsigned int)); 120130561Sobrienextern void ia64_check_label PARAMS ((symbolS *)); 121130561Sobrienextern int ia64_estimate_size_before_relax (fragS *, asection *); 122130561Sobrienextern void ia64_convert_frag (fragS *); 12384865Sobrien 12484865Sobrien#define md_end() ia64_end_of_source () 12584865Sobrien#define md_start_line_hook() ia64_start_line () 12684865Sobrien#define tc_unrecognized_line(ch) ia64_unrecognized_line (ch) 12784865Sobrien#define tc_frob_label(s) ia64_frob_label (s) 128130561Sobrien#ifdef TE_HPUX 129130561Sobrien#define tc_frob_symbol(s,p) p |= ia64_frob_symbol (s) 130130561Sobrien#endif /* TE_HPUX */ 13184865Sobrien#define md_flush_pending_output() ia64_flush_pending_output () 132218822Sdim#define md_parse_name(s,e,m,c) ia64_parse_name (s, e, c) 13384865Sobrien#define tc_canonicalize_symbol_name(s) ia64_canonicalize_symbol_name (s) 134130561Sobrien#define tc_canonicalize_section_name(s) ia64_canonicalize_symbol_name (s) 13584865Sobrien#define md_optimize_expr(l,o,r) ia64_optimize_expr (l, o, r) 13684865Sobrien#define md_cons_align(n) ia64_cons_align (n) 13784865Sobrien#define TC_FORCE_RELOCATION(f) ia64_force_relocation (f) 13884865Sobrien#define tc_fix_adjustable(f) ia64_fix_adjustable (f) 139130561Sobrien#define MD_APPLY_SYM_VALUE(FIX) 0 140130561Sobrien#define md_convert_frag(b,s,f) ia64_convert_frag (f) 14189857Sobrien#define md_create_long_jump(p,f,t,fr,s) as_fatal ("ia64_create_long_jump") 14284865Sobrien#define md_create_short_jump(p,f,t,fr,s) \ 14389857Sobrien as_fatal ("ia64_create_short_jump") 14484865Sobrien#define md_estimate_size_before_relax(f,s) \ 145130561Sobrien ia64_estimate_size_before_relax(f,s) 14689857Sobrien#define md_elf_section_letter ia64_elf_section_letter 14784865Sobrien#define md_elf_section_flags ia64_elf_section_flags 14884865Sobrien#define TC_FIX_TYPE struct ia64_fix 14984865Sobrien#define TC_INIT_FIX_DATA(f) { f->tc_fix_data.opnd = 0; } 15084865Sobrien#define TC_CONS_FIX_NEW(f,o,l,e) ia64_cons_fix_new (f, o, l, e) 15184865Sobrien#define TC_VALIDATE_FIX(fix,seg,skip) ia64_validate_fix (fix) 15284865Sobrien#define MD_PCREL_FROM_SECTION(fix,sec) ia64_pcrel_from_section (fix, sec) 153130561Sobrien#define md_section_align(seg,size) (size) 15484865Sobrien#define md_do_align(n,f,l,m,j) ia64_md_do_align (n,f,l,m) 15584865Sobrien#define HANDLE_ALIGN(f) ia64_handle_align (f) 15684865Sobrien#define md_elf_section_type(str,len) ia64_elf_section_type (str, len) 15789857Sobrien#define md_after_parse_args() ia64_after_parse_args () 158130561Sobrien#define TC_DWARF2_EMIT_OFFSET ia64_dwarf2_emit_offset 159130561Sobrien#define tc_check_label(l) ia64_check_label (l) 16084865Sobrien 161130561Sobrien/* Record if an alignment frag should end with a stop bit. */ 162130561Sobrien#define TC_FRAG_TYPE int 163130561Sobrien#define TC_FRAG_INIT(FRAGP) do {(FRAGP)->tc_frag_data = 0;}while (0) 164130561Sobrien 165218822Sdim/* Give an error if a frag containing code is not aligned to a 16 byte 166218822Sdim boundary. */ 167218822Sdim#define md_frag_check(FRAGP) \ 168218822Sdim if ((FRAGP)->has_code \ 169218822Sdim && (((FRAGP)->fr_address + (FRAGP)->insn_addr) & 15) != 0) \ 170218822Sdim as_bad_where ((FRAGP)->fr_file, (FRAGP)->fr_line, \ 171218822Sdim _("instruction address is not a multiple of 16")); 172218822Sdim 17384865Sobrien#define MAX_MEM_FOR_RS_ALIGN_CODE (15 + 16) 17484865Sobrien 17584865Sobrien#define WORKING_DOT_WORD /* don't do broken word processing for now */ 17684865Sobrien 17784865Sobrien#define DWARF2_LINE_MIN_INSN_LENGTH 1 /* so slot-multipliers can be 1 */ 17884865Sobrien 17984865Sobrien/* This is the information required for unwind records in an ia64 18084865Sobrien object file. This is required by GAS and the compiler runtime. */ 18184865Sobrien 18284865Sobrien/* These are the starting point masks for the various types of 18384865Sobrien unwind records. To create a record of type R3 for instance, one 18484865Sobrien starts by using the value UNW_R3 and or-ing in any other required values. 18584865Sobrien These values are also unique (in context), so they can be used to identify 18684865Sobrien the various record types as well. UNW_Bx and some UNW_Px do have the 18784865Sobrien same value, but Px can only occur in a prologue context, and Bx in 18884865Sobrien a body context. */ 18984865Sobrien 19084865Sobrien#define UNW_R1 0x00 19184865Sobrien#define UNW_R2 0x40 19284865Sobrien#define UNW_R3 0x60 19384865Sobrien#define UNW_P1 0x80 19484865Sobrien#define UNW_P2 0xA0 19584865Sobrien#define UNW_P3 0xB0 19684865Sobrien#define UNW_P4 0xB8 19784865Sobrien#define UNW_P5 0xB9 19884865Sobrien#define UNW_P6 0xC0 19984865Sobrien#define UNW_P7 0xE0 20084865Sobrien#define UNW_P8 0xF0 20184865Sobrien#define UNW_P9 0xF1 20284865Sobrien#define UNW_P10 0xFF 20384865Sobrien#define UNW_X1 0xF9 20484865Sobrien#define UNW_X2 0xFA 20584865Sobrien#define UNW_X3 0xFB 20684865Sobrien#define UNW_X4 0xFC 20784865Sobrien#define UNW_B1 0x80 20884865Sobrien#define UNW_B2 0xC0 20984865Sobrien#define UNW_B3 0xE0 21084865Sobrien#define UNW_B4 0xF0 21184865Sobrien 21284865Sobrien/* These are all the various types of unwind records. */ 21384865Sobrien 21484865Sobrientypedef enum 21584865Sobrien{ 21684865Sobrien prologue, prologue_gr, body, mem_stack_f, mem_stack_v, psp_gr, psp_sprel, 21784865Sobrien rp_when, rp_gr, rp_br, rp_psprel, rp_sprel, pfs_when, pfs_gr, pfs_psprel, 21884865Sobrien pfs_sprel, preds_when, preds_gr, preds_psprel, preds_sprel, 21984865Sobrien fr_mem, frgr_mem, gr_gr, gr_mem, br_mem, br_gr, spill_base, spill_mask, 22084865Sobrien unat_when, unat_gr, unat_psprel, unat_sprel, lc_when, lc_gr, lc_psprel, 22184865Sobrien lc_sprel, fpsr_when, fpsr_gr, fpsr_psprel, fpsr_sprel, 22284865Sobrien priunat_when_gr, priunat_when_mem, priunat_gr, priunat_psprel, 22384865Sobrien priunat_sprel, bsp_when, bsp_gr, bsp_psprel, bsp_sprel, bspstore_when, 22484865Sobrien bspstore_gr, bspstore_psprel, bspstore_sprel, rnat_when, rnat_gr, 22584865Sobrien rnat_psprel, rnat_sprel, epilogue, label_state, copy_state, 22684865Sobrien spill_psprel, spill_sprel, spill_reg, spill_psprel_p, spill_sprel_p, 227130561Sobrien spill_reg_p, unwabi, endp 22884865Sobrien} unw_record_type; 22984865Sobrien 23084865Sobrien/* These structures declare the fields that can be used in each of the 23184865Sobrien 4 record formats, R, P, B and X. */ 23284865Sobrien 23384865Sobrientypedef struct unw_r_record 23484865Sobrien{ 23584865Sobrien unsigned long rlen; 23684865Sobrien unsigned short grmask; 23784865Sobrien unsigned short grsave; 23884865Sobrien /* masks to represent the union of save.g, save.f, save.b, and 23984865Sobrien save.gf: */ 24084865Sobrien unsigned long imask_size; 24184865Sobrien struct 24284865Sobrien { 24384865Sobrien unsigned char *i; 244218822Sdim unsigned int fr_mem; 24584865Sobrien unsigned char gr_mem; 24684865Sobrien unsigned char br_mem; 24784865Sobrien } mask; 24884865Sobrien} unw_r_record; 24984865Sobrien 25084865Sobrientypedef struct unw_p_record 25184865Sobrien{ 252218822Sdim struct unw_rec_list *next; 25384865Sobrien unsigned long t; 25484865Sobrien unsigned long size; 255218822Sdim union 256218822Sdim { 257218822Sdim unsigned long sp; 258218822Sdim unsigned long psp; 259218822Sdim } off; 260218822Sdim union 261218822Sdim { 262218822Sdim unsigned short gr; 263218822Sdim unsigned short br; 264218822Sdim } r; 265218822Sdim unsigned char grmask; 266218822Sdim unsigned char brmask; 267218822Sdim unsigned int frmask; 26884865Sobrien unsigned char abi; 26984865Sobrien unsigned char context; 27084865Sobrien} unw_p_record; 27184865Sobrien 27284865Sobrientypedef struct unw_b_record 27384865Sobrien{ 27484865Sobrien unsigned long t; 27584865Sobrien unsigned long label; 27684865Sobrien unsigned short ecount; 27784865Sobrien} unw_b_record; 27884865Sobrien 27984865Sobrientypedef struct unw_x_record 28084865Sobrien{ 28184865Sobrien unsigned long t; 282218822Sdim union 283218822Sdim { 284218822Sdim unsigned long spoff; 285218822Sdim unsigned long pspoff; 286218822Sdim unsigned int reg; 287218822Sdim } where; 28884865Sobrien unsigned short reg; 28984865Sobrien unsigned short qp; 29084865Sobrien unsigned short ab; /* Value of the AB field.. */ 29184865Sobrien unsigned short xy; /* Value of the XY field.. */ 29284865Sobrien} unw_x_record; 29384865Sobrien 29484865Sobrien/* This structure is used to determine the specific record type and 29584865Sobrien its fields. */ 29684865Sobrientypedef struct unwind_record 29784865Sobrien{ 29884865Sobrien unw_record_type type; 29984865Sobrien union { 30084865Sobrien unw_r_record r; 30184865Sobrien unw_p_record p; 30284865Sobrien unw_b_record b; 30384865Sobrien unw_x_record x; 30484865Sobrien } record; 30584865Sobrien} unwind_record; 30684865Sobrien 307130561Sobrien/* This expression evaluates to true if the relocation is for a local 30884865Sobrien object for which we still want to do the relocation at runtime. 309130561Sobrien False if we are willing to perform this relocation while building 310130561Sobrien the .o file. */ 31184865Sobrien 31289857Sobrien/* If the reloc type is BFD_RELOC_UNUSED, then this is for a TAG13/TAG13b field 31389857Sobrien which has no external reloc, so we must resolve the value now. */ 31489857Sobrien 315130561Sobrien#define TC_FORCE_RELOCATION_LOCAL(FIX) \ 316130561Sobrien ((FIX)->fx_r_type != BFD_RELOC_UNUSED \ 317130561Sobrien && (!(FIX)->fx_pcrel \ 318218822Sdim || (FIX)->fx_r_type == BFD_RELOC_IA64_PLTOFF22 \ 319130561Sobrien || TC_FORCE_RELOCATION (FIX))) 320