X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fconfig%2Ftc-hppa.c;h=fb6d82bc596072d42892d6c01275b1107afc4f70;hb=40c9c8deb94be6576f5729172dce117cbe155856;hp=bd2357eaac25a3838e1d39305041ffbc368d04aa;hpb=aff7ae12a660fc3c7269530eadcb06e2db06a240;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index bd2357eaac..fb6d82bc59 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -1,5 +1,5 @@ /* tc-hppa.c -- Assemble for the PA - Copyright (C) 1989-2016 Free Software Foundation, Inc. + Copyright (C) 1989-2019 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -350,7 +350,7 @@ typedef struct space_dictionary_chain sd_chain_struct; struct default_subspace_dict { /* Name of the subspace. */ - char *name; + const char *name; /* FIXME. Is this still needed? */ char defined; @@ -403,7 +403,7 @@ struct default_subspace_dict struct default_space_dict { /* Name of the space. */ - char *name; + const char *name; /* Space number. It is possible to identify spaces within assembly code numerically! */ @@ -503,27 +503,27 @@ static void pa_align (int); static void pa_space (int); static void pa_spnum (int); static void pa_subspace (int); -static sd_chain_struct *create_new_space (char *, int, int, - int, int, int, - asection *, int); +static sd_chain_struct *create_new_space (const char *, int, int, + int, int, int, + asection *, int); static ssd_chain_struct *create_new_subspace (sd_chain_struct *, - char *, int, int, - int, int, int, int, - int, int, int, int, - int, asection *); + const char *, int, int, + int, int, int, int, + int, int, int, int, + int, asection *); static ssd_chain_struct *update_subspace (sd_chain_struct *, - char *, int, int, int, - int, int, int, int, - int, int, int, int, - asection *); -static sd_chain_struct *is_defined_space (char *); -static ssd_chain_struct *is_defined_subspace (char *); + char *, int, int, int, + int, int, int, int, + int, int, int, int, + asection *); +static sd_chain_struct *is_defined_space (const char *); +static ssd_chain_struct *is_defined_subspace (const char *); static sd_chain_struct *pa_segment_to_space (asection *); static ssd_chain_struct *pa_subsegment_to_subspace (asection *, subsegT); static sd_chain_struct *pa_find_space_by_number (int); static unsigned int pa_subspace_start (sd_chain_struct *, int); -static sd_chain_struct *pa_parse_space_stmt (char *, int); +static sd_chain_struct *pa_parse_space_stmt (const char *, int); #endif /* File and globally scoped variable declarations. */ @@ -1319,7 +1319,7 @@ pa_parse_nullif (char **s) return nullif; } -char * +const char * md_atof (int type, char *litP, int *sizeP) { return ieee_md_atof (type, litP, sizeP, TRUE); @@ -1355,9 +1355,9 @@ tc_gen_reloc (asection *section, fixS *fixp) gas_assert (hppa_fixp != 0); gas_assert (section != 0); - reloc = xmalloc (sizeof (arelent)); + reloc = XNEW (arelent); - reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + reloc->sym_ptr_ptr = XNEW (asymbol *); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); /* Allow fixup_segment to recognize hand-written pc-relative relocations. @@ -1388,8 +1388,8 @@ tc_gen_reloc (asection *section, fixS *fixp) for (n_relocs = 0; codes[n_relocs]; n_relocs++) ; - relocs = xmalloc (sizeof (arelent *) * n_relocs + 1); - reloc = xmalloc (sizeof (arelent) * n_relocs); + relocs = XNEWVEC (arelent *, n_relocs + 1); + reloc = XNEWVEC (arelent, n_relocs); for (i = 0; i < n_relocs; i++) relocs[i] = &reloc[i]; @@ -1440,14 +1440,14 @@ tc_gen_reloc (asection *section, fixS *fixp) /* Facilitate hand-crafted unwind info. */ if (strcmp (section->name, UNWIND_SECTION_NAME) == 0) code = R_PARISC_SEGREL32; - /* Fall thru */ + /* Fallthru */ default: reloc->addend = fixp->fx_offset; break; } - reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + reloc->sym_ptr_ptr = XNEW (asymbol *); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); reloc->howto = bfd_reloc_type_lookup (stdoutput, (bfd_reloc_code_real_type) code); @@ -1463,7 +1463,7 @@ tc_gen_reloc (asection *section, fixS *fixp) { code = *codes[i]; - relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + relocs[i]->sym_ptr_ptr = XNEW (asymbol *); *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); relocs[i]->howto = bfd_reloc_type_lookup (stdoutput, @@ -1484,14 +1484,14 @@ tc_gen_reloc (asection *section, fixS *fixp) (bfd_reloc_code_real_type) *codes[0]); relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[0]->addend = 0; - relocs[1]->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + relocs[1]->sym_ptr_ptr = XNEW (asymbol *); *relocs[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); relocs[1]->howto = bfd_reloc_type_lookup (stdoutput, (bfd_reloc_code_real_type) *codes[1]); relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where; relocs[1]->addend = 0; - relocs[2]->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + relocs[2]->sym_ptr_ptr = XNEW (asymbol *); *relocs[2]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy); relocs[2]->howto = bfd_reloc_type_lookup (stdoutput, @@ -1546,7 +1546,7 @@ tc_gen_reloc (asection *section, fixS *fixp) case R_N0SEL: case R_N1SEL: /* There is no symbol or addend associated with these fixups. */ - relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + relocs[i]->sym_ptr_ptr = XNEW (asymbol *); *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol); relocs[i]->addend = 0; break; @@ -1555,7 +1555,7 @@ tc_gen_reloc (asection *section, fixS *fixp) case R_ENTRY: case R_EXIT: /* There is no symbol associated with these fixups. */ - relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + relocs[i]->sym_ptr_ptr = XNEW (asymbol *); *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol); relocs[i]->addend = fixp->fx_offset; break; @@ -1608,7 +1608,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, valueT md_section_align (asection *segment, valueT size) { - int align = bfd_get_section_alignment (stdoutput, segment); + int align = bfd_section_alignment (segment); int align2 = (1 << align) - 1; return (size + align2) & ~align2; @@ -1653,7 +1653,7 @@ struct option md_longopts[] = size_t md_longopts_size = sizeof (md_longopts); int -md_parse_option (int c, char *arg ATTRIBUTE_UNUSED) +md_parse_option (int c, const char *arg ATTRIBUTE_UNUSED) { switch (c) { @@ -3505,8 +3505,9 @@ pa_ip (char *str) /* M bit is explicit in the major opcode. */ INSERT_FIELD_AND_CONTINUE (opcode, a, 2); } - else if (*args == 'e') + else { + gas_assert (*args == 'e'); /* Stash the ma/mb flag temporarily in the instruction. We will use (and remove it) later when handling 'J', 'K', '<' & '>'. */ @@ -5215,9 +5216,7 @@ pa_ip (char *str) s = expr_end; CHECK_FIELD (num, 63, 0, strict); if (num & 0x20) - ; - else - opcode |= (1 << 13); + opcode &= ~(1 << 13); INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 21); /* Handle a 5 bit immediate at 10. */ @@ -5431,6 +5430,7 @@ pa_ip (char *str) { case SGL: opcode |= 0x20; + /* Fall through. */ case DBL: the_insn.fpof1 = flag; continue; @@ -5685,7 +5685,7 @@ pa_ip (char *str) /* If this instruction is specific to a particular architecture, then set a new architecture. This automatic promotion crud is for compatibility with HP's old assemblers only. */ - if (match == TRUE + if (match && bfd_get_mach (stdoutput) < insn->arch && !bfd_set_arch_mach (stdoutput, bfd_arch_hppa, insn->arch)) { @@ -5962,7 +5962,7 @@ pa_build_unwind_subspace (struct call_info *call_info) char *name, *p; symbolS *symbolP; - if ((bfd_get_section_flags (stdoutput, now_seg) + if ((bfd_section_flags (now_seg) & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) != (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) return; @@ -5974,11 +5974,8 @@ pa_build_unwind_subspace (struct call_info *call_info) /* Replace the start symbol with a local symbol that will be reduced to a section offset. This avoids problems with weak functions with multiple definitions, etc. */ - name = xmalloc (strlen ("L$\001start_") - + strlen (S_GET_NAME (call_info->start_symbol)) - + 1); - strcpy (name, "L$\001start_"); - strcat (name, S_GET_NAME (call_info->start_symbol)); + name = concat ("L$\001start_", S_GET_NAME (call_info->start_symbol), + (char *) NULL); /* If we have a .procend preceded by a .exit, then the symbol will have already been defined. In that case, we don't want another unwind @@ -5992,7 +5989,8 @@ pa_build_unwind_subspace (struct call_info *call_info) else { symbolP = symbol_new (name, now_seg, - S_GET_VALUE (call_info->start_symbol), frag_now); + S_GET_VALUE (call_info->start_symbol), + symbol_get_frag (call_info->start_symbol)); gas_assert (symbolP); S_CLEAR_EXTERNAL (symbolP); symbol_table_insert (symbolP); @@ -6008,10 +6006,9 @@ pa_build_unwind_subspace (struct call_info *call_info) if (seg == ASEC_NULL) { seg = subseg_new (UNWIND_SECTION_NAME, 0); - bfd_set_section_flags (stdoutput, seg, - SEC_READONLY | SEC_HAS_CONTENTS - | SEC_LOAD | SEC_RELOC | SEC_ALLOC | SEC_DATA); - bfd_set_section_alignment (stdoutput, seg, 2); + bfd_set_section_flags (seg, (SEC_READONLY | SEC_HAS_CONTENTS | SEC_LOAD + | SEC_RELOC | SEC_ALLOC | SEC_DATA)); + bfd_set_section_alignment (seg, 2); } subseg_set (seg, 0); @@ -6414,6 +6411,7 @@ hppa_elf_mark_end_of_function (void) /* ELF does not have EXIT relocations. All we do is create a temporary symbol marking the end of the function. */ char *name; + symbolS *symbolP; if (last_call_info == NULL || last_call_info->start_symbol == NULL) { @@ -6422,48 +6420,37 @@ hppa_elf_mark_end_of_function (void) return; } - name = xmalloc (strlen ("L$\001end_") - + strlen (S_GET_NAME (last_call_info->start_symbol)) - + 1); - if (name) - { - symbolS *symbolP; - - strcpy (name, "L$\001end_"); - strcat (name, S_GET_NAME (last_call_info->start_symbol)); + name = concat ("L$\001end_", S_GET_NAME (last_call_info->start_symbol), + (char *) NULL); - /* If we have a .exit followed by a .procend, then the - symbol will have already been defined. */ - symbolP = symbol_find (name); - if (symbolP) - { - /* The symbol has already been defined! This can - happen if we have a .exit followed by a .procend. - - This is *not* an error. All we want to do is free - the memory we just allocated for the name and continue. */ - xfree (name); - } - else - { - /* symbol value should be the offset of the - last instruction of the function */ - symbolP = symbol_new (name, now_seg, (valueT) (frag_now_fix () - 4), - frag_now); - - gas_assert (symbolP); - S_CLEAR_EXTERNAL (symbolP); - symbol_table_insert (symbolP); - } + /* If we have a .exit followed by a .procend, then the + symbol will have already been defined. */ + symbolP = symbol_find (name); + if (symbolP) + { + /* The symbol has already been defined! This can + happen if we have a .exit followed by a .procend. - if (symbolP) - last_call_info->end_symbol = symbolP; - else - as_bad (_("Symbol '%s' could not be created."), name); + This is *not* an error. All we want to do is free + the memory we just allocated for the name and continue. */ + xfree (name); + } + else + { + /* symbol value should be the offset of the + last instruction of the function */ + symbolP = symbol_new (name, now_seg, (valueT) (frag_now_fix () - 4), + frag_now); + gas_assert (symbolP); + S_CLEAR_EXTERNAL (symbolP); + symbol_table_insert (symbolP); } + + if (symbolP) + last_call_info->end_symbol = symbolP; else - as_bad (_("No memory for symbol name.")); + as_bad (_("Symbol '%s' could not be created."), name); } #endif @@ -6925,7 +6912,7 @@ pa_proc (int unused ATTRIBUTE_UNUSED) within_procedure = TRUE; /* Create another call_info structure. */ - call_info = xmalloc (sizeof (struct call_info)); + call_info = XNEW (struct call_info); if (!call_info) as_fatal (_("Cannot allocate unwind descriptor\n")); @@ -7036,7 +7023,7 @@ pa_procend (int unused ATTRIBUTE_UNUSED) #ifdef OBJ_ELF /* ELF needs to mark the end of each function so that it can compute - the size of the function (apparently its needed in the symbol table). */ + the size of the function (apparently it's needed in the symbol table). */ hppa_elf_mark_end_of_function (); #endif @@ -7080,7 +7067,7 @@ pa_check_current_space_and_subspace (void) by the parameters to the .SPACE directive. */ static sd_chain_struct * -pa_parse_space_stmt (char *space_name, int create_flag) +pa_parse_space_stmt (const char *space_name, int create_flag) { char *name, *ptemp, c; char loadable, defined, private, sort; @@ -7300,8 +7287,7 @@ pa_space (int unused ATTRIBUTE_UNUSED) print_errors = 1; input_line_pointer = save_s; c = get_symbol_name (&name); - space_name = xmalloc (strlen (name) + 1); - strcpy (space_name, name); + space_name = xstrdup (name); (void) restore_line_pointer (c); sd_chain = pa_parse_space_stmt (space_name, 1); @@ -7365,8 +7351,7 @@ pa_subspace (int create_new) else { c = get_symbol_name (&name); - ss_name = xmalloc (strlen (name) + 1); - strcpy (ss_name, name); + ss_name = xstrdup (name); (void) restore_line_pointer (c); /* Load default values. */ @@ -7547,14 +7532,13 @@ pa_subspace (int create_new) seg_info (section)->bss = 1; /* Now set the flags. */ - bfd_set_section_flags (stdoutput, section, applicable); + bfd_set_section_flags (section, applicable); /* Record any alignment request for this section. */ record_alignment (section, exact_log2 (alignment)); /* Set the starting offset for this section. */ - bfd_set_section_vma (stdoutput, section, - pa_subspace_start (space, quadrant)); + bfd_set_section_vma (section, pa_subspace_start (space, quadrant)); /* Now that all the flags are set, update an existing subspace, or create a new one. */ @@ -7592,7 +7576,7 @@ pa_spaces_begin (void) i = 0; while (pa_def_spaces[i].name) { - char *name; + const char *name; /* Pick the right name to use for the new section. */ name = pa_def_spaces[i].name; @@ -7608,7 +7592,7 @@ pa_spaces_begin (void) i = 0; while (pa_def_subspaces[i].name) { - char *name; + const char *name; int applicable, subsegment; asection *segment = NULL; sd_chain_struct *space; @@ -7628,7 +7612,7 @@ pa_spaces_begin (void) { text_section = segment; applicable = bfd_applicable_section_flags (stdoutput); - bfd_set_section_flags (stdoutput, segment, + bfd_set_section_flags (segment, applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_READONLY @@ -7638,7 +7622,7 @@ pa_spaces_begin (void) { data_section = segment; applicable = bfd_applicable_section_flags (stdoutput); - bfd_set_section_flags (stdoutput, segment, + bfd_set_section_flags (segment, applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS)); @@ -7648,13 +7632,13 @@ pa_spaces_begin (void) { bss_section = segment; applicable = bfd_applicable_section_flags (stdoutput); - bfd_set_section_flags (stdoutput, segment, + bfd_set_section_flags (segment, applicable & SEC_ALLOC); } else if (!strcmp (pa_def_subspaces[i].name, "$LIT$")) { applicable = bfd_applicable_section_flags (stdoutput); - bfd_set_section_flags (stdoutput, segment, + bfd_set_section_flags (segment, applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY @@ -7663,7 +7647,7 @@ pa_spaces_begin (void) else if (!strcmp (pa_def_subspaces[i].name, "$MILLICODE$")) { applicable = bfd_applicable_section_flags (stdoutput); - bfd_set_section_flags (stdoutput, segment, + bfd_set_section_flags (segment, applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY @@ -7672,7 +7656,7 @@ pa_spaces_begin (void) else if (!strcmp (pa_def_subspaces[i].name, "$UNWIND$")) { applicable = bfd_applicable_section_flags (stdoutput); - bfd_set_section_flags (stdoutput, segment, + bfd_set_section_flags (segment, applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY @@ -7709,7 +7693,7 @@ pa_spaces_begin (void) by the given parameters. */ static sd_chain_struct * -create_new_space (char *name, +create_new_space (const char *name, int spnum, int loadable ATTRIBUTE_UNUSED, int defined, @@ -7720,13 +7704,8 @@ create_new_space (char *name, { sd_chain_struct *chain_entry; - chain_entry = xmalloc (sizeof (sd_chain_struct)); - if (!chain_entry) - as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"), - name); - - SPACE_NAME (chain_entry) = xmalloc (strlen (name) + 1); - strcpy (SPACE_NAME (chain_entry), name); + chain_entry = XNEW (sd_chain_struct); + SPACE_NAME (chain_entry) = xstrdup (name); SPACE_DEFINED (chain_entry) = defined; SPACE_USER_DEFINED (chain_entry) = user_defined; SPACE_SPNUM (chain_entry) = spnum; @@ -7792,7 +7771,7 @@ create_new_space (char *name, static ssd_chain_struct * create_new_subspace (sd_chain_struct *space, - char *name, + const char *name, int loadable ATTRIBUTE_UNUSED, int code_only ATTRIBUTE_UNUSED, int comdat, @@ -7808,12 +7787,8 @@ create_new_subspace (sd_chain_struct *space, { ssd_chain_struct *chain_entry; - chain_entry = xmalloc (sizeof (ssd_chain_struct)); - if (!chain_entry) - as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name); - - SUBSPACE_NAME (chain_entry) = xmalloc (strlen (name) + 1); - strcpy (SUBSPACE_NAME (chain_entry), name); + chain_entry = XNEW (ssd_chain_struct); + SUBSPACE_NAME (chain_entry) = xstrdup (name); /* Initialize subspace_defined. When we hit a .subspace directive we'll set it to 1 which "locks-in" the subspace attributes. */ @@ -7897,7 +7872,7 @@ update_subspace (sd_chain_struct *space, NULL if no such space exists. */ static sd_chain_struct * -is_defined_space (char *name) +is_defined_space (const char *name) { sd_chain_struct *chain_pointer; @@ -7946,7 +7921,7 @@ pa_segment_to_space (asection *seg) own subspace. */ static ssd_chain_struct * -is_defined_subspace (char *name) +is_defined_subspace (const char *name) { sd_chain_struct *space_chain; ssd_chain_struct *subspace_chain; @@ -8552,7 +8527,7 @@ pa_vtable_entry (int ignore ATTRIBUTE_UNUSED) { struct fix *new_fix; - new_fix = obj_elf_vtable_entry (0); + new_fix = obj_elf_get_vtable_entry (); if (new_fix) { @@ -8573,7 +8548,7 @@ pa_vtable_inherit (int ignore ATTRIBUTE_UNUSED) { struct fix *new_fix; - new_fix = obj_elf_vtable_inherit (0); + new_fix = obj_elf_get_vtable_inherit (); if (new_fix) {