tc-i386.h revision 256281
14Srgrimes/* tc-i386.h -- Header file for tc-i386.c 245720Speter Copyright 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 34Srgrimes 2001, 2002, 2003, 2004, 2005, 2006, 2007 44Srgrimes Free Software Foundation, Inc. 54Srgrimes 64Srgrimes This file is part of GAS, the GNU Assembler. 74Srgrimes 84Srgrimes GAS is free software; you can redistribute it and/or modify 94Srgrimes it under the terms of the GNU General Public License as published by 104Srgrimes the Free Software Foundation; either version 2, or (at your option) 114Srgrimes any later version. 124Srgrimes 134Srgrimes GAS is distributed in the hope that it will be useful, 1445720Speter but WITHOUT ANY WARRANTY; without even the implied warranty of 154Srgrimes MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 164Srgrimes GNU General Public License for more details. 1745720Speter 184Srgrimes You should have received a copy of the GNU General Public License 194Srgrimes along with GAS; see the file COPYING. If not, write to the Free 204Srgrimes Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 214Srgrimes 02110-1301, USA. */ 224Srgrimes 234Srgrimes#ifndef TC_I386 244Srgrimes#define TC_I386 1 254Srgrimes 264Srgrimes#include "opcodes/i386-opc.h" 27115703Sobrien 28115703Sobrienstruct fix; 29115703Sobrien 304Srgrimes#define TARGET_BYTES_BIG_ENDIAN 0 3145720Speter 3245720Speter#define TARGET_ARCH bfd_arch_i386 334Srgrimes#define TARGET_MACH (i386_mach ()) 3445720Speterextern unsigned long i386_mach (void); 3545720Speter 3645720Speter#ifdef TE_FreeBSD 3745720Speter#define AOUT_TARGET_FORMAT "a.out-i386-freebsd" 3845720Speter#endif 3945720Speter#ifdef TE_NetBSD 4045720Speter#define AOUT_TARGET_FORMAT "a.out-i386-netbsd" 4145720Speter#endif 4245720Speter#ifdef TE_386BSD 4345720Speter#define AOUT_TARGET_FORMAT "a.out-i386-bsd" 4445720Speter#endif 4545720Speter#ifdef TE_LINUX 4645720Speter#define AOUT_TARGET_FORMAT "a.out-i386-linux" 4745720Speter#endif 4845720Speter#ifdef TE_Mach 4945720Speter#define AOUT_TARGET_FORMAT "a.out-mach3" 5045720Speter#endif 5145720Speter#ifdef TE_DYNIX 5245720Speter#define AOUT_TARGET_FORMAT "a.out-i386-dynix" 5345720Speter#endif 5445720Speter#ifndef AOUT_TARGET_FORMAT 5545720Speter#define AOUT_TARGET_FORMAT "a.out-i386" 5645720Speter#endif 5745720Speter 584Srgrimes#ifdef TE_FreeBSD 594Srgrimes#define ELF_TARGET_FORMAT "elf32-i386-freebsd" 602056Swollman#define ELF_TARGET_FORMAT64 "elf64-x86-64-freebsd" 6145720Speter#elif defined (TE_VXWORKS) 622056Swollman#define ELF_TARGET_FORMAT "elf32-i386-vxworks" 6345720Speter#endif 6458762Skato 6590466Snyan#ifndef ELF_TARGET_FORMAT 6690466Snyan#define ELF_TARGET_FORMAT "elf32-i386" 6790466Snyan#endif 684Srgrimes 6945720Speter#ifndef ELF_TARGET_FORMAT64 7026157Sse#define ELF_TARGET_FORMAT64 "elf64-x86-64" 7145720Speter#endif 7247398Sdfr 7329613Sjmg#if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \ 7447398Sdfr || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) 7588376Stmmextern const char *i386_target_format (void); 7631457Sjmg#define TARGET_FORMAT i386_target_format () 773258Sdg#else 788876Srgrimes#ifdef OBJ_ELF 7947178Sdfr#define TARGET_FORMAT ELF_TARGET_FORMAT 8045720Speter#endif 8145720Speter#ifdef OBJ_AOUT 8245720Speter#define TARGET_FORMAT AOUT_TARGET_FORMAT 8345720Speter#endif 8445720Speter#endif 8545720Speter 8615147Ssmpatel#if (defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF)) 8747398Sdfr#define md_end i386_elf_emit_arch_note 8845720Speterextern void i386_elf_emit_arch_note (void); 8945720Speter#endif 9015147Ssmpatel 9145720Speter#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0 9247398Sdfr 9347616Sdfr#define LOCAL_LABELS_FB 1 9447616Sdfr 9545720Speterextern const char extra_symbol_chars[]; 9647398Sdfr#define tc_symbol_chars extra_symbol_chars 9747398Sdfr 9852174Sdfrextern const char *i386_comment_chars; 9952174Sdfr#define tc_comment_chars i386_comment_chars 10047398Sdfr 10147398Sdfr/* Prefixes will be emitted in the order defined below. 10247398Sdfr WAIT_PREFIX must be the first prefix since FWAIT is really is an 10347398Sdfr instruction, and so must come before any prefixes. 10447398Sdfr The preferred prefix order is SEG_PREFIX, ADDR_PREFIX, DATA_PREFIX, 10547398Sdfr LOCKREP_PREFIX. */ 10647398Sdfr#define WAIT_PREFIX 0 10752174Sdfr#define SEG_PREFIX 1 10852174Sdfr#define ADDR_PREFIX 2 10952174Sdfr#define DATA_PREFIX 3 11052174Sdfr#define LOCKREP_PREFIX 4 11152174Sdfr#define REX_PREFIX 5 /* must come last. */ 11252174Sdfr#define MAX_PREFIXES 6 /* max prefixes per opcode */ 11352174Sdfr 11452174Sdfr/* we define the syntax here (modulo base,index,scale syntax) */ 11552174Sdfr#define REGISTER_PREFIX '%' 11652174Sdfr#define IMMEDIATE_PREFIX '$' 11752174Sdfr#define ABSOLUTE_PREFIX '*' 11852174Sdfr 11952174Sdfr/* these are the instruction mnemonic suffixes. */ 12052174Sdfr#define WORD_MNEM_SUFFIX 'w' 12152174Sdfr#define BYTE_MNEM_SUFFIX 'b' 12252174Sdfr#define SHORT_MNEM_SUFFIX 's' 12352174Sdfr#define LONG_MNEM_SUFFIX 'l' 12452174Sdfr#define QWORD_MNEM_SUFFIX 'q' 12547398Sdfr/* Intel Syntax */ 12652174Sdfr#define LONG_DOUBLE_MNEM_SUFFIX 'x' 12747398Sdfr 12845720Speter#define END_OF_INSN '\0' 12945720Speter 13047398Sdfr/* 13152174Sdfr 'templates' is for grouping together 'template' structures for opcodes 13247398Sdfr of the same name. This is only used for storing the insns in the grand 13345720Speter ole hash table of insns. 13415147Ssmpatel The templates themselves start at START and range up to (but not including) 13558762Skato END. 13658762Skato */ 13758762Skatotypedef struct 13858762Skato{ 13958762Skato const template *start; 14058762Skato const template *end; 14158762Skato} 14258762Skatotemplates; 14358762Skato 14458762Skato/* 386 operand encoding bytes: see 386 book for details of this. */ 14558762Skatotypedef struct 14658762Skato{ 14758762Skato unsigned int regmem; /* codes register or memory operand */ 14878391Snyan unsigned int reg; /* codes register operand (or extended opcode) */ 14958762Skato unsigned int mode; /* how to interpret regmem & reg */ 15058762Skato} 15158762Skatomodrm_byte; 15258762Skato 15378391Snyan/* x86-64 extension prefix. */ 15458762Skatotypedef int rex_byte; 15558762Skato 15658762Skato/* 386 opcode byte to code indirect addressing. */ 15758762Skatotypedef struct 15865570Snyan{ 15958762Skato unsigned base; 16058762Skato unsigned index; 16158762Skato unsigned scale; 16258762Skato} 16358762Skatosib_byte; 16458762Skato 16578391Snyanenum processor_type 16678391Snyan{ 16778391Snyan PROCESSOR_UNKNOWN, 16858762Skato PROCESSOR_I486, 16958762Skato PROCESSOR_PENTIUM, 17058762Skato PROCESSOR_PENTIUMPRO, 17158762Skato PROCESSOR_PENTIUM4, 17258762Skato PROCESSOR_NOCONA, 17358762Skato PROCESSOR_CORE, 17458762Skato PROCESSOR_CORE2, 17558762Skato PROCESSOR_K6, 17658762Skato PROCESSOR_ATHLON, 17758762Skato PROCESSOR_K8, 17858762Skato PROCESSOR_GENERIC32, 17958762Skato PROCESSOR_GENERIC64, 18065570Snyan PROCESSOR_AMDFAM10 18158762Skato}; 18258762Skato 18358762Skato/* x86 arch names, types and features */ 18458762Skatotypedef struct 18578391Snyan{ 18658762Skato const char *name; /* arch name */ 18758762Skato enum processor_type type; /* arch type */ 18858762Skato unsigned int flags; /* cpu feature flags */ 18958762Skato} 19058762Skatoarch_entry; 19158762Skato 19258762Skato/* The name of the global offset table generated by the compiler. Allow 19358762Skato this to be overridden if need be. */ 19458762Skato#ifndef GLOBAL_OFFSET_TABLE_NAME 19567346Skato#define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_" 19667346Skato#endif 19758762Skato 19858762Skato#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && !defined (LEX_AT) 19958762Skato#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) x86_cons (EXP, NBYTES) 20058762Skatoextern void x86_cons (expressionS *, int); 20147398Sdfr#endif 20258762Skato 20358762Skato#define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP) x86_cons_fix_new(FRAG, OFF, LEN, EXP) 20484615Snyanextern void x86_cons_fix_new 20558762Skato (fragS *, unsigned int, unsigned int, expressionS *); 20658762Skato 20784615Snyan#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */ 20884615Snyan 20984615Snyan#define NO_RELOC BFD_RELOC_NONE 21084615Snyan 21158762Skatovoid i386_validate_fix (struct fix *); 21284615Snyan#define TC_VALIDATE_FIX(FIX,SEGTYPE,SKIP) i386_validate_fix(FIX) 21384615Snyan 21484615Snyan#define tc_fix_adjustable(X) tc_i386_fix_adjustable(X) 21584615Snyanextern int tc_i386_fix_adjustable (struct fix *); 21684615Snyan 21784615Snyan/* Values passed to md_apply_fix don't include the symbol value. */ 21884615Snyan#define MD_APPLY_SYM_VALUE(FIX) 0 21958762Skato 22067346Skato/* ELF wants external syms kept, as does PE COFF. */ 22184615Snyan#if defined (TE_PE) && defined (STRICT_PE_FORMAT) 22258762Skato#define EXTERN_FORCE_RELOC \ 22358762Skato (OUTPUT_FLAVOR == bfd_target_elf_flavour \ 22458762Skato || OUTPUT_FLAVOR == bfd_target_coff_flavour) 22558762Skato#else 22658762Skato#define EXTERN_FORCE_RELOC \ 22758762Skato (OUTPUT_FLAVOR == bfd_target_elf_flavour) 22845720Speter#endif 22945720Speter 23045720Speter/* This expression evaluates to true if the relocation is for a local 23152174Sdfr object for which we still want to do the relocation at runtime. 23252174Sdfr False if we are willing to perform this relocation while building 23358762Skato the .o file. GOTOFF does not need to be checked here because it is 23458762Skato not pcrel. I am not sure if some of the others are ever used with 23558762Skato pcrel, but it is easier to be safe than sorry. */ 23658762Skato 23758762Skato#define TC_FORCE_RELOCATION_LOCAL(FIX) \ 23858762Skato (!(FIX)->fx_pcrel \ 23958762Skato || (FIX)->fx_r_type == BFD_RELOC_386_PLT32 \ 24090762Snyan || (FIX)->fx_r_type == BFD_RELOC_386_GOT32 \ 24190762Snyan || (FIX)->fx_r_type == BFD_RELOC_386_GOTPC \ 24290762Snyan || TC_FORCE_RELOCATION (FIX)) 24390762Snyan 24490762Snyanextern int i386_parse_name (char *, expressionS *, char *); 24590762Snyan#define md_parse_name(s, e, m, c) i386_parse_name (s, e, c) 24690762Snyan 24758762Skatoextern const struct relax_type md_relax_table[]; 24852174Sdfr#define TC_GENERIC_RELAX_TABLE md_relax_table 2494Srgrimes 2504Srgrimesextern int optimize_align_code; 2514Srgrimes 25245720Speter#define md_do_align(n, fill, len, max, around) \ 25345720Speterif ((n) \ 25445720Speter && !need_pass_2 \ 25545720Speter && optimize_align_code \ 2564Srgrimes && (!(fill) \ 25747398Sdfr || ((char)*(fill) == (char)0x90 && (len) == 1)) \ 25846743Sdfr && subseg_text_p (now_seg)) \ 25945720Speter { \ 26031457Sjmg frag_align_code ((n), (max)); \ 26146743Sdfr goto around; \ 26246743Sdfr } 2634Srgrimes 2644Srgrimes#define MAX_MEM_FOR_RS_ALIGN_CODE 15 26547398Sdfr 26645720Speterextern void i386_align_code (fragS *, int); 26745720Speter 26827639Smsmith#define HANDLE_ALIGN(fragP) \ 26945720Speterif (fragP->fr_type == rs_align_code) \ 27027639Smsmith i386_align_code (fragP, (fragP->fr_next->fr_address \ 271 - fragP->fr_address \ 272 - fragP->fr_fix)); 273 274void i386_print_statistics (FILE *); 275#define tc_print_statistics i386_print_statistics 276 277#define md_number_to_chars number_to_chars_littleendian 278 279#ifdef SCO_ELF 280#define tc_init_after_args() sco_id () 281extern void sco_id (void); 282#endif 283 284#define WORKING_DOT_WORD 1 285 286/* We want .cfi_* pseudo-ops for generating unwind info. */ 287#define TARGET_USE_CFIPOP 1 288 289extern unsigned int x86_dwarf2_return_column; 290#define DWARF2_DEFAULT_RETURN_COLUMN x86_dwarf2_return_column 291 292extern int x86_cie_data_alignment; 293#define DWARF2_CIE_DATA_ALIGNMENT x86_cie_data_alignment 294 295#define tc_regname_to_dw2regnum tc_x86_regname_to_dw2regnum 296extern int tc_x86_regname_to_dw2regnum (char *); 297 298#define tc_cfi_frame_initial_instructions tc_x86_frame_initial_instructions 299extern void tc_x86_frame_initial_instructions (void); 300 301#define md_elf_section_type(str,len) i386_elf_section_type (str, len) 302extern int i386_elf_section_type (const char *, size_t); 303 304/* Support for SHF_X86_64_LARGE */ 305extern int x86_64_section_word (char *, size_t); 306extern int x86_64_section_letter (int, char **); 307#define md_elf_section_letter(LETTER, PTR_MSG) x86_64_section_letter (LETTER, PTR_MSG) 308#define md_elf_section_word(STR, LEN) x86_64_section_word (STR, LEN) 309 310#ifdef TE_PE 311 312#define O_secrel O_md1 313 314#define TC_DWARF2_EMIT_OFFSET tc_pe_dwarf2_emit_offset 315void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int); 316 317#endif /* TE_PE */ 318 319#endif /* TC_I386 */ 320