aboutsummaryrefslogtreecommitdiff
path: root/gas/config/obj-coff.c
diff options
context:
space:
mode:
authorTrevor Saunders <tbsaunde+binutils@tbsaunde.org>2016-03-28 05:49:15 -0400
committerTrevor Saunders <tbsaunde+binutils@tbsaunde.org>2016-05-13 00:35:51 -0400
commit29a2809e4210d5055291e95de861b493c55b9c0a (patch)
tree7b64ff6421a379f7ad2568e8648f6be1ffa99a12 /gas/config/obj-coff.c
parent59441ccdbd5d74575ae0149c6cf7b4663b56ff6d (diff)
downloadgdb-29a2809e4210d5055291e95de861b493c55b9c0a.zip
gdb-29a2809e4210d5055291e95de861b493c55b9c0a.tar.gz
gdb-29a2809e4210d5055291e95de861b493c55b9c0a.tar.bz2
use xstrdup, xmemdup0 and concat more
gas/ChangeLog: 2016-05-13 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * config/obj-coff.c (obj_coff_def): Simplify string copying. (weak_name2altname): Likewise. (weak_uniquify): Likewise. (obj_coff_section): Likewise. (obj_coff_init_stab_section): Likewise. * config/obj-elf.c (obj_elf_section_name): Likewise. (obj_elf_init_stab_section): Likewise. * config/obj-evax.c (evax_shorten_name): Likewise. * config/obj-macho.c (obj_mach_o_make_or_get_sect): Likewise. * config/tc-aarch64.c (create_register_alias): Likewise. * config/tc-alpha.c (load_expression): Likewise. (s_alpha_file): Likewise. (s_alpha_section_name): Likewise. (tc_gen_reloc): Likewise. * config/tc-arc.c (md_assemble): Likewise. * config/tc-arm.c (create_neon_reg_alias): Likewise. (start_unwind_section): Likewise. * config/tc-hppa.c (pa_build_unwind_subspace): Likewise. (hppa_elf_mark_end_of_function): Likewise. * config/tc-nios2.c (nios2_modify_arg): Likewise. (nios2_negate_arg): Likewise. * config/tc-rx.c (rx_section): Likewise. * config/tc-sh64.c (sh64_consume_datalabel): Likewise. * config/tc-tic30.c (tic30_find_parallel_insn): Likewise. * config/tc-tic54x.c (tic54x_include): Likewise. (tic54x_macro_info): Likewise. (subsym_get_arg): Likewise. (subsym_substitute): Likewise. (tic54x_start_line_hook): Likewise. * config/tc-xtensa.c (xtensa_literal_prefix): Likewise. (xg_reverse_shift_count): Likewise. * config/xtensa-relax.c (enter_opname_n): Likewise. (split_string): Likewise. * dwarf2dbg.c (get_filenum): Likewise. (process_entries): Likewise. * expr.c (operand): Likewise. * itbl-ops.c (alloc_entry): Likewise. * listing.c (listing_message): Likewise. (listing_title): Likewise. * macro.c (check_macro): Likewise. * stabs.c (s_xstab): Likewise. * symbols.c (symbol_relc_make_expr): Likewise. * write.c (compress_debug): Likewise.
Diffstat (limited to 'gas/config/obj-coff.c')
-rw-r--r--gas/config/obj-coff.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 03be655..059f1cc 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -592,7 +592,6 @@ obj_coff_def (int what ATTRIBUTE_UNUSED)
char name_end; /* Char after the end of name. */
char *symbol_name; /* Name of the debug symbol. */
char *symbol_name_copy; /* Temporary copy of the name. */
- unsigned int symbol_name_length;
if (def_symbol_in_progress != NULL)
{
@@ -604,9 +603,7 @@ obj_coff_def (int what ATTRIBUTE_UNUSED)
SKIP_WHITESPACES ();
name_end = get_symbol_name (&symbol_name);
- symbol_name_length = strlen (symbol_name);
- symbol_name_copy = xmalloc (symbol_name_length + 1);
- strcpy (symbol_name_copy, symbol_name);
+ symbol_name_copy = xstrdup (symbol_name);
#ifdef tc_canonicalize_symbol_name
symbol_name_copy = tc_canonicalize_symbol_name (symbol_name_copy);
#endif
@@ -1083,11 +1080,7 @@ weak_is_altname (const char * name)
static const char *
weak_name2altname (const char * name)
{
- char *alt_name;
-
- alt_name = xmalloc (sizeof (weak_altprefix) + strlen (name));
- strcpy (alt_name, weak_altprefix);
- return strcat (alt_name, name);
+ return concat (weak_altprefix, name, (char *) NULL);
}
/* Return the name of the weak symbol corresponding to an
@@ -1115,11 +1108,7 @@ weak_uniquify (const char * name)
#endif
gas_assert (weak_is_altname (name));
- ret = xmalloc (strlen (name) + strlen (unique) + 2);
- strcpy (ret, name);
- strcat (ret, ".");
- strcat (ret, unique);
- return ret;
+ return concat (name, ".", unique, (char *) NULL);
}
void
@@ -1562,8 +1551,7 @@ obj_coff_section (int ignore ATTRIBUTE_UNUSED)
}
c = get_symbol_name (&section_name);
- name = xmalloc (input_line_pointer - section_name + 1);
- strcpy (name, section_name);
+ name = xmemdup0 (section_name, input_line_pointer - section_name);
*input_line_pointer = c;
SKIP_WHITESPACE_AFTER_NAME ();
@@ -1820,9 +1808,7 @@ obj_coff_init_stab_section (segT seg)
/* Zero it out. */
memset (p, 0, 12);
file = as_where ((unsigned int *) NULL);
- stabstr_name = xmalloc (strlen (seg->name) + 4);
- strcpy (stabstr_name, seg->name);
- strcat (stabstr_name, "str");
+ stabstr_name = concat (seg->name, "str", (char *) NULL);
stroff = get_stab_string_offset (file, stabstr_name);
know (stroff == 1);
md_number_to_chars (p, stroff, 4);