📄 tc-hppa.c
字号:
/* tc-hppa.c -- Assemble for the PA Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. GAS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GAS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GAS; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* HP PA-RISC support was contributed by the Center for Software Science at the University of Utah. */#include <stdio.h>#include <ctype.h>#include "as.h"#include "subsegs.h"#include "bfd/libhppa.h"/* Be careful, this file includes data *declarations*. */#include "opcode/hppa.h"#if defined (OBJ_ELF) && defined (OBJ_SOM)error only one of OBJ_ELF and OBJ_SOM can be defined#endif/* If we are using ELF, then we probably can support dwarf2 debug records. Furthermore, if we are supporting dwarf2 debug records, then we want to use the assembler support for compact line numbers. */#ifdef OBJ_ELF#include "dwarf2dbg.h"/* A "convient" place to put object file dependencies which do not need to be seen outside of tc-hppa.c. *//* Object file formats specify relocation types. */typedef enum elf_hppa_reloc_type reloc_type;/* Object file formats specify BFD symbol types. */typedef elf_symbol_type obj_symbol_type;#define symbol_arg_reloc_info(sym)\ (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.hppa_arg_reloc)#if TARGET_ARCH_SIZE == 64/* How to generate a relocation. */#define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type#else#define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type#endif/* ELF objects can have versions, but apparently do not have anywhere to store a copyright string. */#define obj_version obj_elf_version#define obj_copyright obj_elf_version#define UNWIND_SECTION_NAME ".PARISC.unwind"#endif /* OBJ_ELF */#ifdef OBJ_SOM/* Names of various debugging spaces/subspaces. */#define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"#define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"#define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"#define UNWIND_SECTION_NAME "$UNWIND$"/* Object file formats specify relocation types. */typedef int reloc_type;/* SOM objects can have both a version string and a copyright string. */#define obj_version obj_som_version#define obj_copyright obj_som_copyright/* How to generate a relocation. */#define hppa_gen_reloc_type hppa_som_gen_reloc_type/* Object file formats specify BFD symbol types. */typedef som_symbol_type obj_symbol_type;#define symbol_arg_reloc_info(sym)\ (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.ap.hppa_arg_reloc)/* This apparently isn't in older versions of hpux reloc.h. */#ifndef R_DLT_REL#define R_DLT_REL 0x78#endif#ifndef R_N0SEL#define R_N0SEL 0xd8#endif#ifndef R_N1SEL#define R_N1SEL 0xd9#endif#endif /* OBJ_SOM */#if TARGET_ARCH_SIZE == 64#define DEFAULT_LEVEL 25#else#define DEFAULT_LEVEL 10#endif/* Various structures and types used internally in tc-hppa.c. *//* Unwind table and descriptor. FIXME: Sync this with GDB version. */struct unwind_desc { unsigned int cannot_unwind:1; unsigned int millicode:1; unsigned int millicode_save_rest:1; unsigned int region_desc:2; unsigned int save_sr:2; unsigned int entry_fr:4; unsigned int entry_gr:5; unsigned int args_stored:1; unsigned int call_fr:5; unsigned int call_gr:5; unsigned int save_sp:1; unsigned int save_rp:1; unsigned int save_rp_in_frame:1; unsigned int extn_ptr_defined:1; unsigned int cleanup_defined:1; unsigned int hpe_interrupt_marker:1; unsigned int hpux_interrupt_marker:1; unsigned int reserved:3; unsigned int frame_size:27; };/* We can't rely on compilers placing bitfields in any particular place, so use these macros when dumping unwind descriptors to object files. */#define UNWIND_LOW32(U) \ (((U)->cannot_unwind << 31) \ | ((U)->millicode << 30) \ | ((U)->millicode_save_rest << 29) \ | ((U)->region_desc << 27) \ | ((U)->save_sr << 25) \ | ((U)->entry_fr << 21) \ | ((U)->entry_gr << 16) \ | ((U)->args_stored << 15) \ | ((U)->call_fr << 10) \ | ((U)->call_gr << 5) \ | ((U)->save_sp << 4) \ | ((U)->save_rp << 3) \ | ((U)->save_rp_in_frame << 2) \ | ((U)->extn_ptr_defined << 1) \ | ((U)->cleanup_defined << 0))#define UNWIND_HIGH32(U) \ (((U)->hpe_interrupt_marker << 31) \ | ((U)->hpux_interrupt_marker << 30) \ | ((U)->frame_size << 0))struct unwind_table { /* Starting and ending offsets of the region described by descriptor. */ unsigned int start_offset; unsigned int end_offset; struct unwind_desc descriptor; };/* This structure is used by the .callinfo, .enter, .leave pseudo-ops to control the entry and exit code they generate. It is also used in creation of the correct stack unwind descriptors. NOTE: GAS does not support .enter and .leave for the generation of prologues and epilogues. FIXME. The fields in structure roughly correspond to the arguments available on the .callinfo pseudo-op. */struct call_info { /* The unwind descriptor being built. */ struct unwind_table ci_unwind; /* Name of this function. */ symbolS *start_symbol; /* (temporary) symbol used to mark the end of this function. */ symbolS *end_symbol; /* Next entry in the chain. */ struct call_info *ci_next; };/* Operand formats for FP instructions. Note not all FP instructions allow all four formats to be used (for example fmpysub only allows SGL and DBL). */typedef enum { SGL, DBL, ILLEGAL_FMT, QUAD, W, UW, DW, UDW, QW, UQW }fp_operand_format;/* This fully describes the symbol types which may be attached to an EXPORT or IMPORT directive. Only SOM uses this formation (ELF has no need for it). */typedef enum { SYMBOL_TYPE_UNKNOWN, SYMBOL_TYPE_ABSOLUTE, SYMBOL_TYPE_CODE, SYMBOL_TYPE_DATA, SYMBOL_TYPE_ENTRY, SYMBOL_TYPE_MILLICODE, SYMBOL_TYPE_PLABEL, SYMBOL_TYPE_PRI_PROG, SYMBOL_TYPE_SEC_PROG, }pa_symbol_type;/* This structure contains information needed to assemble individual instructions. */struct pa_it { /* Holds the opcode after parsing by pa_ip. */ unsigned long opcode; /* Holds an expression associated with the current instruction. */ expressionS exp; /* Does this instruction use PC-relative addressing. */ int pcrel; /* Floating point formats for operand1 and operand2. */ fp_operand_format fpof1; fp_operand_format fpof2; /* Whether or not we saw a truncation request on an fcnv insn. */ int trunc; /* Holds the field selector for this instruction (for example L%, LR%, etc). */ long field_selector; /* Holds any argument relocation bits associated with this instruction. (instruction should be some sort of call). */ unsigned int arg_reloc; /* The format specification for this instruction. */ int format; /* The relocation (if any) associated with this instruction. */ reloc_type reloc; };/* PA-89 floating point registers are arranged like this: +--------------+--------------+ | 0 or 16L | 16 or 16R | +--------------+--------------+ | 1 or 17L | 17 or 17R | +--------------+--------------+ | | | . . . . . . . . . | | | +--------------+--------------+ | 14 or 30L | 30 or 30R | +--------------+--------------+ | 15 or 31L | 31 or 31R | +--------------+--------------+ *//* Additional information needed to build argument relocation stubs. */struct call_desc { /* The argument relocation specification. */ unsigned int arg_reloc; /* Number of arguments. */ unsigned int arg_count; };#ifdef OBJ_SOM/* This structure defines an entry in the subspace dictionary chain. */struct subspace_dictionary_chain { /* Nonzero if this space has been defined by the user code. */ unsigned int ssd_defined; /* Name of this subspace. */ char *ssd_name; /* GAS segment and subsegment associated with this subspace. */ asection *ssd_seg; int ssd_subseg; /* Next space in the subspace dictionary chain. */ struct subspace_dictionary_chain *ssd_next; };typedef struct subspace_dictionary_chain ssd_chain_struct;/* This structure defines an entry in the subspace dictionary chain. */struct space_dictionary_chain { /* Nonzero if this space has been defined by the user code or as a default space. */ unsigned int sd_defined; /* Nonzero if this spaces has been defined by the user code. */ unsigned int sd_user_defined; /* The space number (or index). */ unsigned int sd_spnum; /* The name of this subspace. */ char *sd_name; /* GAS segment to which this subspace corresponds. */ asection *sd_seg; /* Current subsegment number being used. */ int sd_last_subseg; /* The chain of subspaces contained within this space. */ ssd_chain_struct *sd_subspaces; /* The next entry in the space dictionary chain. */ struct space_dictionary_chain *sd_next; };typedef struct space_dictionary_chain sd_chain_struct;/* This structure defines attributes of the default subspace dictionary entries. */struct default_subspace_dict { /* Name of the subspace. */ char *name; /* FIXME. Is this still needed? */ char defined; /* Nonzero if this subspace is loadable. */ char loadable; /* Nonzero if this subspace contains only code. */ char code_only; /* Nonzero if this is a common subspace. */ char common; /* Nonzero if this is a common subspace which allows symbols to be multiply defined. */ char dup_common; /* Nonzero if this subspace should be zero filled. */ char zero; /* Sort key for this subspace. */ unsigned char sort; /* Access control bits for this subspace. Can represent RWX access as well as privilege level changes for gateways. */ int access; /* Index of containing space. */ int space_index; /* Alignment (in bytes) of this subspace. */ int alignment; /* Quadrant within space where this subspace should be loaded. */ int quadrant; /* An index into the default spaces array. */ int def_space_index; /* Subsegment associated with this subspace. */ subsegT subsegment; };/* This structure defines attributes of the default space dictionary entries. */struct default_space_dict { /* Name of the space. */ char *name; /* Space number. It is possible to identify spaces within assembly code numerically! */ int spnum; /* Nonzero if this space is loadable. */ char loadable; /* Nonzero if this space is "defined". FIXME is still needed */ char defined; /* Nonzero if this space can not be shared. */ char private; /* Sort key for this space. */ unsigned char sort; /* Segment associated with this space. */ asection *segment; };#endif/* Structure for previous label tracking. Needed so that alignments, callinfo declarations, etc can be easily attached to a particular label. */typedef struct label_symbol_struct { struct symbol *lss_label;#ifdef OBJ_SOM sd_chain_struct *lss_space;#endif#ifdef OBJ_ELF segT lss_segment;#endif struct label_symbol_struct *lss_next; }label_symbol_struct;/* Extra information needed to perform fixups (relocations) on the PA. */struct hppa_fix_struct { /* The field selector. */ enum hppa_reloc_field_selector_type_alt fx_r_field; /* Type of fixup. */ int fx_r_type; /* Format of fixup. */ int fx_r_format; /* Argument relocation bits. */ unsigned int fx_arg_reloc; /* The segment this fixup appears in. */ segT segment; };/* Structure to hold information about predefined registers. */struct pd_reg { char *name; int value; };/* This structure defines the mapping from a FP condition string to a condition number which can be recorded in an instruction. */struct fp_cond_map { char *string; int cond; };/* This structure defines a mapping from a field selector string to a field selector type. */struct selector_entry { char *prefix; int field_selector; };/* Prototypes for functions local to tc-hppa.c. */#ifdef OBJ_SOMstatic void pa_check_current_space_and_subspace PARAMS ((void));#endif#if !(defined (OBJ_ELF) && defined (TE_LINUX))static void pa_text PARAMS ((int));static void pa_data PARAMS ((int));static void pa_comm PARAMS ((int));#endifstatic fp_operand_format pa_parse_fp_format PARAMS ((char **s));static void pa_cons PARAMS ((int));static void pa_float_cons PARAMS ((int));static void pa_fill PARAMS ((int));static void pa_lcomm PARAMS ((int));static void pa_lsym PARAMS ((int));static void pa_stringer PARAMS ((int));static void pa_version PARAMS ((int));static int pa_parse_fp_cmp_cond PARAMS ((char **));static int get_expression PARAMS ((char *));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -