X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fconfig%2Ftc-alpha.c;h=89eaf88603da7a3ce3fab869b201384c80e1ea9d;hb=945e0f82dad31db89a107b496532886fe215c011;hp=43bd18b8bdff1e57ef9fba0a03a4fd0a19027a07;hpb=9b80deddf2929f55251e96edfc4ef1e39003bbac;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c index 43bd18b8bd..89eaf88603 100644 --- a/gas/config/tc-alpha.c +++ b/gas/config/tc-alpha.c @@ -1,7 +1,5 @@ /* tc-alpha.c - Processor-specific code for the DEC Alpha AXP CPU. - Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1989-2016 Free Software Foundation, Inc. Contributed by Carnegie Mellon University, 1993. Written by Alessandro Forin, based on earlier gas-1.38 target CPU files. Modified by Ken Raeburn for gas-2.x and ECOFF support. @@ -243,7 +241,7 @@ const char EXP_CHARS[] = "eE"; /* Characters which mean that a number is a floating point constant, as in 0d1.0. */ /* XXX: Do all of these really get used on the alpha?? */ -char FLT_CHARS[] = "rRsSfFdDxXpP"; +const char FLT_CHARS[] = "rRsSfFdDxXpP"; #ifdef OBJ_EVAX const char *md_shortopts = "Fm:g+1h:HG:"; @@ -267,7 +265,7 @@ struct option md_longopts[] = #define OPTION_REPLACE (OPTION_RELAX + 1) #define OPTION_NOREPLACE (OPTION_REPLACE+1) { "replace", no_argument, NULL, OPTION_REPLACE }, - { "noreplace", no_argument, NULL, OPTION_NOREPLACE }, + { "noreplace", no_argument, NULL, OPTION_NOREPLACE }, #endif { NULL, no_argument, NULL, 0 } }; @@ -580,7 +578,7 @@ static void assemble_insn (const struct alpha_opcode *, const expressionS *, int static void emit_insn (struct alpha_insn *); static void assemble_tokens (const char *, const expressionS *, int, int); #ifdef OBJ_EVAX -static char *s_alpha_section_name (void); +static const char *s_alpha_section_name (void); static symbolS *add_to_link_pool (symbolS *, offsetT); #endif @@ -923,8 +921,7 @@ tokenize_arguments (char *str, ++input_line_pointer; SKIP_WHITESPACE (); - p = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&p); /* Parse !relocation_type. */ len = input_line_pointer - p; @@ -945,7 +942,7 @@ tokenize_arguments (char *str, } *input_line_pointer = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer != '!') { if (r->require_seq) @@ -1387,13 +1384,14 @@ load_expression (int targreg, ptr1 = strstr (symname, "..") + 2; if (ptr1 > ptr2) ptr1 = symname; - ensymname = (char *) alloca (ptr2 - ptr1 + 5); + ensymname = (char *) xmalloc (ptr2 - ptr1 + 5); memcpy (ensymname, ptr1, ptr2 - ptr1); memcpy (ensymname + (ptr2 - ptr1), "..en", 5); gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS); insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_NOP; ensym = symbol_find_or_make (ensymname); + free (ensymname); symbol_mark_used (ensym); /* The fixup must be the same as the BFD_RELOC_ALPHA_BOH case in emit_jsrjmp. See B.4.5.2 of the OpenVMS Linker @@ -1419,13 +1417,14 @@ load_expression (int targreg, ptr1 = strstr (symname, "..") + 2; if (ptr1 > ptr2) ptr1 = symname; - psymname = (char *) alloca (ptr2 - ptr1 + 1); + psymname = (char *) xmalloc (ptr2 - ptr1 + 1); memcpy (psymname, ptr1, ptr2 - ptr1); psymname [ptr2 - ptr1] = 0; gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS); insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_LDA; psym = symbol_find_or_make (psymname); + free (psymname); symbol_mark_used (psym); insn.fixups[insn.nfixups].exp.X_op = O_subtract; insn.fixups[insn.nfixups].exp.X_add_symbol = psym; @@ -1800,7 +1799,7 @@ emit_insn (struct alpha_insn *insn) default: gas_assert (size >= 1 && size <= 4); } - + pcrel = reloc_howto->pc_relative; } @@ -1976,7 +1975,7 @@ static unsigned insert_operand (unsigned insn, const struct alpha_operand *operand, offsetT val, - char *file, + const char *file, unsigned line) { if (operand->bits != 32 && !(operand->flags & AXP_OPERAND_NOOVERFLOW)) @@ -2139,7 +2138,7 @@ assemble_insn (const struct alpha_opcode *opcode, /* If this is a real relocation (as opposed to a lituse hint), then the relocation width should match the operand width. - Take care of -MDISP in operand table. */ + Take care of -MDISP in operand table. */ else if (reloc < BFD_RELOC_UNUSED && reloc > 0) { reloc_howto_type *reloc_howto @@ -2192,7 +2191,7 @@ emit_ir_load (const expressionS *tok, if (basereg == alpha_gp_register && (symlen > 4 && strcmp (&symname [symlen - 4], "..lk") == 0)) return; - + newtok[0] = tok[0]; set_tok_preg (newtok[2], basereg); @@ -2233,7 +2232,7 @@ emit_loadstore (const expressionS *tok, if (alpha_noat_on) as_bad (_("macro requires $at register while noat in effect")); - lituse = load_expression (AXP_REG_AT, &tok[1], + lituse = load_expression (AXP_REG_AT, &tok[1], &basereg, &newtok[1], (const char *) opname); } else @@ -2884,7 +2883,7 @@ emit_jsrjmp (const expressionS *tok, char *ensymname; /* Build the entry name as 'NAME..en'. */ - ensymname = (char *) alloca (symlen + 5); + ensymname = (char *) xmalloc (symlen + 5); memcpy (ensymname, symname, symlen); memcpy (ensymname + symlen, "..en", 5); @@ -2906,6 +2905,7 @@ emit_jsrjmp (const expressionS *tok, insn.fixups[0].procsym = alpha_evax_proc->symbol; insn.nfixups++; alpha_linkage_symbol = 0; + free (ensymname); } #endif @@ -3385,7 +3385,7 @@ add_to_link_pool (symbolS *sym, offsetT addend) fixS *fixp; symbolS *linksym, *expsym; expressionS e; - + basesym = alpha_evax_proc->symbol; /* @@ This assumes all entries in a given section will be of the same @@ -3496,14 +3496,13 @@ s_alpha_comm (int ignore ATTRIBUTE_UNUSED) int log_align = 0; #endif - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); /* Just after name is now '\0'. */ p = input_line_pointer; *p = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); /* Alpha OSF/1 compiler doesn't provide the comma, gcc does. */ if (*input_line_pointer == ',') @@ -3553,12 +3552,12 @@ s_alpha_comm (int ignore ATTRIBUTE_UNUSED) The symbol is effectively an alias for the section name. */ segT sec; - char *sec_name; + const char *sec_name; symbolS *sec_symbol; segT current_seg = now_seg; subsegT current_subseg = now_subseg; int cur_size; - + input_line_pointer++; SKIP_WHITESPACE (); sec_name = s_alpha_section_name (); @@ -3612,7 +3611,7 @@ s_alpha_comm (int ignore ATTRIBUTE_UNUSED) subseg_set (current_seg, current_subseg); } #endif - + if (S_GET_VALUE (symbolP)) { if (S_GET_VALUE (symbolP) != (valueT) size) @@ -3628,7 +3627,7 @@ s_alpha_comm (int ignore ATTRIBUTE_UNUSED) #endif S_SET_EXTERNAL (symbolP); } - + #ifndef OBJ_EVAX know (symbolP->sy_frag == &zero_address_frag); #endif @@ -3693,6 +3692,8 @@ static struct alpha_elf_frame_data *all_frame_data; static struct alpha_elf_frame_data **plast_frame_data = &all_frame_data; static struct alpha_elf_frame_data *cur_frame_data; +extern int all_cfi_sections; + /* Handle the .section pseudo-op. This is like the usual one, but it clears alpha_insn_label and restores auto alignment. */ @@ -3714,13 +3715,15 @@ s_alpha_ent (int dummy ATTRIBUTE_UNUSED) else { char *name, name_end; - name = input_line_pointer; - name_end = get_symbol_end (); + + name_end = get_symbol_name (&name); + /* CFI_EMIT_eh_frame is the default. */ + all_cfi_sections = CFI_EMIT_eh_frame; if (! is_name_beginner (*name)) { as_warn (_(".ent directive has no name")); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); } else { @@ -3746,7 +3749,7 @@ s_alpha_ent (int dummy ATTRIBUTE_UNUSED) /* The .ent directive is sometimes followed by a number. Not sure what it really means, but ignore it. */ *input_line_pointer = name_end; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer == ',') { input_line_pointer++; @@ -3767,13 +3770,12 @@ s_alpha_end (int dummy ATTRIBUTE_UNUSED) else { char *name, name_end; - name = input_line_pointer; - name_end = get_symbol_end (); + + name_end = get_symbol_name (&name); if (! is_name_beginner (*name)) { as_warn (_(".end directive has no name")); - *input_line_pointer = name_end; } else { @@ -3801,9 +3803,9 @@ s_alpha_end (int dummy ATTRIBUTE_UNUSED) } cur_frame_data = NULL; - - *input_line_pointer = name_end; } + + (void) restore_line_pointer (name_end); demand_empty_rest_of_line (); } } @@ -4063,6 +4065,7 @@ alpha_elf_md_end (void) S_GET_VALUE (p->func_sym), symbol_get_frag (p->func_sym))); + cfi_set_sections (); cfi_set_return_column (p->ra_regno); cfi_add_CFA_def_cfa_register (30); if (p->fp_regno != 30 || p->mask || p->fmask || p->frame_size) @@ -4127,19 +4130,20 @@ s_alpha_usepv (int unused ATTRIBUTE_UNUSED) symbolS *sym; int other; - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); if (! is_name_beginner (*name)) { as_bad (_(".usepv directive has no name")); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); ignore_rest_of_line (); return; } sym = symbol_find_or_make (name); - *input_line_pointer++ = name_end; + name_end = restore_line_pointer (name_end); + if (! is_end_of_line[(unsigned char) name_end]) + input_line_pointer++; if (name_end != ',') { @@ -4149,8 +4153,8 @@ s_alpha_usepv (int unused ATTRIBUTE_UNUSED) } SKIP_WHITESPACE (); - which = input_line_pointer; - which_end = get_symbol_end (); + + which_end = get_symbol_name (&which); if (strcmp (which, "no") == 0) other = STO_ALPHA_NOPV; @@ -4162,7 +4166,7 @@ s_alpha_usepv (int unused ATTRIBUTE_UNUSED) other = 0; } - *input_line_pointer = which_end; + (void) restore_line_pointer (which_end); demand_empty_rest_of_line (); S_SET_OTHER (sym, other | (S_GET_OTHER (sym) & ~STO_ALPHA_STD_GPLOAD)); @@ -4180,7 +4184,7 @@ alpha_cfi_frame_initial_instructions (void) #ifdef OBJ_EVAX /* Get name of section. */ -static char * +static const char * s_alpha_section_name (void) { char *name; @@ -4237,7 +4241,7 @@ s_alpha_section_word (char *str, size_t len) { no = 1; str += 2; - len -= 2; + len -= 2; } if (len == 3) @@ -4288,13 +4292,14 @@ s_alpha_section_word (char *str, size_t len) #define EVAX_SECTION_COUNT 5 -static char *section_name[EVAX_SECTION_COUNT + 1] = +static const char *section_name[EVAX_SECTION_COUNT + 1] = { "NULL", ".rdata", ".comm", ".link", ".ctors", ".dtors" }; static void s_alpha_section (int secid) { - char *name, *beg; + const char *name; + char *beg; segT sec; flagword vms_flags = 0; symbolS *symbol; @@ -4316,15 +4321,15 @@ s_alpha_section (int secid) char c; SKIP_WHITESPACE (); - beg = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&beg); *input_line_pointer = c; vms_flags |= s_alpha_section_word (beg, input_line_pointer - beg); - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); } while (*input_line_pointer++ == ','); + --input_line_pointer; } @@ -4408,13 +4413,12 @@ s_alpha_handler (int is_data) else { char *name, name_end; - name = input_line_pointer; - name_end = get_symbol_end (); + + name_end = get_symbol_name (&name); if (! is_name_beginner (*name)) { as_warn (_(".handler directive has no name")); - *input_line_pointer = name_end; } else { @@ -4423,9 +4427,11 @@ s_alpha_handler (int is_data) sym = symbol_find_or_make (name); symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; alpha_evax_proc->handler = sym; - *input_line_pointer = name_end; } - } + + (void) restore_line_pointer (name_end); + } + demand_empty_rest_of_line (); } @@ -4484,7 +4490,7 @@ s_alpha_pdesc (int ignore ATTRIBUTE_UNUSED) { char *name; char name_end; - register char *p; + char *p; expressionS exp; symbolS *entry_sym; const char *entry_sym_name; @@ -4504,10 +4510,10 @@ s_alpha_pdesc (int ignore ATTRIBUTE_UNUSED) as_bad (_(".pdesc directive has no entry symbol")); return; } - + entry_sym = make_expr_symbol (&exp); entry_sym_name = S_GET_NAME (entry_sym); - + /* Strip "..en". */ len = strlen (entry_sym_name); if (len < 4 || strcmp (entry_sym_name + len - 4, "..en") != 0) @@ -4529,12 +4535,12 @@ s_alpha_pdesc (int ignore ATTRIBUTE_UNUSED) /* Define pdesc symbol. */ symbol_set_value_now (alpha_evax_proc->symbol); - + /* Save bfd symbol of proc entry in function symbol. */ ((struct evax_private_udata_struct *) symbol_get_bfdsym (alpha_evax_proc->symbol)->udata.p)->enbsym = symbol_get_bfdsym (entry_sym); - + SKIP_WHITESPACE (); if (*input_line_pointer++ != ',') { @@ -4544,8 +4550,7 @@ s_alpha_pdesc (int ignore ATTRIBUTE_UNUSED) } SKIP_WHITESPACE (); - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); if (strncmp (name, "stack", 5) == 0) alpha_evax_proc->pdsckind = PDSC_S_K_KIND_FP_STACK; @@ -4558,12 +4563,13 @@ s_alpha_pdesc (int ignore ATTRIBUTE_UNUSED) else { + (void) restore_line_pointer (name_end); as_fatal (_("unknown procedure kind")); demand_empty_rest_of_line (); return; } - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); demand_empty_rest_of_line (); #ifdef md_flush_pending_output @@ -4700,7 +4706,7 @@ s_alpha_linkage (int ignore ATTRIBUTE_UNUSED) else { struct alpha_linkage_fixups *linkage_fixup; - + p = frag_more (LKP_S_K_SIZE); memset (p, 0, LKP_S_K_SIZE); fixp = fix_new_exp @@ -4801,10 +4807,11 @@ s_alpha_fmask (int ignore ATTRIBUTE_UNUSED) static void s_alpha_end (int ignore ATTRIBUTE_UNUSED) { + char *name; char c; - c = get_symbol_end (); - *input_line_pointer = c; + c = get_symbol_name (&name); + (void) restore_line_pointer (c); demand_empty_rest_of_line (); alpha_evax_proc = NULL; } @@ -4935,12 +4942,11 @@ s_alpha_proc (int is_static ATTRIBUTE_UNUSED) /* Takes ".proc name,nargs". */ SKIP_WHITESPACE (); - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); p = input_line_pointer; symbolP = symbol_find_or_make (name); *p = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer != ',') { *p = 0; @@ -4970,9 +4976,8 @@ s_alpha_set (int x ATTRIBUTE_UNUSED) int yesno = 1; SKIP_WHITESPACE (); - name = input_line_pointer; - ch = get_symbol_end (); + ch = get_symbol_name (&name); s = name; if (s[0] == 'n' && s[1] == 'o') { @@ -4992,7 +4997,7 @@ s_alpha_set (int x ATTRIBUTE_UNUSED) else as_warn (_("Tried to .set unrecognized mode `%s'"), name); - *input_line_pointer = ch; + (void) restore_line_pointer (ch); demand_empty_rest_of_line (); } @@ -5127,8 +5132,8 @@ s_alpha_arch (int ignored ATTRIBUTE_UNUSED) const struct cpu_type *p; SKIP_WHITESPACE (); - name = input_line_pointer; - ch = get_symbol_end (); + + ch = get_symbol_name (&name); for (p = cpu_types; p->name; ++p) if (strcmp (name, p->name) == 0) @@ -5139,7 +5144,7 @@ s_alpha_arch (int ignored ATTRIBUTE_UNUSED) as_warn (_("Unknown CPU identifier `%s'"), name); found: - *input_line_pointer = ch; + (void) restore_line_pointer (ch); demand_empty_rest_of_line (); } @@ -5302,7 +5307,7 @@ maybe_set_gp (asection *sec) if (!sec) return; - vma = bfd_get_section_vma (foo, sec); + vma = bfd_get_section_vma (sec->owner, sec); if (vma && vma < alpha_gp_value) alpha_gp_value = vma; } @@ -5336,7 +5341,7 @@ select_gp_value (void) /* Map 's' to SHF_ALPHA_GPREL. */ bfd_vma -alpha_elf_section_letter (int letter, char **ptr_msg) +alpha_elf_section_letter (int letter, const char **ptr_msg) { if (letter == 's') return SHF_ALPHA_GPREL; @@ -5362,8 +5367,8 @@ alpha_elf_section_flags (flagword flags, bfd_vma attr, int type ATTRIBUTE_UNUSED void alpha_handle_align (fragS *fragp) { - static char const unop[4] = { 0x00, 0x00, 0xfe, 0x2f }; - static char const nopunop[8] = + static unsigned char const unop[4] = { 0x00, 0x00, 0xfe, 0x2f }; + static unsigned char const nopunop[8] = { 0x1f, 0x04, 0xff, 0x47, 0x00, 0x00, 0xfe, 0x2f @@ -5575,10 +5580,10 @@ md_section_align (segT seg, valueT size) of LITTLENUMS emitted is stored in *SIZEP. An error message is returned, or NULL on OK. */ -char * +const char * md_atof (int type, char *litP, int *sizeP) { - extern char *vax_md_atof (int, char *, int *); + extern const char *vax_md_atof (int, char *, int *); switch (type) { @@ -5598,7 +5603,7 @@ md_atof (int type, char *litP, int *sizeP) /* Take care of the target-specific command-line options. */ int -md_parse_option (int c, char *arg) +md_parse_option (int c, const char *arg) { switch (c) { @@ -6278,11 +6283,12 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, if (pname_len > 4 && strcmp (pname + pname_len - 4, "..en") == 0) { symbolS *sym; - char *my_pname = (char *) alloca (pname_len - 4 + 1); + char *my_pname = (char *) xmalloc (pname_len - 4 + 1); memcpy (my_pname, pname, pname_len - 4); my_pname [pname_len - 4] = 0; sym = symbol_find (my_pname); + free (my_pname); if (sym == NULL) abort (); @@ -6331,8 +6337,8 @@ tc_get_register (int frame ATTRIBUTE_UNUSED) SKIP_WHITESPACE (); if (*input_line_pointer == '$') { - char *s = input_line_pointer; - char c = get_symbol_end (); + char *s; + char c = get_symbol_name (&s); symbolS *sym = md_undefined_symbol (s); *strchr (s, '\0') = c;