+2021-04-01 Martin Liska <mliska@suse.cz>
+
+ * as.c (select_emulation_mode): Use startswith.
+ * config/m68k-parse.y: Likewise.
+ * config/obj-aout.c (obj_aout_type): Likewise.
+ * config/obj-elf.c (elf_common_parse): Likewise.
+ (obj_elf_section_type): Likewise.
+ (obj_elf_section_word): Likewise.
+ (obj_elf_section): Likewise.
+ (obj_elf_symver): Likewise.
+ (adjust_stab_sections): Likewise.
+ * config/obj-evax.c (evax_shorten_name): Likewise.
+ * config/obj-macho.c (obj_mach_o_is_frame_section): Likewise.
+ * config/tc-aarch64.c (parse_aarch64_imm_float): Likewise.
+ (aarch64_parse_features): Likewise.
+ (create_register_alias): Likewise.
+ (aarch64_data_in_code): Likewise.
+ (md_parse_option): Likewise.
+ * config/tc-alpha.c (s_alpha_section_word): Likewise.
+ (s_alpha_pdesc): Likewise.
+ * config/tc-arc.c (tokenize_extregister): Likewise.
+ * config/tc-arm.c (create_register_alias): Likewise.
+ (create_neon_reg_alias): Likewise.
+ (parse_ifimm_zero): Likewise.
+ (parse_qfloat_immediate): Likewise.
+ (arm_elf_section_type): Likewise.
+ (arm_parse_extension): Likewise.
+ (aeabi_set_public_attributes): Likewise.
+ (s_arm_arch_extension): Likewise.
+ (arm_data_in_code): Likewise.
+ (start_unwind_section): Likewise.
+ * config/tc-avr.c (avr_ldi_expression): Likewise.
+ * config/tc-csky.c (is_freglist_legal): Likewise.
+ (csky_s_section): Likewise.
+ * config/tc-d30v.c (do_assemble): Likewise.
+ * config/tc-dlx.c (parse_operand): Likewise.
+ * config/tc-epiphany.c (md_assemble): Likewise.
+ * config/tc-h8300.c (h8300_elf_section): Likewise.
+ (get_operand): Likewise.
+ * config/tc-hppa.c (pa_ip): Likewise.
+ (pa_level): Likewise.
+ (pa_space): Likewise.
+ * config/tc-i386.c (i386_mach): Likewise.
+ (md_assemble): Likewise.
+ (check_VecOperations): Likewise.
+ (i386_target_format): Likewise.
+ (i386_elf_section_type): Likewise.
+ * config/tc-ia64.c (start_unwind_section): Likewise.
+ (md_parse_option): Likewise.
+ (is_taken_branch): Likewise.
+ (idesc->name,): Likewise.
+ (note_register_values): Likewise.
+ (do_alias): Likewise.
+ * config/tc-m32c.c (insn_to_subtype): Likewise.
+ * config/tc-m68hc11.c (get_operand): Likewise.
+ (md_assemble): Likewise.
+ * config/tc-m68k.c (m68k_ip): Likewise.
+ (m68k_elf_suffix): Likewise.
+ * config/tc-mcore.c (mcore_s_section): Likewise.
+ * config/tc-metag.c (parse_get_set): Likewise.
+ (md_parse_option): Likewise.
+ * config/tc-microblaze.c (parse_imm): Likewise.
+ (check_got): Likewise.
+ (md_apply_fix): Likewise.
+ * config/tc-mips.c (CPU_HAS_MIPS16): Likewise.
+ (md_begin): Likewise.
+ (s_is_linkonce): Likewise.
+ (check_regno): Likewise.
+ (match_float_constant): Likewise.
+ (classify_vr4120_insn): Likewise.
+ (match_insn): Likewise.
+ (mips_after_parse_args): Likewise.
+ (s_change_sec): Likewise.
+ (s_option): Likewise.
+ (parse_code_option): Likewise.
+ (md_section_align): Likewise.
+ (nopic_need_relax): Likewise.
+ * config/tc-mmix.c (mmix_handle_mmixal): Likewise.
+ * config/tc-mn10300.c (mn10300_fix_adjustable): Likewise.
+ (mn10300_end_of_match): Likewise.
+ * config/tc-msp430.c (msp430_make_init_symbols): Likewise.
+ * config/tc-nds32.c (nds32_parse_option): Likewise.
+ * config/tc-nds32.h (md_do_align): Likewise.
+ * config/tc-nios2.c (strprefix): Likewise.
+ (nios2_special_relocation_p): Likewise.
+ (nios2_parse_base_register): Likewise.
+ (nios2_cons): Likewise.
+ * config/tc-ns32k.c (addr_mode): Likewise.
+ * config/tc-pdp11.c (set_option): Likewise.
+ (parse_reg): Likewise.
+ (parse_ac5): Likewise.
+ (parse_op_no_deferred): Likewise.
+ (set_cpu_model): Likewise.
+ (set_machine_model): Likewise.
+ * config/tc-pj.c (md_operand): Likewise.
+ * config/tc-ppc.c (ppc_set_cpu): Likewise.
+ (ppc_arch): Likewise.
+ (ppc_section_type): Likewise.
+ * config/tc-s12z.c (tb_reg_rel): Likewise.
+ (tb_opr_rel): Likewise.
+ * config/tc-s390.c (s390_parse_cpu): Likewise.
+ (md_parse_option): Likewise.
+ * config/tc-score.c (s3_nopic_need_relax): Likewise.
+ (s3_pic_need_relax): Likewise.
+ * config/tc-score7.c (s7_nopic_need_relax): Likewise.
+ (s7_pic_need_relax): Likewise.
+ * config/tc-sh.h (SUB_SEGMENT_ALIGN): Likewise.
+ * config/tc-sparc.c (md_parse_option): Likewise.
+ (sparc_ip): Likewise.
+ (s_reserve): Likewise.
+ (s_common): Likewise.
+ (s_seg): Likewise.
+ (sparc_cons): Likewise.
+ * config/tc-tic54x.c (stag_add_field): Likewise.
+ (tic54x_endstruct): Likewise.
+ * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
+ * config/tc-v850.c (v850_comm): Likewise.
+ (md_begin): Likewise.
+ (md_assemble): Likewise.
+ * config/tc-vax.c (vax_cons): Likewise.
+ * config/tc-wasm32.c (wasm32_leb128): Likewise.
+ * config/tc-xstormy16.c (md_operand): Likewise.
+ * config/tc-xtensa.c (get_directive): Likewise.
+ (xg_instruction_matches_option_term): Likewise.
+ (is_unaligned_label): Likewise.
+ (cache_literal_section): Likewise.
+ * config/xtensa-relax.c (parse_precond): Likewise.
+ (parse_option_cond): Likewise.
+ (transition_applies): Likewise.
+ (wide_branch_opcode): Likewise.
+ * dw2gencfi.c: Likewise.
+ * dwarf2dbg.c (dwarf2_directive_filename): Likewise.
+ * ehopt.c (get_cie_info): Likewise.
+ * input-file.c (input_file_open): Likewise.
+ * listing.c (listing_newline): Likewise.
+ (debugging_pseudo): Likewise.
+ * read.c (read_a_source_file): Likewise.
+ * write.c (adjust_reloc_syms): Likewise.
+ (compress_debug): Likewise.
+ (maybe_generate_build_notes): Likewise.
+
2021-03-31 Alan Modra <amodra@gmail.com>
* itbl-lex-wrapper.c: Include as.h not sysdep.h.
const char *em = NULL;
for (i = 1; i < argc; i++)
- if (!strncmp ("--em", argv[i], 4))
+ if (startswith (argv[i], "--em"))
break;
if (i == argc)
/* We end up here for any -gsomething-not-already-a-long-option.
give some useful feedback on not (yet) supported -gdwarfxxx
versions/sections/options. */
- if (strncmp (old_argv[optind - 1], "-gdwarf",
- strlen ("-gdwarf")) == 0)
+ if (startswith (old_argv[optind - 1], "-gdwarf"))
as_fatal (_("unknown DWARF option %s\n"), old_argv[optind - 1]);
if (md_debug_format_selector)
cp = s - tail;
if (cp - 7 > str && cp[-7] == '@')
{
- if (strncmp (cp - 7, "@TLSLDM", 7) == 0)
+ if (startswith (cp - 7, "@TLSLDM"))
{
yylval.exp.pic_reloc = pic_tls_ldm;
tail += 7;
}
- else if (strncmp (cp - 7, "@TLSLDO", 7) == 0)
+ else if (startswith (cp - 7, "@TLSLDO"))
{
yylval.exp.pic_reloc = pic_tls_ldo;
tail += 7;
}
else if (cp - 6 > str && cp[-6] == '@')
{
- if (strncmp (cp - 6, "@PLTPC", 6) == 0)
+ if (startswith (cp - 6, "@PLTPC"))
{
yylval.exp.pic_reloc = pic_plt_pcrel;
tail += 6;
}
- else if (strncmp (cp - 6, "@GOTPC", 6) == 0)
+ else if (startswith (cp - 6, "@GOTPC"))
{
yylval.exp.pic_reloc = pic_got_pcrel;
tail += 6;
}
- else if (strncmp (cp - 6, "@TLSGD", 6) == 0)
+ else if (startswith (cp - 6, "@TLSGD"))
{
yylval.exp.pic_reloc = pic_tls_gd;
tail += 6;
}
- else if (strncmp (cp - 6, "@TLSIE", 6) == 0)
+ else if (startswith (cp - 6, "@TLSIE"))
{
yylval.exp.pic_reloc = pic_tls_ie;
tail += 6;
}
- else if (strncmp (cp - 6, "@TLSLE", 6) == 0)
+ else if (startswith (cp - 6, "@TLSLE"))
{
yylval.exp.pic_reloc = pic_tls_le;
tail += 6;
}
else if (cp - 4 > str && cp[-4] == '@')
{
- if (strncmp (cp - 4, "@PLT", 4) == 0)
+ if (startswith (cp - 4, "@PLT"))
{
yylval.exp.pic_reloc = pic_plt_off;
tail += 4;
}
- else if (strncmp (cp - 4, "@GOT", 4) == 0)
+ else if (startswith (cp - 4, "@GOT"))
{
yylval.exp.pic_reloc = pic_got_off;
tail += 4;
if (*input_line_pointer == '@')
{
++input_line_pointer;
- if (strncmp (input_line_pointer, "object", 6) == 0)
+ if (startswith (input_line_pointer, "object"))
S_SET_OTHER (sym, 1);
- else if (strncmp (input_line_pointer, "function", 8) == 0)
+ else if (startswith (input_line_pointer, "function"))
S_SET_OTHER (sym, 2);
}
}
if (*input_line_pointer == '.')
input_line_pointer++;
/* Some say data, some say bss. */
- if (strncmp (input_line_pointer, "bss\"", 4) == 0)
+ if (startswith (input_line_pointer, "bss\""))
input_line_pointer += 4;
- else if (strncmp (input_line_pointer, "data\"", 5) == 0)
+ else if (startswith (input_line_pointer, "data\""))
input_line_pointer += 5;
else
{
static int
obj_elf_section_type (char *str, size_t len, bool warn)
{
- if (len == 8 && strncmp (str, "progbits", 8) == 0)
+ if (len == 8 && startswith (str, "progbits"))
return SHT_PROGBITS;
- if (len == 6 && strncmp (str, "nobits", 6) == 0)
+ if (len == 6 && startswith (str, "nobits"))
return SHT_NOBITS;
- if (len == 4 && strncmp (str, "note", 4) == 0)
+ if (len == 4 && startswith (str, "note"))
return SHT_NOTE;
- if (len == 10 && strncmp (str, "init_array", 10) == 0)
+ if (len == 10 && startswith (str, "init_array"))
return SHT_INIT_ARRAY;
- if (len == 10 && strncmp (str, "fini_array", 10) == 0)
+ if (len == 10 && startswith (str, "fini_array"))
return SHT_FINI_ARRAY;
- if (len == 13 && strncmp (str, "preinit_array", 13) == 0)
+ if (len == 13 && startswith (str, "preinit_array"))
return SHT_PREINIT_ARRAY;
#ifdef md_elf_section_type
{
int ret;
- if (len == 5 && strncmp (str, "write", 5) == 0)
+ if (len == 5 && startswith (str, "write"))
return SHF_WRITE;
- if (len == 5 && strncmp (str, "alloc", 5) == 0)
+ if (len == 5 && startswith (str, "alloc"))
return SHF_ALLOC;
- if (len == 9 && strncmp (str, "execinstr", 9) == 0)
+ if (len == 9 && startswith (str, "execinstr"))
return SHF_EXECINSTR;
- if (len == 7 && strncmp (str, "exclude", 7) == 0)
+ if (len == 7 && startswith (str, "exclude"))
return SHF_EXCLUDE;
- if (len == 3 && strncmp (str, "tls", 3) == 0)
+ if (len == 3 && startswith (str, "tls"))
return SHF_TLS;
#ifdef md_elf_section_word
{
++input_line_pointer;
SKIP_WHITESPACE ();
- if (strncmp (input_line_pointer, "comdat", 6) == 0)
+ if (startswith (input_line_pointer, "comdat"))
{
input_line_pointer += 6;
linkonce = 1;
}
}
- else if (strncmp (name, ".gnu.linkonce", 13) == 0)
+ else if (startswith (name, ".gnu.linkonce"))
linkonce = 1;
}
else if ((attr & SHF_GROUP) != 0)
++input_line_pointer;
SKIP_WHITESPACE ();
- if (strncmp (input_line_pointer, "unique", 6) == 0)
+ if (startswith (input_line_pointer, "unique"))
{
input_line_pointer += 6;
SKIP_WHITESPACE ();
++input_line_pointer;
SKIP_WHITESPACE ();
- if (strncmp (input_line_pointer, "local", 5) == 0)
+ if (startswith (input_line_pointer, "local"))
{
input_line_pointer += 5;
sy_obj->visibility = visibility_local;
}
- else if (strncmp (input_line_pointer, "hidden", 6) == 0)
+ else if (startswith (input_line_pointer, "hidden"))
{
input_line_pointer += 6;
sy_obj->visibility = visibility_hidden;
}
- else if (strncmp (input_line_pointer, "remove", 6) == 0)
+ else if (startswith (input_line_pointer, "remove"))
{
input_line_pointer += 6;
sy_obj->visibility = visibility_remove;
char *p;
int strsz, nsyms;
- if (strncmp (".stab", sec->name, 5))
+ if (!startswith (sec->name, ".stab"))
return;
if (!strcmp ("str", sec->name + strlen (sec->name) - 3))
return;
prefix [0] = 0;
/* Check for ..xx suffix and save it. */
- if (strncmp (&id[len-4], "..", 2) == 0)
+ if (startswith (&id[len-4], ".."))
{
suffix_dotdot = len - 4;
strncpy (suffix, &id[len-4], 4);
{
int l;
l = strlen (segment_name (sec));
- if ((l == 9 && strncmp (".eh_frame", segment_name (sec), 9) == 0)
- || (l == 12 && strncmp (".debug_frame", segment_name (sec), 12) == 0))
+ if ((l == 9 && startswith (segment_name (sec), ".eh_frame"))
+ || (l == 12 && startswith (segment_name (sec), ".debug_frame")))
return 1;
return 0;
}
/* The input scrubber ensures that whitespace after the mnemonic is
collapsed to single spaces. */
oldname = p;
- if (strncmp (oldname, " .req ", 6) != 0)
+ if (!startswith (oldname, " .req "))
return false;
oldname += 6;
fpnum = str;
skip_whitespace (fpnum);
- if (strncmp (fpnum, "0x", 2) == 0)
+ if (startswith (fpnum, "0x"))
{
/* Support the hexadecimal representation of the IEEE754 encoding.
Double-precision is expected when DP_P is TRUE, otherwise the
int
aarch64_data_in_code (void)
{
- if (!strncmp (input_line_pointer + 1, "data:", 5))
+ if (startswith (input_line_pointer + 1, "data:"))
{
*input_line_pointer = '/';
input_line_pointer += 5;
else
optlen = strlen (str);
- if (optlen >= 2 && strncmp (str, "no", 2) == 0)
+ if (optlen >= 2 && startswith (str, "no"))
{
if (adding_value != 0)
adding_value = 0;
/* These options are expected to have an argument. */
if (c == lopt->option[0]
&& arg != NULL
- && strncmp (arg, lopt->option + 1,
- strlen (lopt->option + 1)) == 0)
+ && startswith (arg, lopt->option + 1))
{
/* If the option is deprecated, tell the user. */
if (lopt->deprecated != NULL)
int no = 0;
flagword flag = 0;
- if (len == 5 && strncmp (str, "NO", 2) == 0)
+ if (len == 5 && startswith (str, "NO"))
{
no = 1;
str += 2;
if (len == 3)
{
- if (strncmp (str, "PIC", 3) == 0)
+ if (startswith (str, "PIC"))
flag = EGPS__V_PIC;
- else if (strncmp (str, "LIB", 3) == 0)
+ else if (startswith (str, "LIB"))
flag = EGPS__V_LIB;
- else if (strncmp (str, "OVR", 3) == 0)
+ else if (startswith (str, "OVR"))
flag = EGPS__V_OVR;
- else if (strncmp (str, "REL", 3) == 0)
+ else if (startswith (str, "REL"))
flag = EGPS__V_REL;
- else if (strncmp (str, "GBL", 3) == 0)
+ else if (startswith (str, "GBL"))
flag = EGPS__V_GBL;
- else if (strncmp (str, "SHR", 3) == 0)
+ else if (startswith (str, "SHR"))
flag = EGPS__V_SHR;
- else if (strncmp (str, "EXE", 3) == 0)
+ else if (startswith (str, "EXE"))
flag = EGPS__V_EXE;
- else if (strncmp (str, "WRT", 3) == 0)
+ else if (startswith (str, "WRT"))
flag = EGPS__V_WRT;
- else if (strncmp (str, "VEC", 3) == 0)
+ else if (startswith (str, "VEC"))
flag = EGPS__V_VEC;
- else if (strncmp (str, "MOD", 3) == 0)
+ else if (startswith (str, "MOD"))
{
flag = no ? EGPS__V_NOMOD : EGPS__V_NOMOD << EGPS__V_NO_SHIFT;
no = 0;
}
- else if (strncmp (str, "COM", 3) == 0)
+ else if (startswith (str, "COM"))
flag = EGPS__V_COM;
}
SKIP_WHITESPACE ();
name_end = get_symbol_name (&name);
- if (strncmp (name, "stack", 5) == 0)
+ if (startswith (name, "stack"))
alpha_evax_proc->pdsckind = PDSC_S_K_KIND_FP_STACK;
- else if (strncmp (name, "reg", 3) == 0)
+ else if (startswith (name, "reg"))
alpha_evax_proc->pdsckind = PDSC_S_K_KIND_FP_REGISTER;
- else if (strncmp (name, "null", 4) == 0)
+ else if (startswith (name, "null"))
alpha_evax_proc->pdsckind = PDSC_S_K_KIND_NULL;
else
input_line_pointer++;
mode = input_line_pointer;
- if (!strncmp (mode, "r|w", 3))
+ if (startswith (mode, "r|w"))
{
imode = 0;
input_line_pointer += 3;
}
- else if (!strncmp (mode, "r", 1))
+ else if (startswith (mode, "r"))
{
imode = ARC_REGISTER_READONLY;
input_line_pointer += 1;
}
- else if (strncmp (mode, "w", 1))
+ else if (!startswith (mode, "w"))
{
as_bad (_("invalid mode"));
ignore_rest_of_line ();
input_line_pointer++;
- if (!strncmp (input_line_pointer, "cannot_shortcut", 15))
+ if (startswith (input_line_pointer, "cannot_shortcut"))
{
imode |= ARC_REGISTER_NOSHORT_CUT;
input_line_pointer += 15;
}
- else if (strncmp (input_line_pointer, "can_shortcut", 12))
+ else if (!startswith (input_line_pointer, "can_shortcut"))
{
as_bad (_("shortcut designator invalid"));
ignore_rest_of_line ();
/* The input scrubber ensures that whitespace after the mnemonic is
collapsed to single spaces. */
oldname = p;
- if (strncmp (oldname, " .req ", 6) != 0)
+ if (!startswith (oldname, " .req "))
return false;
oldname += 6;
nameend = p;
- if (strncmp (p, " .dn ", 5) == 0)
+ if (startswith (p, " .dn "))
basetype = REG_TYPE_VFD;
- else if (strncmp (p, " .qn ", 5) == 0)
+ else if (startswith (p, " .qn "))
basetype = REG_TYPE_NQ;
else
return false;
++*in;
/* Accept #0x0 as a synonym for #0. */
- if (strncmp (*in, "0x", 2) == 0)
+ if (startswith (*in, "0x"))
{
int val;
if (parse_immediate (in, &val, 0, 0, true) == FAIL)
fpnum = str;
skip_whitespace (fpnum);
- if (strncmp (fpnum, "0x", 2) == 0)
+ if (startswith (fpnum, "0x"))
return FAIL;
else
{
bool
arm_data_in_code (void)
{
- if (thumb_mode && ! strncmp (input_line_pointer + 1, "data:", 5))
+ if (thumb_mode && startswith (input_line_pointer + 1, "data:"))
{
*input_line_pointer = '/';
input_line_pointer += 5;
int
arm_elf_section_type (const char * str, size_t len)
{
- if (len == 5 && strncmp (str, "exidx", 5) == 0)
+ if (len == 5 && startswith (str, "exidx"))
return SHT_ARM_EXIDX;
return -1;
if (streq (text_name, ".text"))
text_name = "";
- if (strncmp (text_name, ".gnu.linkonce.t.",
- strlen (".gnu.linkonce.t.")) == 0)
+ if (startswith (text_name, ".gnu.linkonce.t."))
{
prefix = prefix_once;
text_name += strlen (".gnu.linkonce.t.");
else
len = strlen (str);
- if (len >= 2 && strncmp (str, "no", 2) == 0)
+ if (len >= 2 && startswith (str, "no"))
{
if (adding_value != 0)
{
char *q;
q = selected_cpu_name;
- if (strncmp (q, "armv", 4) == 0)
+ if (startswith (q, "armv"))
{
int i;
*input_line_pointer = 0;
if (strlen (name) >= 2
- && strncmp (name, "no", 2) == 0)
+ && startswith (name, "no"))
{
adding_value = 0;
name += 2;
++str;
- if (strncmp ("pm(", str, 3) == 0
- || strncmp ("gs(",str,3) == 0
- || strncmp ("-(gs(",str,5) == 0
- || strncmp ("-(pm(", str, 5) == 0)
+ if (startswith (str, "pm(")
+ || startswith (str, "gs(")
+ || startswith (str, "-(gs(")
+ || startswith (str, "-(pm("))
{
if (HAVE_PM_P (mod))
{
reg2 = reg2 - reg1;
/* The fldm/fstm in CSKY_ISA_FLOAT_7E60 has 5 bits frz(reg1). */
shift = 4;
- if (strncmp (csky_insn.opcode->mnemonic, "fstm", 4) == 0
- || strncmp (csky_insn.opcode->mnemonic, "fldm", 4) == 0)
+ if (startswith (csky_insn.opcode->mnemonic, "fstm")
+ || startswith (csky_insn.opcode->mnemonic, "fldm"))
{
if ((!(isa_flag & CSKY_ISA_FLOAT_7E60)
&& (reg2 > (int)15 || reg1 > 15))
while (*ilp != 0 && ISSPACE (*ilp))
++ ilp;
- if (strncmp (ilp, ".line", 5) == 0
+ if (startswith (ilp, ".line")
&& (ISSPACE (ilp[5]) || *ilp == '\n' || *ilp == '\r'))
;
else
opcode->ecc = ECC_AL;
/* CMP and CMPU change their name based on condition codes. */
- if (!strncmp (name, "cmp", 3))
+ if (startswith (name, "cmp"))
{
int p, i;
char **d30v_str = (char **) d30v_cc_names;
the_insn.HI = the_insn.LO = 0;
/* Search for %hi and %lo, make a mark and skip it. */
- if (strncmp (s, "%hi", 3) == 0)
+ if (startswith (s, "%hi"))
{
s += 3;
the_insn.HI = 1;
}
else
{
- if (strncmp (s, "%lo", 3) == 0)
+ if (startswith (s, "%lo"))
{
s += 3;
the_insn.LO = 1;
int regmask=0, push=0, pop=0;
/* Special-case push/pop instruction macros. */
- if (0 == strncmp (str, "push {", 6))
+ if (startswith (str, "push {"))
{
char * s = str + 6;
push = 1;
pperr = parse_reglist (s, ®mask);
}
- else if (0 == strncmp (str, "pop {", 5))
+ else if (startswith (str, "pop {"))
{
char * s = str + 5;
pop = 1;
if (i < 0)
for (i = ARRAY_SIZE (known_data_prefixes); i--;)
- if (strncmp (name, known_data_prefixes[i],
- strlen (known_data_prefixes[i])) == 0)
+ if (startswith (name, known_data_prefixes[i]))
break;
if (i < 0)
*ptr = parse_exp (src + 1, op);
return;
}
- else if (strncmp (src, "mach", 4) == 0 ||
- strncmp (src, "macl", 4) == 0 ||
- strncmp (src, "MACH", 4) == 0 ||
- strncmp (src, "MACL", 4) == 0)
+ else if (startswith (src, "mach") ||
+ startswith (src, "macl") ||
+ startswith (src, "MACH") ||
+ startswith (src, "MACL"))
{
op->reg = TOLOWER (src[3]) == 'l';
op->mode = MACREG;
/* Handle load cache hint completer. */
case 'c':
cmpltr = 0;
- if (!strncmp (s, ",sl", 3))
+ if (startswith (s, ",sl"))
{
s += 3;
cmpltr = 2;
/* Handle store cache hint completer. */
case 'C':
cmpltr = 0;
- if (!strncmp (s, ",sl", 3))
+ if (startswith (s, ",sl"))
{
s += 3;
cmpltr = 2;
}
- else if (!strncmp (s, ",bc", 3))
+ else if (startswith (s, ",bc"))
{
s += 3;
cmpltr = 1;
/* Handle load and clear cache hint completer. */
case 'd':
cmpltr = 0;
- if (!strncmp (s, ",co", 3))
+ if (startswith (s, ",co"))
{
s += 3;
cmpltr = 1;
/* Handle load ordering completer. */
case 'o':
- if (strncmp (s, ",o", 2) != 0)
+ if (!startswith (s, ",o"))
break;
s += 2;
continue;
else if (*s == '*')
break;
- if (strncmp (s, "<", 1) == 0)
+ if (startswith (s, "<"))
{
cmpltr = 0;
s++;
}
- else if (strncmp (s, ">=", 2) == 0)
+ else if (startswith (s, ">="))
{
cmpltr = 1;
s += 2;
char *level;
level = input_line_pointer;
- if (strncmp (level, "1.0", 3) == 0)
+ if (startswith (level, "1.0"))
{
input_line_pointer += 3;
if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 10))
as_warn (_("could not set architecture and machine"));
}
- else if (strncmp (level, "1.1", 3) == 0)
+ else if (startswith (level, "1.1"))
{
input_line_pointer += 3;
if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 11))
as_warn (_("could not set architecture and machine"));
}
- else if (strncmp (level, "2.0w", 4) == 0)
+ else if (startswith (level, "2.0w"))
{
input_line_pointer += 4;
if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 25))
as_warn (_("could not set architecture and machine"));
}
- else if (strncmp (level, "2.0", 3) == 0)
+ else if (startswith (level, "2.0"))
{
input_line_pointer += 3;
if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 20))
and place them into a subroutine or something similar? */
/* FIXME Is this (and the next IF stmt) really right?
What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
- if (strncmp (input_line_pointer, "$TEXT$", 6) == 0)
+ if (startswith (input_line_pointer, "$TEXT$"))
{
input_line_pointer += 6;
sd_chain = is_defined_space ("$TEXT$");
demand_empty_rest_of_line ();
return;
}
- if (strncmp (input_line_pointer, "$PRIVATE$", 9) == 0)
+ if (startswith (input_line_pointer, "$PRIVATE$"))
{
input_line_pointer += 9;
sd_chain = is_defined_space ("$PRIVATE$");
unsigned long
i386_mach (void)
{
- if (!strncmp (default_arch, "x86_64", 6))
+ if (startswith (default_arch, "x86_64"))
{
if (cpu_arch_isa == PROCESSOR_L1OM)
{
&& i.operands > 1
&& (strcmp (mnemonic, "bound") != 0)
&& (strncmp (mnemonic, "invlpg", 6) != 0)
- && (strncmp (mnemonic, "monitor", 7) != 0)
- && (strncmp (mnemonic, "mwait", 5) != 0)
+ && !startswith (mnemonic, "monitor")
+ && !startswith (mnemonic, "mwait")
&& (strcmp (mnemonic, "pvalidate") != 0)
- && (strncmp (mnemonic, "rmp", 3) != 0)
+ && !startswith (mnemonic, "rmp")
&& (strcmp (mnemonic, "tpause") != 0)
&& (strcmp (mnemonic, "umwait") != 0)
&& !(operand_type_check (i.types[0], imm)
op_string++;
/* Check broadcasts. */
- if (strncmp (op_string, "1to", 3) == 0)
+ if (startswith (op_string, "1to"))
{
unsigned int bcst_type;
const char *
i386_target_format (void)
{
- if (!strncmp (default_arch, "x86_64", 6))
+ if (startswith (default_arch, "x86_64"))
{
update_code_flag (CODE_64BIT, 1);
if (default_arch[6] == '\0')
{
if (flag_code == CODE_64BIT
&& len == sizeof ("unwind") - 1
- && strncmp (str, "unwind", 6) == 0)
+ && startswith (str, "unwind"))
return SHT_X86_64_UNWIND;
return -1;
sec_text_name = segment_name (text_seg);
text_name = sec_text_name;
- if (strncmp (text_name, "_info", 5) == 0)
+ if (startswith (text_name, "_info"))
{
as_bad (_("Illegal section name `%s' (causes unwind section name clash)"),
text_name);
/* Build the unwind section name by appending the (possibly stripped)
text section name to the unwind prefix. */
suffix = text_name;
- if (strncmp (text_name, ".gnu.linkonce.t.",
- sizeof (".gnu.linkonce.t.") - 1) == 0)
+ if (startswith (text_name, ".gnu.linkonce.t."))
{
prefix = special_linkonce_name [sec_index - SPECIAL_SECTION_UNWIND];
suffix += sizeof (".gnu.linkonce.t.") - 1;
md.flags |= EF_IA_64_BE;
default_big_endian = 1;
}
- else if (strncmp (arg, "unwind-check=", 13) == 0)
+ else if (startswith (arg, "unwind-check="))
{
arg += 13;
if (strcmp (arg, "warning") == 0)
else
return 0;
}
- else if (strncmp (arg, "hint.b=", 7) == 0)
+ else if (startswith (arg, "hint.b="))
{
arg += 7;
if (strcmp (arg, "ok") == 0)
else
return 0;
}
- else if (strncmp (arg, "tune=", 5) == 0)
+ else if (startswith (arg, "tune="))
{
arg += 5;
if (strcmp (arg, "itanium1") == 0)
exit: branch out from the current context (default)
labels: all labels in context may be branch targets
*/
- if (strncmp (arg, "indirect=", 9) != 0)
+ if (!startswith (arg, "indirect="))
return 0;
break;
is_taken_branch (struct ia64_opcode *idesc)
{
return ((is_conditional_branch (idesc) && CURR_SLOT.qp_regno == 0)
- || strncmp (idesc->name, "br.ia", 5) == 0);
+ || startswith (idesc->name, "br.ia"));
}
/* Return whether the given opcode is an interruption or rfi. If there's any
/* FIXME we can identify some individual RSE written resources, but RSE
read resources have not yet been completely identified, so for now
treat RSE as a single resource */
- if (strncmp (idesc->name, "mov", 3) == 0)
+ if (startswith (idesc->name, "mov"))
{
if (rsrc_write)
{
}
/* After a call, all register values are undefined, except those marked
as "safe". */
- else if (strncmp (idesc->name, "br.call", 6) == 0
- || strncmp (idesc->name, "brl.call", 7) == 0)
+ else if (startswith (idesc->name, "br.call")
+ || startswith (idesc->name, "brl.call"))
{
/* FIXME keep GR values which are marked as "safe_across_calls" */
clear_register_values ();
/* Uses .alias extensively to alias CRTL functions to same with
decc$ prefix. Sometimes function gets optimized away and a
warning results, which should be suppressed. */
- if (strncmp (tuple->key, "decc$", 5) != 0)
+ if (!startswith (tuple->key, "decc$"))
#endif
as_warn_where (h->file, h->line,
_("symbol `%s' aliased to `%s' is not used"),
unsigned int i;
if (insn
- && (strncmp (insn->base->mnemonic, "adjnz", 5) == 0
- || strncmp (insn->base->mnemonic, "sbjnz", 5) == 0))
+ && (startswith (insn->base->mnemonic, "adjnz")
+ || startswith (insn->base->mnemonic, "sbjnz")))
{
i = 23 + insn->base->bitsize/8 - 3;
/*printf("mapping %d used for %s\n", i, insn->base->mnemonic);*/
mode = M6811_OP_IMM16;
p++;
- if (strncmp (p, "%hi", 3) == 0)
+ if (startswith (p, "%hi"))
{
p += 3;
mode |= M6811_OP_HIGH_ADDR;
}
- else if (strncmp (p, "%lo", 3) == 0)
+ else if (startswith (p, "%lo"))
{
p += 3;
mode |= M6811_OP_LOW_ADDR;
}
/* %page modifier is used to obtain only the page number
of the address of a function. */
- else if (strncmp (p, "%page", 5) == 0)
+ else if (startswith (p, "%page"))
{
p += 5;
mode |= M6811_OP_PAGE_ADDR;
mapped in the 16K window at 0x8000 and the value will be
within that window (although the function address may not fit
in 16-bit). See bfd/elf32-m68hc12.c for the translation. */
- else if (strncmp (p, "%addr", 5) == 0)
+ else if (startswith (p, "%addr"))
{
p += 5;
mode |= M6811_OP_CALL_ADDR;
return -1;
}
/* Handle 68HC12 page specification in 'call foo,%page(bar)'. */
- else if ((opmode & M6812_OP_PAGE) && strncmp (p, "%page", 5) == 0)
+ else if ((opmode & M6812_OP_PAGE) && startswith (p, "%page"))
{
p += 5;
mode = M6811_OP_PAGE_ADDR | M6812_OP_PAGE | M6811_OP_IND16;
}
/* Special handling of TFR. */
- if (strncmp (opc->opcode->name, "tfr",3) == 0)
+ if (startswith (opc->opcode->name, "tfr"))
{
/* There must be two operands with a comma. */
input_line_pointer = skip_whites (input_line_pointer);
}
/* Special handling of SIF. */
- if (strncmp (opc->opcode->name, "sif",3) == 0)
+ if (startswith (opc->opcode->name, "sif"))
{
/* Either OP_NONE or OP_RS. */
if (*input_line_pointer != '\n')
opcode = find (opc, operands, 1);
if (opcode)
{
- if ((strncmp (opc->opcode->name, "com",3) == 0)
- || (strncmp (opc->opcode->name, "neg",3) == 0))
+ if ((startswith (opc->opcode->name, "com"))
+ || (startswith (opc->opcode->name, "neg")))
/* Special case for com RD as alias for sub RD,R0,RS */
/* Special case for neg RD as alias for sub RD,R0,RS */
opcode_local.opcode = opcode->opcode
| (operands[0].reg1 << 8) | (operands[0].reg1 << 2);
- else if (strncmp (opc->opcode->name, "tst",3) == 0)
+ else if (startswith (opc->opcode->name, "tst"))
/* Special case for tst RS alias for sub R0, RS, R0 */
opcode_local.opcode = opcode->opcode
| (operands[0].reg1 << 5);
{
input_line_pointer++;
input_line_pointer = skip_whites (input_line_pointer);
- if (strncmp (input_line_pointer, "%hi", 3) == 0)
+ if (startswith (input_line_pointer, "%hi"))
{
input_line_pointer += 3;
operands[0].mode = M6811_OP_HIGH_ADDR;
}
- else if (strncmp (input_line_pointer, "%lo", 3) == 0)
+ else if (startswith (input_line_pointer, "%lo"))
{
input_line_pointer += 3;
operands[0].mode = M6811_OP_LOW_ADDR;
opcode = find (opc, operands, 1);
if (opcode)
{
- if ((strncmp (opc->opcode->name, "com",3) == 0)
- || (strncmp (opc->opcode->name, "mov",3) == 0)
- || (strncmp (opc->opcode->name, "neg",3) == 0))
+ if ((startswith (opc->opcode->name, "com"))
+ || (startswith (opc->opcode->name, "mov"))
+ || (startswith (opc->opcode->name, "neg")))
{
/* Special cases for:
com RD, RS alias for xnor RD,R0,RS
opcode_local.opcode = opcode->opcode
| (operands[0].reg1 << 8) | (operands[1].reg1 << 2);
}
- else if ((strncmp (opc->opcode->name, "cmp",3) == 0)
- || (strncmp (opc->opcode->name, "cpc",3) == 0))
+ else if ((startswith (opc->opcode->name, "cmp"))
+ || (startswith (opc->opcode->name, "cpc")))
{
/* special cases for:
cmp RS1, RS2 alias for sub R0, RS1, RS2
case 'B': /* FOO */
if (opP->mode != ABSL
|| (flag_long_jumps
- && strncmp (instring, "jbsr", 4) == 0))
+ && startswith (instring, "jbsr")))
losing++;
break;
|| TRUNC (opP->disp.exp.X_add_number) - 1 > 7)
losing++;
else if (! m68k_quick
- && (strncmp (instring, "add", 3) == 0
- || strncmp (instring, "sub", 3) == 0)
+ && (startswith (instring, "add")
+ || startswith (instring, "sub"))
&& instring[3] != 'q')
losing++;
break;
#endif
/* Intentional fall-through. */
case 'm':
- if (!strncmp (arg, "arch=", 5))
+ if (startswith (arg, "arch="))
m68k_set_arch (arg + 5, 1, 0);
- else if (!strncmp (arg, "cpu=", 4))
+ else if (startswith (arg, "cpu="))
m68k_set_cpu (arg + 4, 1, 0);
else if (m68k_set_extension (arg, 0, 1))
;
*str2 = '\0';
len = str2 - ident;
- if (strncmp (ident, "TLSLDO", 6) == 0
+ if (startswith (ident, "TLSLDO")
&& len == 6)
{
/* Now check for identifier@suffix+constant. */
while (*ilp != 0 && ISSPACE (*ilp))
++ ilp;
- if (strncmp (ilp, ".line", 5) == 0
+ if (startswith (ilp, ".line")
&& (ISSPACE (ilp[5]) || *ilp == '\n' || *ilp == '\r'))
;
else
if (is_get)
{
- bool is_mov = strncmp (template->name, "MOV", 3) == 0;
+ bool is_mov = startswith (template->name, "MOV");
l = parse_get (l, regs, &addr, size, is_mov);
/* These options are expected to have an argument. */
if (c == lopt->option[0]
&& arg != NULL
- && strncmp (arg, lopt->option + 1,
- strlen (lopt->option + 1)) == 0)
+ && startswith (arg, lopt->option + 1))
{
#if WARN_DEPRECATED
/* If the option is deprecated, tell the user. */
new_pointer = parse_exp (s, e);
- if (!GOT_symbol && ! strncmp (s, GOT_SYMBOL_NAME, 20))
+ if (!GOT_symbol && startswith (s, GOT_SYMBOL_NAME))
{
GOT_symbol = symbol_find_or_make (GOT_SYMBOL_NAME);
}
if (is_end_of_line[(unsigned char) *atp])
return NULL;
- if (strncmp (atp + 1, "GOTOFF", 5) == 0)
+ if (startswith (atp + 1, "GOTOFF"))
{
*got_len = 6;
*got_type = IMM_GOTOFF;
}
- else if (strncmp (atp + 1, "GOT", 3) == 0)
+ else if (startswith (atp + 1, "GOT"))
{
*got_len = 3;
*got_type = IMM_GOT;
}
- else if (strncmp (atp + 1, "PLT", 3) == 0)
+ else if (startswith (atp + 1, "PLT"))
{
*got_len = 3;
*got_type = IMM_PLT;
|| (symbol_used_in_reloc_p (fixP->fx_addsy)
&& (((bfd_section_flags (S_GET_SEGMENT (fixP->fx_addsy))
& SEC_LINK_ONCE) != 0)
- || !strncmp (segment_name (S_GET_SEGMENT (fixP->fx_addsy)),
- ".gnu.linkonce",
- sizeof (".gnu.linkonce") - 1))))
+ || startswith (segment_name (S_GET_SEGMENT (fixP->fx_addsy)),
+ ".gnu.linkonce"))))
{
val -= S_GET_VALUE (fixP->fx_addsy);
if (val != 0 && ! fixP->fx_pcrel)
/* Return true if the given CPU supports the MIPS16 ASE. */
#define CPU_HAS_MIPS16(cpu) \
- (strncmp (TARGET_CPU, "mips16", sizeof ("mips16") - 1) == 0 \
- || strncmp (TARGET_CANONICAL, "mips-lsi-elf", sizeof ("mips-lsi-elf") - 1) == 0)
+ (startswith (TARGET_CPU, "mips16") \
+ || startswith (TARGET_CANONICAL, "mips-lsi-elf"))
/* Return true if the given CPU supports the microMIPS ASE. */
#define CPU_HAS_MICROMIPS(cpu) 0
/* On a native system other than VxWorks, sections must be aligned
to 16 byte boundaries. When configured for an embedded ELF
target, we don't bother. */
- if (strncmp (TARGET_OS, "elf", 3) != 0
- && strncmp (TARGET_OS, "vxworks", 7) != 0)
+ if (!startswith (TARGET_OS, "elf")
+ && !startswith (TARGET_OS, "vxworks"))
{
bfd_set_section_alignment (text_section, 4);
bfd_set_section_alignment (data_section, 4);
running program can access it. However, we don't load it
if we are configured for an embedded target. */
flags = SEC_READONLY | SEC_DATA;
- if (strncmp (TARGET_OS, "elf", 3) != 0)
+ if (!startswith (TARGET_OS, "elf"))
flags |= SEC_ALLOC | SEC_LOAD;
if (mips_abi != N64_ABI)
/* The GNU toolchain uses an extension for ELF: a section
beginning with the magic string .gnu.linkonce is a
linkonce section. */
- if (strncmp (segment_name (symseg), ".gnu.linkonce",
- sizeof ".gnu.linkonce" - 1) == 0)
+ if (startswith (segment_name (symseg), ".gnu.linkonce"))
linkonce = true;
}
return linkonce;
length = strlen (name);
if ((regno & 1) != 0
&& ((length >= 3 && strcmp (name + length - 3, ".ps") == 0)
- || (length >= 5 && strncmp (name + length - 5, "any2", 4) == 0)))
+ || (length >= 5 && startswith (name + length - 5, "any2"))))
as_warn (_("condition code register should be even for %s, was %d"),
name, regno);
if ((regno & 3) != 0
- && (length >= 5 && strncmp (name + length - 5, "any4", 4) == 0))
+ && (length >= 5 && startswith (name + length - 5, "any4")))
as_warn (_("condition code register should be 0 or 4 for %s, was %d"),
name, regno);
}
bfd_set_section_flags (new_seg,
SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA);
frag_align (length == 4 ? 2 : 3, 0, 0);
- if (strncmp (TARGET_OS, "elf", 3) != 0)
+ if (!startswith (TARGET_OS, "elf"))
record_alignment (new_seg, 4);
else
record_alignment (new_seg, length == 4 ? 2 : 3);
static unsigned int
classify_vr4120_insn (const char *name)
{
- if (strncmp (name, "macc", 4) == 0)
+ if (startswith (name, "macc"))
return FIX_VR4120_MACC;
- if (strncmp (name, "dmacc", 5) == 0)
+ if (startswith (name, "dmacc"))
return FIX_VR4120_DMACC;
- if (strncmp (name, "mult", 4) == 0)
+ if (startswith (name, "mult"))
return FIX_VR4120_MULT;
- if (strncmp (name, "dmult", 5) == 0)
+ if (startswith (name, "dmult"))
return FIX_VR4120_DMULT;
if (strstr (name, "div"))
return FIX_VR4120_DIV;
return true;
clear_insn_error ();
if (arg.dest_regno == arg.last_regno
- && strncmp (insn->insn_mo->name, "jalr", 4) == 0)
+ && startswith (insn->insn_mo->name, "jalr"))
{
if (arg.opnum == 2)
set_insn_error
(0, _("a destination register must be supplied"));
}
else if (arg.last_regno == 31
- && (strncmp (insn->insn_mo->name, "bltzal", 6) == 0
- || strncmp (insn->insn_mo->name, "bgezal", 6) == 0))
+ && (startswith (insn->insn_mo->name, "bltzal")
+ || startswith (insn->insn_mo->name, "bgezal")))
set_insn_error (0, _("the source register must not be $31"));
check_completed_insn (&arg);
return true;
const struct mips_cpu_info *tune_info = 0;
/* GP relative stuff not working for PE. */
- if (strncmp (TARGET_OS, "pe", 2) == 0)
+ if (startswith (TARGET_OS, "pe"))
{
if (g_switch_seen && g_switch_value != 0)
as_bad (_("-G not supported in this configuration"));
(subsegT) get_absolute_expression ());
bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY
| SEC_RELOC | SEC_DATA));
- if (strncmp (TARGET_OS, "elf", 3) != 0)
+ if (!startswith (TARGET_OS, "elf"))
record_alignment (seg, 4);
demand_empty_rest_of_line ();
break;
seg = subseg_new (".sdata", (subsegT) get_absolute_expression ());
bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_RELOC
| SEC_DATA | SEC_SMALL_DATA));
- if (strncmp (TARGET_OS, "elf", 3) != 0)
+ if (!startswith (TARGET_OS, "elf"))
record_alignment (seg, 4);
demand_empty_rest_of_line ();
break;
case 'B':
seg = subseg_new (".sbss", (subsegT) get_absolute_expression ());
bfd_set_section_flags (seg, SEC_ALLOC | SEC_SMALL_DATA);
- if (strncmp (TARGET_OS, "elf", 3) != 0)
+ if (!startswith (TARGET_OS, "elf"))
record_alignment (seg, 4);
demand_empty_rest_of_line ();
break;
{
/* FIXME: What does this mean? */
}
- else if (strncmp (opt, "pic", 3) == 0 && ISDIGIT (opt[3]) && opt[4] == '\0')
+ else if (startswith (opt, "pic") && ISDIGIT (opt[3]) && opt[4] == '\0')
{
int i;
bool isa_set = false;
const struct mips_ase *ase;
- if (strncmp (name, "at=", 3) == 0)
+ if (startswith (name, "at="))
{
char *s = name + 3;
mips_set_ase (ase, &mips_opts, false);
else if ((ase = mips_lookup_ase (name)))
mips_set_ase (ase, &mips_opts, true);
- else if (strncmp (name, "mips", 4) == 0 || strncmp (name, "arch=", 5) == 0)
+ else if (startswith (name, "mips") || startswith (name, "arch="))
{
/* Permit the user to change the ISA and architecture on the fly.
Needless to say, misuse can cause serious problems. */
- if (strncmp (name, "arch=", 5) == 0)
+ if (startswith (name, "arch="))
{
const struct mips_cpu_info *p;
mips_opts.init_ase = p->ase;
}
}
- else if (strncmp (name, "mips", 4) == 0)
+ else if (startswith (name, "mips"))
{
const struct mips_cpu_info *p;
However, Irix 5 may prefer that we align them at least to a 16
byte boundary. We don't bother to align the sections if we
are targeted for an embedded system. */
- if (strncmp (TARGET_OS, "elf", 3) == 0)
+ if (startswith (TARGET_OS, "elf"))
return addr;
if (align > 4)
align = 4;
&& strcmp (segname, ".lit4") != 0);
change = (strcmp (segname, ".sdata") != 0
&& strcmp (segname, ".sbss") != 0
- && strncmp (segname, ".sdata.", 7) != 0
- && strncmp (segname, ".sbss.", 6) != 0
- && strncmp (segname, ".gnu.linkonce.sb.", 17) != 0
- && strncmp (segname, ".gnu.linkonce.s.", 16) != 0);
+ && !startswith (segname, ".sdata.")
+ && !startswith (segname, ".sbss.")
+ && !startswith (segname, ".gnu.linkonce.sb.")
+ && !startswith (segname, ".gnu.linkonce.s."));
}
return change;
}
}
else if (s[0] == 'G'
&& s[1] == 'R'
- && strncmp (s, "GREG", 4) == 0
+ && startswith (s, "GREG")
&& (ISSPACE (s[4]) || is_end_of_line[(unsigned char) s[4]]))
{
input_line_pointer = s + 4;
if (! (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_MERGE))
return false;
- if (strncmp (S_GET_SEGMENT (fixp->fx_addsy)->name, ".debug", 6) == 0)
+ if (startswith (S_GET_SEGMENT (fixp->fx_addsy)->name, ".debug"))
return false;
return true;
{
int len = strlen (what);
- if (strncmp (cont, what, strlen (what)) == 0
+ if (startswith (cont, what)
&& ! is_part_of_name (cont[len]))
return cont + len;
static void
msp430_make_init_symbols (const char * name)
{
- if (strncmp (name, ".bss", 4) == 0
- || strncmp (name, ".lower.bss", 10) == 0
- || strncmp (name, ".either.bss", 11) == 0
- || strncmp (name, ".gnu.linkonce.b.", 16) == 0)
+ if (startswith (name, ".bss")
+ || startswith (name, ".lower.bss")
+ || startswith (name, ".either.bss")
+ || startswith (name, ".gnu.linkonce.b."))
(void) symbol_find_or_make ("__crt0_init_bss");
- if (strncmp (name, ".data", 5) == 0
- || strncmp (name, ".lower.data", 11) == 0
- || strncmp (name, ".either.data", 12) == 0
- || strncmp (name, ".gnu.linkonce.d.", 16) == 0)
+ if (startswith (name, ".data")
+ || startswith (name, ".lower.data")
+ || startswith (name, ".either.data")
+ || startswith (name, ".gnu.linkonce.d."))
(void) symbol_find_or_make ("__crt0_movedata");
/* Note - data assigned to the .either.data section may end up being
placed in the .upper.data section if the .lower.data section is
The linker may create upper or either data sections, even when none exist
at the moment, so use the value of the data-region flag to determine if
the symbol is needed. */
- if (strncmp (name, ".either.data", 12) == 0
- || strncmp (name, ".upper.data", 11) == 0
+ if (startswith (name, ".either.data")
+ || startswith (name, ".upper.data")
|| upper_data_region_in_use)
(void) symbol_find_or_make ("__crt0_move_highdata");
/* See note about .either.data above. */
- if (strncmp (name, ".upper.bss", 10) == 0
- || strncmp (name, ".either.bss", 11) == 0
+ if (startswith (name, ".upper.bss")
+ || startswith (name, ".either.bss")
|| upper_data_region_in_use)
(void) symbol_find_or_make ("__crt0_init_highbss");
exit() or returning from main.
__crt0_run_array is required to actually call the functions in the above
arrays. */
- if (strncmp (name, ".init_array", 11) == 0)
+ if (startswith (name, ".init_array"))
{
(void) symbol_find_or_make ("__crt0_run_init_array");
(void) symbol_find_or_make ("__crt0_run_array");
}
- else if (strncmp (name, ".preinit_array", 14) == 0)
+ else if (startswith (name, ".preinit_array"))
{
(void) symbol_find_or_make ("__crt0_run_preinit_array");
(void) symbol_find_or_make ("__crt0_run_array");
}
- else if (strncmp (name, ".fini_array", 11) == 0)
+ else if (startswith (name, ".fini_array"))
{
(void) symbol_find_or_make ("__crt0_run_fini_array");
(void) symbol_find_or_make ("__crt0_run_array");
int disable = 0;
/* Filter out the Disable option first. */
- if (strncmp (arg, "no-", 3) == 0)
+ if (startswith (arg, "no-"))
{
disable = 1;
arg += 3;
#define md_do_align(N, FILL, LEN, MAX, LABEL) \
nds32_pre_do_align (N, FILL, LEN, MAX); \
if ((N) > 1 && (subseg_text_p (now_seg) \
- || strncmp (now_seg->name, ".gcc_except_table", sizeof(".gcc_except_table") - 1) == 0)) \
+ || startswith (now_seg->name, ".gcc_except_table"))) \
nds32_do_align (N); \
goto LABEL;
#define md_elf_section_change_hook() nds32_elf_section_change_hook ()
return NULL;
}
-/* Return true if STR starts with PREFIX, which should be a string literal. */
-#define strprefix(STR, PREFIX) \
- (strncmp ((STR), PREFIX, strlen (PREFIX)) == 0)
-
-
/* Return true if STR is prefixed with a special relocation operator. */
static int
nios2_special_relocation_p (const char *str)
{
- return (strprefix (str, "%lo")
- || strprefix (str, "%hi")
- || strprefix (str, "%hiadj")
- || strprefix (str, "%gprel")
- || strprefix (str, "%got")
- || strprefix (str, "%call")
- || strprefix (str, "%gotoff_lo")
- || strprefix (str, "%gotoff_hiadj")
- || strprefix (str, "%tls_gd")
- || strprefix (str, "%tls_ldm")
- || strprefix (str, "%tls_ldo")
- || strprefix (str, "%tls_ie")
- || strprefix (str, "%tls_le")
- || strprefix (str, "%gotoff"));
+ return (startswith (str, "%lo")
+ || startswith (str, "%hi")
+ || startswith (str, "%hiadj")
+ || startswith (str, "%gprel")
+ || startswith (str, "%got")
+ || startswith (str, "%call")
+ || startswith (str, "%gotoff_lo")
+ || startswith (str, "%gotoff_hiadj")
+ || startswith (str, "%tls_gd")
+ || startswith (str, "%tls_ldm")
+ || startswith (str, "%tls_ldo")
+ || startswith (str, "%tls_ie")
+ || startswith (str, "%tls_le")
+ || startswith (str, "%gotoff"));
}
*ret = 0;
/* Check for --. */
- if (strncmp (str, "--", 2) == 0)
+ if (startswith (str, "--"))
{
str += 2;
*direction -= 1;
return NULL;
/* Check for ++. */
- if (strncmp (str, "++", 2) == 0)
+ if (startswith (str, "++"))
{
str += 2;
*direction += 1;
{
while (*str == ' ')
str++;
- if (strncmp (str, "writeback", 9) == 0)
+ if (startswith (str, "writeback"))
{
*writeback = 1;
str += 9;
}
- else if (strncmp (str, "ret", 3) == 0)
+ else if (startswith (str, "ret"))
{
*ret = 1;
str += 3;
SKIP_WHITESPACE ();
if (input_line_pointer[0] == '%')
{
- if (strprefix (input_line_pointer + 1, "tls_ldo"))
+ if (startswith (input_line_pointer + 1, "tls_ldo"))
{
reloc_name = "%tls_ldo";
if (size != 4)
explicit_reloc = BFD_RELOC_NIOS2_TLS_DTPREL;
}
}
- else if (strprefix (input_line_pointer + 1, "gotoff"))
+ else if (startswith (input_line_pointer + 1, "gotoff"))
{
reloc_name = "%gotoff";
if (size != 4)
case 'e':
if (str[strl - 1] != ']')
{
- if ((!strncmp (str, "ext(", 4)) && strl > 7)
+ if ((startswith (str, "ext(")) && strl > 7)
{ /* external */
addrmodeP->disp[0] = str + 4;
i = 0;
/* Fall through. */
case 3:
- if (!strncmp (str, "tos", 3))
+ if (startswith (str, "tos"))
{
addrmodeP->mode = 23; /* TopOfStack */
return -1;
{
if (str[strl - 2] == ')')
{
- if (!strncmp (&str[strl - 5], "(fp", 3))
+ if (startswith (&str[strl - 5], "(fp"))
mode = 16; /* Memory Relative. */
- else if (!strncmp (&str[strl - 5], "(sp", 3))
+ else if (startswith (&str[strl - 5], "(sp"))
mode = 17;
- else if (!strncmp (&str[strl - 5], "(sb", 3))
+ else if (startswith (&str[strl - 5], "(sb"))
mode = 18;
if (mode != DEFAULT)
/* Fall through. */
default:
- if (!strncmp (&str[strl - 4], "(fp", 3))
+ if (startswith (&str[strl - 4], "(fp"))
mode = 24;
- else if (!strncmp (&str[strl - 4], "(sp", 3))
+ else if (startswith (&str[strl - 4], "(sp"))
mode = 25;
- else if (!strncmp (&str[strl - 4], "(sb", 3))
+ else if (startswith (&str[strl - 4], "(sb"))
mode = 26;
- else if (!strncmp (&str[strl - 4], "(pc", 3))
+ else if (startswith (&str[strl - 4], "(pc"))
mode = 27;
if (mode != DEFAULT)
return 1;
}
- if (strncmp (arg, "no-", 3) == 0)
+ if (startswith (arg, "no-"))
{
yes = 0;
arg += 3;
else if (strcmp (arg, "mfpt") == 0)
pdp11_extension[PDP11_MFPT] = yes;
/* Multiprocessor insns: */
- else if (strncmp (arg, "mproc", 5) == 0
+ else if (startswith (arg, "mproc")
/* TSTSET, WRTLCK */
- || strncmp (arg, "multiproc", 9) == 0)
+ || startswith (arg, "multiproc"))
pdp11_extension[PDP11_MPROC] = yes;
/* Move from/to proc status. */
else if (strcmp (arg, "mxps") == 0)
return str - 1;
}
}
- else if (strncmp (str, "sp", 2) == 0
- || strncmp (str, "SP", 2) == 0)
+ else if (startswith (str, "sp")
+ || startswith (str, "SP"))
{
operand->code = 6;
str += 2;
}
- else if (strncmp (str, "pc", 2) == 0
- || strncmp (str, "PC", 2) == 0)
+ else if (startswith (str, "pc")
+ || startswith (str, "PC"))
{
operand->code = 7;
str += 2;
parse_ac5 (char *str, struct pdp11_code *operand)
{
str = skip_whitespace (str);
- if (strncmp (str, "fr", 2) == 0
- || strncmp (str, "FR", 2) == 0
- || strncmp (str, "ac", 2) == 0
- || strncmp (str, "AC", 2) == 0)
+ if (startswith (str, "fr")
+ || startswith (str, "FR")
+ || startswith (str, "ac")
+ || startswith (str, "AC"))
{
str += 2;
switch (*str)
/* label, d(rn), -(rn) */
default:
{
- if (strncmp (str, "-(", 2) == 0) /* -(rn) */
+ if (startswith (str, "-(")) /* -(rn) */
{
str = parse_reg (str + 2, operand);
if (operand->error)
if (arg[0] == '-')
arg++;
- if (strncmp (arg, "11", 2) != 0)
+ if (!startswith (arg, "11"))
return 0;
arg += 2;
set_option ("no-extensions");
/* KA11 (11/15/20). */
- if (strncmp (buf, "a", 1) == 0)
+ if (startswith (buf, "a"))
return 1; /* No extensions. */
/* KB11 (11/45/50/55/70). */
- else if (strncmp (buf, "b", 1) == 0)
+ else if (startswith (buf, "b"))
return set_option ("eis") && set_option ("spl");
/* KD11-A (11/35/40). */
- else if (strncmp (buf, "da", 2) == 0)
+ else if (startswith (buf, "da"))
return set_option ("limited-eis");
/* KD11-B (11/05/10). */
- else if (strncmp (buf, "db", 2) == 0
+ else if (startswith (buf, "db")
/* KD11-D (11/04). */
- || strncmp (buf, "dd", 2) == 0)
+ || startswith (buf, "dd"))
return 1; /* no extensions */
/* KD11-E (11/34). */
- else if (strncmp (buf, "de", 2) == 0)
+ else if (startswith (buf, "de"))
return set_option ("eis") && set_option ("mxps");
/* KD11-F (11/03). */
- else if (strncmp (buf, "df", 2) == 0
+ else if (startswith (buf, "df")
/* KD11-H (11/03). */
- || strncmp (buf, "dh", 2) == 0
+ || startswith (buf, "dh")
/* KD11-Q (11/03). */
- || strncmp (buf, "dq", 2) == 0)
+ || startswith (buf, "dq"))
return set_option ("limited-eis") && set_option ("mxps");
/* KD11-K (11/60). */
- else if (strncmp (buf, "dk", 2) == 0)
+ else if (startswith (buf, "dk"))
return set_option ("eis")
&& set_option ("mxps")
&& set_option ("ucode");
/* KD11-Z (11/44). */
- else if (strncmp (buf, "dz", 2) == 0)
+ else if (startswith (buf, "dz"))
return set_option ("csm")
&& set_option ("eis")
&& set_option ("mfpt")
&& set_option ("spl");
/* F11 (11/23/24). */
- else if (strncmp (buf, "f", 1) == 0)
+ else if (startswith (buf, "f"))
return set_option ("eis")
&& set_option ("mfpt")
&& set_option ("mxps");
/* J11 (11/53/73/83/84/93/94). */
- else if (strncmp (buf, "j", 1) == 0)
+ else if (startswith (buf, "j"))
return set_option ("csm")
&& set_option ("eis")
&& set_option ("mfpt")
&& set_option ("spl");
/* T11 (11/21). */
- else if (strncmp (buf, "t", 1) == 0)
+ else if (startswith (buf, "t"))
return set_option ("limited-eis")
&& set_option ("mxps");
static int
set_machine_model (const char *arg)
{
- if (strncmp (arg, "pdp-11/", 7) != 0
- && strncmp (arg, "pdp11/", 6) != 0
- && strncmp (arg, "11/", 3) != 0)
+ if (!startswith (arg, "pdp-11/")
+ && !startswith (arg, "pdp11/")
+ && !startswith (arg, "11/"))
return 0;
- if (strncmp (arg, "pdp", 3) == 0)
+ if (startswith (arg, "pdp"))
arg += 3;
if (arg[0] == '-')
arg++;
- if (strncmp (arg, "11/", 3) == 0)
+ if (startswith (arg, "11/"))
arg += 3;
if (strcmp (arg, "03") == 0)
void
md_operand (expressionS *op)
{
- if (strncmp (input_line_pointer, "%hi16", 5) == 0)
+ if (startswith (input_line_pointer, "%hi16"))
{
if (pending_reloc)
as_bad (_("confusing relocation expressions"));
expression (op);
}
- if (strncmp (input_line_pointer, "%lo16", 5) == 0)
+ if (startswith (input_line_pointer, "%lo16"))
{
if (pending_reloc)
as_bad (_("confusing relocation expressions"));
{
#ifdef OBJ_ELF
case bfd_target_elf_flavour:
- return strncmp (targ->name, "elf64-powerpc", 13) == 0;
+ return startswith (targ->name, "elf64-powerpc");
#endif
#ifdef OBJ_XCOFF
case bfd_target_xcoff_flavour:
else
/* The minimum supported cpu for 64-bit little-endian is power8. */
ppc_cpu |= ppc_parse_cpu (ppc_cpu, &sticky, "power8");
- else if (strncmp (default_os, "aix", 3) == 0
+ else if (startswith (default_os, "aix")
&& default_os[3] >= '4' && default_os[3] <= '9')
ppc_cpu |= PPC_OPCODE_COMMON;
- else if (strncmp (default_os, "aix3", 4) == 0)
+ else if (startswith (default_os, "aix3"))
ppc_cpu |= PPC_OPCODE_POWER;
else if (strcmp (default_cpu, "rs6000") == 0)
ppc_cpu |= PPC_OPCODE_POWER;
- else if (strncmp (default_cpu, "powerpc", 7) == 0)
+ else if (startswith (default_cpu, "powerpc"))
ppc_cpu |= PPC_OPCODE_PPC;
else
as_fatal (_("unknown default cpu = %s, os = %s"),
{
if (strcmp (default_cpu, "rs6000") == 0)
return bfd_arch_rs6000;
- else if (strncmp (default_cpu, "powerpc", 7) == 0)
+ else if (startswith (default_cpu, "powerpc"))
return bfd_arch_powerpc;
}
int
ppc_section_type (char *str, size_t len)
{
- if (len == 7 && strncmp (str, "ordered", 7) == 0)
+ if (len == 7 && startswith (str, "ordered"))
return SHT_ORDERED;
return -1;
if (reg == REG_Y)
lb |= 0x01;
- if (0 == strncmp (insn->name + 2, "ne", 2))
+ if (startswith (insn->name + 2, "ne"))
lb |= 0x00 << 4;
- else if (0 == strncmp (insn->name + 2, "eq", 2))
+ else if (startswith (insn->name + 2, "eq"))
lb |= 0x01 << 4;
- else if (0 == strncmp (insn->name + 2, "pl", 2))
+ else if (startswith (insn->name + 2, "pl"))
lb |= 0x02 << 4;
- else if (0 == strncmp (insn->name + 2, "mi", 2))
+ else if (startswith (insn->name + 2, "mi"))
lb |= 0x03 << 4;
- else if (0 == strncmp (insn->name + 2, "gt", 2))
+ else if (startswith (insn->name + 2, "gt"))
lb |= 0x04 << 4;
- else if (0 == strncmp (insn->name + 2, "le", 2))
+ else if (startswith (insn->name + 2, "le"))
lb |= 0x05 << 4;
switch (insn->name[0])
uint8_t lb = 0x0C;
- if (0 == strncmp (insn->name + 2, "ne", 2))
+ if (startswith (insn->name + 2, "ne"))
lb |= 0x00 << 4;
- else if (0 == strncmp (insn->name + 2, "eq", 2))
+ else if (startswith (insn->name + 2, "eq"))
lb |= 0x01 << 4;
- else if (0 == strncmp (insn->name + 2, "pl", 2))
+ else if (startswith (insn->name + 2, "pl"))
lb |= 0x02 << 4;
- else if (0 == strncmp (insn->name + 2, "mi", 2))
+ else if (startswith (insn->name + 2, "mi"))
lb |= 0x03 << 4;
- else if (0 == strncmp (insn->name + 2, "gt", 2))
+ else if (startswith (insn->name + 2, "gt"))
lb |= 0x04 << 4;
- else if (0 == strncmp (insn->name + 2, "le", 2))
+ else if (startswith (insn->name + 2, "le"))
lb |= 0x05 << 4;
switch (insn->name[0])
char *ilp_bak;
icpu = S390_OPCODE_MAXCPU;
- if (strncmp (arg, "all", 3) == 0 && (arg[3] == 0 || arg[3] == '+'))
+ if (startswith (arg, "all") && (arg[3] == 0 || arg[3] == '+'))
{
icpu = S390_OPCODE_MAXCPU - 1;
arg += 3;
current_mode_mask = 1 << S390_OPCODE_ZARCH;
}
- else if (arg != NULL && strncmp (arg, "arch=", 5) == 0)
+ else if (arg != NULL && startswith (arg, "arch="))
{
current_cpu = s390_parse_cpu (arg + 5, ¤t_flags, false);
if (current_cpu == S390_OPCODE_MAXCPU)
segname = segment_name (S_GET_SEGMENT (sym));
return (strcmp (segname, ".sdata") != 0
&& strcmp (segname, ".sbss") != 0
- && strncmp (segname, ".sdata.", 7) != 0
- && strncmp (segname, ".gnu.linkonce.s.", 16) != 0);
+ && !startswith (segname, ".sdata.")
+ && !startswith (segname, ".gnu.linkonce.s."));
}
/* We are not optimizing for the $gp register. */
else
/* The GNU toolchain uses an extension for ELF: a section
beginning with the magic string .gnu.linkonce is a linkonce
section. */
- if (strncmp (segment_name (symsec), ".gnu.linkonce",
- sizeof ".gnu.linkonce" - 1) == 0)
+ if (startswith (segment_name (symsec), ".gnu.linkonce"))
linkonce = true;
}
segname = segment_name (S_GET_SEGMENT (sym));
return (strcmp (segname, ".sdata") != 0
&& strcmp (segname, ".sbss") != 0
- && strncmp (segname, ".sdata.", 7) != 0
- && strncmp (segname, ".gnu.linkonce.s.", 16) != 0);
+ && !startswith (segname, ".sdata.")
+ && !startswith (segname, ".gnu.linkonce.s."));
}
/* We are not optimizing for the $gp register. */
else
/* The GNU toolchain uses an extension for ELF: a section
beginning with the magic string .gnu.linkonce is a linkonce
section. */
- if (strncmp (segment_name (symsec), ".gnu.linkonce",
- sizeof ".gnu.linkonce" - 1) == 0)
+ if (startswith (segment_name (symsec), ".gnu.linkonce"))
linkonce = true;
}
/* We align most sections to a 16 byte boundary. */
#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
- (strncmp (SEG_NAME (SEG), ".stabstr", 8) == 0 \
+ (startswith (SEG_NAME (SEG), ".stabstr") \
? 0 \
- : ((strncmp (SEG_NAME (SEG), ".stab", 5) == 0 \
+ : ((startswith (SEG_NAME (SEG), ".stab") \
|| strcmp (SEG_NAME (SEG), ".ctors") == 0 \
|| strcmp (SEG_NAME (SEG), ".dtors") == 0) \
? 2 \
break;
case OPTION_XARCH:
- if (!strncmp (arg, "v9", 2))
+ if (startswith (arg, "v9"))
md_parse_option (OPTION_64, NULL);
else
{
- if (!strncmp (arg, "v8", 2)
- || !strncmp (arg, "v7", 2)
- || !strncmp (arg, "v6", 2)
+ if (startswith (arg, "v8")
+ || startswith (arg, "v7")
+ || startswith (arg, "v6")
|| !strcmp (arg, "sparclet")
|| !strcmp (arg, "sparclite")
|| !strcmp (arg, "sparc86x"))
case 'M':
case 'm':
- if (strncmp (s, "%asr", 4) == 0)
+ if (startswith (s, "%asr"))
{
s += 4;
{
++s;
}
- if ((strncmp (s, "%icc", 4) == 0)
- || (sparc_arch_size == 32 && strncmp (s, "%ncc", 4) == 0))
+ if ((startswith (s, "%icc"))
+ || (sparc_arch_size == 32 && startswith (s, "%ncc")))
{
s += 4;
continue;
{
++s;
}
- if ((strncmp (s, "%xcc", 4) == 0)
- || (sparc_arch_size == 64 && strncmp (s, "%ncc", 4) == 0))
+ if ((startswith (s, "%xcc"))
+ || (sparc_arch_size == 64 && startswith (s, "%ncc")))
{
s += 4;
continue;
{
++s;
}
- if (strncmp (s, "%fcc0", 5) == 0)
+ if (startswith (s, "%fcc0"))
{
s += 5;
continue;
{
++s;
}
- if (strncmp (s, "%fcc1", 5) == 0)
+ if (startswith (s, "%fcc1"))
{
s += 5;
continue;
{
++s;
}
- if (strncmp (s, "%fcc2", 5) == 0)
+ if (startswith (s, "%fcc2"))
{
s += 5;
continue;
{
++s;
}
- if (strncmp (s, "%fcc3", 5) == 0)
+ if (startswith (s, "%fcc3"))
{
s += 5;
continue;
break;
case 'P':
- if (strncmp (s, "%pc", 3) == 0)
+ if (startswith (s, "%pc"))
{
s += 3;
continue;
break;
case 'W':
- if (strncmp (s, "%tick", 5) == 0)
+ if (startswith (s, "%tick"))
{
s += 5;
continue;
break;
case 'C': /* Coprocessor state register. */
- if (strncmp (s, "%csr", 4) == 0)
+ if (startswith (s, "%csr"))
{
s += 4;
continue;
} /* float arg */
case 'F':
- if (strncmp (s, "%fsr", 4) == 0)
+ if (startswith (s, "%fsr"))
{
s += 4;
continue;
break;
case '(':
- if (strncmp (s, "%efsr", 5) == 0)
+ if (startswith (s, "%efsr"))
{
s += 5;
continue;
} /* Alternate space. */
case 'p':
- if (strncmp (s, "%psr", 4) == 0)
+ if (startswith (s, "%psr"))
{
s += 4;
continue;
break;
case 'q': /* Floating point queue. */
- if (strncmp (s, "%fq", 3) == 0)
+ if (startswith (s, "%fq"))
{
s += 3;
continue;
break;
case 'Q': /* Coprocessor queue. */
- if (strncmp (s, "%cq", 3) == 0)
+ if (startswith (s, "%cq"))
{
s += 3;
continue;
special_case = SPECIAL_CASE_SETX;
continue;
}
- else if (strncmp (str, "fdiv", 4) == 0)
+ else if (startswith (str, "fdiv"))
{
special_case = SPECIAL_CASE_FDIV;
continue;
break;
case 'o':
- if (strncmp (s, "%asi", 4) != 0)
+ if (!startswith (s, "%asi"))
break;
s += 4;
continue;
case 's':
- if (strncmp (s, "%fprs", 5) != 0)
+ if (!startswith (s, "%fprs"))
break;
s += 5;
continue;
case '{':
- if (strncmp (s, "%mcdper",7) != 0)
+ if (!startswith (s, "%mcdper"))
break;
s += 7;
continue;
case '&':
- if (strncmp (s, "%entropy", 8) != 0)
+ if (!startswith (s, "%entropy"))
break;
s += 8;
continue;
case 'E':
- if (strncmp (s, "%ccr", 4) != 0)
+ if (!startswith (s, "%ccr"))
break;
s += 4;
continue;
case 't':
- if (strncmp (s, "%tbr", 4) != 0)
+ if (!startswith (s, "%tbr"))
break;
s += 4;
continue;
case 'w':
- if (strncmp (s, "%wim", 4) != 0)
+ if (!startswith (s, "%wim"))
break;
s += 4;
continue;
}
case 'y':
- if (strncmp (s, "%y", 2) != 0)
+ if (!startswith (s, "%y"))
break;
s += 2;
continue;
symbolP = symbol_find_or_make (name);
*p = c;
- if (strncmp (input_line_pointer, ",\"bss\"", 6) != 0
- && strncmp (input_line_pointer, ",\".bss\"", 7) != 0)
+ if (!startswith (input_line_pointer, ",\"bss\"")
+ && !startswith (input_line_pointer, ",\".bss\""))
{
as_bad (_("bad .reserve segment -- expected BSS segment"));
return;
if (*input_line_pointer == '.')
input_line_pointer++;
/* @@ Some say data, some say bss. */
- if (strncmp (input_line_pointer, "bss\"", 4)
- && strncmp (input_line_pointer, "data\"", 5))
+ if (!startswith (input_line_pointer, "bss\"")
+ && !startswith (input_line_pointer, "data\""))
{
while (*--input_line_pointer != '"')
;
s_seg (int ignore ATTRIBUTE_UNUSED)
{
- if (strncmp (input_line_pointer, "\"text\"", 6) == 0)
+ if (startswith (input_line_pointer, "\"text\""))
{
input_line_pointer += 6;
s_text (0);
return;
}
- if (strncmp (input_line_pointer, "\"data\"", 6) == 0)
+ if (startswith (input_line_pointer, "\"data\""))
{
input_line_pointer += 6;
s_data (0);
return;
}
- if (strncmp (input_line_pointer, "\"data1\"", 7) == 0)
+ if (startswith (input_line_pointer, "\"data1\""))
{
input_line_pointer += 7;
s_data1 ();
return;
}
- if (strncmp (input_line_pointer, "\"bss\"", 5) == 0)
+ if (startswith (input_line_pointer, "\"bss\""))
{
input_line_pointer += 5;
/* We only support 2 segments -- text and data -- for now, so
&& input_line_pointer[1] == 'r'
&& input_line_pointer[2] == '_')
{
- if (strncmp (input_line_pointer + 3, "disp", 4) == 0)
+ if (startswith (input_line_pointer + 3, "disp"))
{
input_line_pointer += 7;
sparc_cons_special_reloc = "disp";
}
- else if (strncmp (input_line_pointer + 3, "plt", 3) == 0)
+ else if (startswith (input_line_pointer + 3, "plt"))
{
if (size != 4 && size != 8)
as_bad (_("Illegal operands: %%r_plt in %d-byte data field"), size);
sparc_cons_special_reloc = "plt";
}
}
- else if (strncmp (input_line_pointer + 3, "tls_dtpoff", 10) == 0)
+ else if (startswith (input_line_pointer + 3, "tls_dtpoff"))
{
if (size != 4 && size != 8)
as_bad (_("Illegal operands: %%r_tls_dtpoff in %d-byte data field"), size);
sf->next = sfield;
}
/* Only create a symbol for this field if the parent has no name. */
- if (!strncmp (".fake", parent->name, 5))
+ if (startswith (parent->name, ".fake"))
{
symbolS *sym = symbol_new (name, absolute_section, &zero_address_frag,
offset);
{
int size;
const char *path =
- !strncmp (current_stag->name, ".fake", 5) ? "" : current_stag->name;
+ startswith (current_stag->name, ".fake") ? "" : current_stag->name;
if (!current_stag || current_stag->is_union != is_union)
{
if (streq (text_name, ".text"))
text_name = "";
- if (strncmp (text_name, ".gnu.linkonce.t.",
- strlen (".gnu.linkonce.t.")) == 0)
+ if (startswith (text_name, ".gnu.linkonce.t."))
{
prefix = prefix_once;
text_name += strlen (".gnu.linkonce.t.");
input_line_pointer++;
/* @@ Some say data, some say bss. */
- if (strncmp (input_line_pointer, "bss\"", 4)
- && strncmp (input_line_pointer, "data\"", 5))
+ if (!startswith (input_line_pointer, "bss\"")
+ && !startswith (input_line_pointer, "data\""))
{
while (*--input_line_pointer != '"')
;
const char *prev_name = "";
const struct v850_opcode *op;
- if (strncmp (TARGET_CPU, "v850e3v5", 8) == 0)
+ if (startswith (TARGET_CPU, "v850e3v5"))
{
if (machine == -1)
machine = bfd_mach_v850e3v5;
if (!processor_mask)
SET_PROCESSOR_MASK (processor_mask, PROCESSOR_V850E3V5);
}
- else if (strncmp (TARGET_CPU, "v850e2v4", 8) == 0)
+ else if (startswith (TARGET_CPU, "v850e2v4"))
{
if (machine == -1)
machine = bfd_mach_v850e3v5;
if (!processor_mask)
SET_PROCESSOR_MASK (processor_mask, PROCESSOR_V850E3V5);
}
- else if (strncmp (TARGET_CPU, "v850e2v3", 8) == 0)
+ else if (startswith (TARGET_CPU, "v850e2v3"))
{
if (machine == -1)
machine = bfd_mach_v850e2v3;
if (!processor_mask)
SET_PROCESSOR_MASK (processor_mask, PROCESSOR_V850E2V3);
}
- else if (strncmp (TARGET_CPU, "v850e2", 6) == 0)
+ else if (startswith (TARGET_CPU, "v850e2"))
{
if (machine == -1)
machine = bfd_mach_v850e2;
if (!processor_mask)
SET_PROCESSOR_MASK (processor_mask, PROCESSOR_V850E2);
}
- else if (strncmp (TARGET_CPU, "v850e1", 6) == 0)
+ else if (startswith (TARGET_CPU, "v850e1"))
{
if (machine == -1)
machine = bfd_mach_v850e1;
if (!processor_mask)
SET_PROCESSOR_MASK (processor_mask, PROCESSOR_V850E1);
}
- else if (strncmp (TARGET_CPU, "v850e", 5) == 0)
+ else if (startswith (TARGET_CPU, "v850e"))
{
if (machine == -1)
machine = bfd_mach_v850e;
if (!processor_mask)
SET_PROCESSOR_MASK (processor_mask, PROCESSOR_V850E);
}
- else if (strncmp (TARGET_CPU, "v850", 4) == 0)
+ else if (startswith (TARGET_CPU, "v850"))
{
if (machine == -1)
machine = 0;
if (no_stld23)
{
- if ((strncmp (opcode->name, "st.", 3) == 0
+ if ((startswith (opcode->name, "st.")
&& v850_operands[opcode->operands[1]].bits == 23)
- || (strncmp (opcode->name, "ld.", 3) == 0
+ || (startswith (opcode->name, "ld.")
&& v850_operands[opcode->operands[0]].bits == 23))
{
errmsg = _("st/ld offset 23 instruction was disabled .");
value does not fit into the bits available then create a
fake error so that the next ld/st instruction will be
selected. */
- if ( ( (strncmp (opcode->name, "st.", 3) == 0)
- || (strncmp (opcode->name, "ld.", 3) == 0))
+ if ( ( (startswith (opcode->name, "st."))
+ || (startswith (opcode->name, "ld.")))
&& ex.X_op == O_constant
&& (ex.X_add_number < (-(1 << (operand->bits - 1)))
|| ex.X_add_number > ((1 << (operand->bits - 1)) - 1)))
save = input_line_pointer;
if (input_line_pointer[0] == '%')
{
- if (strncmp (input_line_pointer + 1, "pcrel", 5) == 0)
+ if (startswith (input_line_pointer + 1, "pcrel"))
{
input_line_pointer += 6;
vax_cons_special_reloc = "pcrel";
reloc->u.a.addend = 0;
}
/* i32.const fpointer@gotcode */
- if (strncmp (input_line_pointer, "@gotcode", 8) == 0)
+ if (startswith (input_line_pointer, "@gotcode"))
{
gotrel = 1;
code = 1;
input_line_pointer += 8;
}
/* i32.const data@got */
- else if (strncmp (input_line_pointer, "@got", 4) == 0)
+ else if (startswith (input_line_pointer, "@got"))
{
gotrel = 1;
input_line_pointer += 4;
}
/* call f@plt{__sigchar_FiiiiE} */
- else if (strncmp (input_line_pointer, "@plt", 4) == 0)
+ else if (startswith (input_line_pointer, "@plt"))
{
char *end_of_sig;
code = 1;
input_line_pointer += 4;
- if (strncmp (input_line_pointer, "{", 1) == 0
+ if (startswith (input_line_pointer, "{")
&& (end_of_sig = strchr (input_line_pointer, '}')))
{
char *signature;
if (*input_line_pointer != '@')
return;
- if (strncmp (input_line_pointer + 1, "fptr", 4) == 0)
+ if (startswith (input_line_pointer + 1, "fptr"))
{
input_line_pointer += 5;
SKIP_WHITESPACE ();
unsigned i;
const char *directive_string;
- if (strncmp (input_line_pointer, "no-", 3) != 0)
+ if (!startswith (input_line_pointer, "no-"))
*negated = false;
else
{
equivalent to .begin [no-]transform. We should remove it when
we stop accepting those options. */
- if (strncmp (input_line_pointer, "generics", strlen ("generics")) == 0)
+ if (startswith (input_line_pointer, "generics"))
{
as_warn (_("[no-]generics is deprecated; use [no-]transform instead"));
directive_string = "transform";
}
- else if (strncmp (input_line_pointer, "relax", strlen ("relax")) == 0)
+ else if (startswith (input_line_pointer, "relax"))
{
as_warn (_("[no-]relax is deprecated; use [no-]transform instead"));
directive_string = "transform";
xg_instruction_matches_option_term (TInsn *insn, const ReqOrOption *option)
{
if (strcmp (option->option_name, "realnop") == 0
- || strncmp (option->option_name, "IsaUse", 6) == 0)
+ || startswith (option->option_name, "IsaUse"))
{
/* These conditions were evaluated statically when building the
relaxation table. There's no need to reevaluate them now. */
&& (name[fake_size] == 'F'
|| name[fake_size] == 'L'
|| (name[fake_size] == 'e'
- && strncmp ("endfunc", name+fake_size, 7) == 0)))
+ && startswith (name + fake_size, "endfunc"))))
return true;
return false;
size_t len = strlen (text_name);
if (len >= 5
&& (strcmp (text_name + len - 5, ".text") == 0
- || strncmp (text_name, ".text", 5) == 0))
+ || startswith (text_name, ".text")))
len -= 5;
name = XNEWVEC (char, len + strlen (base_name) + 1);
- if (strncmp (text_name, ".text", 5) == 0)
+ if (startswith (text_name, ".text"))
{
strcpy (name, base_name);
strcat (name, text_name + 5);
p = skip_white (p);
/* Check for "==" and "!=". */
- if (strncmp (p, "==", 2) == 0)
+ if (startswith (p, "=="))
precond->cmpop = OP_EQUAL;
- else if (strncmp (p, "!=", 2) == 0)
+ else if (startswith (p, "!="))
precond->cmpop = OP_NOTEQUAL;
else
return false;
ReqOrOption *req;
ReqOrOption **r_p;
- if (strncmp (option_name, "no-", 3) == 0)
+ if (startswith (option_name, "no-"))
{
option_name = xstrdup (&option_name[3]);
is_true = false;
|| req_or_option->next != NULL)
continue;
- if (strncmp (req_or_option->option_name, "IsaUse", 6) == 0)
+ if (startswith (req_or_option->option_name, "IsaUse"))
{
bool option_available = false;
char *option_name = req_or_option->option_name + 6;
xtensa_opcode opcode;
static char wbr_name_buf[20];
- if (strncmp (opcode_name, "WIDE.", 5) != 0)
+ if (!startswith (opcode_name, "WIDE."))
return false;
strcpy (wbr_name_buf, opcode_name + 5);
saved_ilp = input_line_pointer;
c = get_symbol_name (& name);
- if (strncmp (name, ".eh_frame", sizeof ".eh_frame") == 0
+ if (startswith (name, ".eh_frame")
&& name[9] != '_')
sections |= CFI_EMIT_eh_frame;
- else if (strncmp (name, ".debug_frame", sizeof ".debug_frame") == 0)
+ else if (startswith (name, ".debug_frame"))
sections |= CFI_EMIT_debug_frame;
#if SUPPORT_COMPACT_EH
- else if (strncmp (name, ".eh_frame_entry",
- sizeof ".eh_frame_entry") == 0)
+ else if (startswith (name, ".eh_frame_entry"))
{
compact_eh = true;
sections |= CFI_EMIT_eh_frame_compact;
SKIP_WHITESPACE ();
}
- if (strncmp (input_line_pointer, "md5", 3) == 0)
+ if (startswith (input_line_pointer, "md5"))
{
input_line_pointer += 3;
SKIP_WHITESPACE ();
/* First make sure that the CIE Identifier Tag is 0/-1. */
- if (strncmp (segment_name (now_seg), ".debug_frame", 12) == 0)
+ if (startswith (segment_name (now_seg), ".debug_frame"))
CIE_id = (char)0xff;
else
CIE_id = 0;
#endif
/* Select the proper section data. */
- if (strncmp (segment_name (now_seg), ".eh_frame", 9) == 0
+ if (startswith (segment_name (now_seg), ".eh_frame")
&& segment_name (now_seg)[9] != '_')
d = &eh_frame_data;
- else if (strncmp (segment_name (now_seg), ".debug_frame", 12) == 0)
+ else if (startswith (segment_name (now_seg), ".debug_frame"))
d = &debug_frame_data;
else
return 0;
if (c == 'N')
{
if (fgets (buf, sizeof (buf), f_in)
- && !strncmp (buf, "O_APP", 5) && ISSPACE (buf[5]))
+ && startswith (buf, "O_APP") && ISSPACE (buf[5]))
preprocess = 0;
if (!strchr (buf, '\n'))
ungetc ('#', f_in); /* It was longer. */
else if (c == 'A')
{
if (fgets (buf, sizeof (buf), f_in)
- && !strncmp (buf, "PP", 2) && ISSPACE (buf[2]))
+ && startswith (buf, "PP") && ISSPACE (buf[2]))
preprocess = 1;
if (!strchr (buf, '\n'))
ungetc ('#', f_in);
const char *segname;
segname = segment_name (now_seg);
- if (strncmp (segname, ".debug", sizeof ".debug" - 1) == 0
- || strncmp (segname, ".line", sizeof ".line" - 1) == 0)
+ if (startswith (segname, ".debug")
+ || startswith (segname, ".line"))
listing_tail->debugging = 1;
}
#endif
const char *segname;
segname = segment_name (now_seg);
- if (strncmp (segname, ".debug", sizeof ".debug" - 1) == 0
- || strncmp (segname, ".line", sizeof ".line" - 1) == 0)
+ if (startswith (segname, ".debug")
+ || startswith (segname, ".line"))
new_i->debugging = 1;
}
#endif
line++;
- if (strncmp (line, "def", 3) == 0)
+ if (startswith (line, "def"))
return 1;
- if (strncmp (line, "val", 3) == 0)
+ if (startswith (line, "val"))
return 1;
- if (strncmp (line, "scl", 3) == 0)
+ if (startswith (line, "scl"))
return 1;
- if (strncmp (line, "line", 4) == 0)
+ if (startswith (line, "line"))
return 1;
- if (strncmp (line, "endef", 5) == 0)
+ if (startswith (line, "endef"))
return 1;
- if (strncmp (line, "ln", 2) == 0)
+ if (startswith (line, "ln"))
return 1;
- if (strncmp (line, "type", 4) == 0)
+ if (startswith (line, "type"))
return 1;
- if (strncmp (line, "size", 4) == 0)
+ if (startswith (line, "size"))
return 1;
- if (strncmp (line, "dim", 3) == 0)
+ if (startswith (line, "dim"))
return 1;
- if (strncmp (line, "tag", 3) == 0)
+ if (startswith (line, "tag"))
return 1;
- if (strncmp (line, "stabs", 5) == 0)
+ if (startswith (line, "stabs"))
return 1;
- if (strncmp (line, "stabn", 5) == 0)
+ if (startswith (line, "stabn"))
return 1;
return 0;
char *tmp_buf = 0;
s = input_line_pointer;
- if (strncmp (s, "APP\n", 4))
+ if (!startswith (s, "APP\n"))
{
/* We ignore it. */
ignore_rest_of_line ();
/* The GNU toolchain uses an extension for ELF: a
section beginning with the magic string
.gnu.linkonce is a linkonce section. */
- && strncmp (segment_name (symsec), ".gnu.linkonce",
- sizeof ".gnu.linkonce" - 1) == 0))
+ && startswith (segment_name (symsec), ".gnu.linkonce")))
continue;
}
return;
section_name = bfd_section_name (sec);
- if (strncmp (section_name, ".debug_", 7) != 0)
+ if (!startswith (section_name, ".debug_"))
return;
strm = compress_init ();
/* Skip linkonce sections - we cannot use these section symbols as they may disappear. */
&& (bsym->section->flags & (SEC_CODE | SEC_LINK_ONCE)) == SEC_CODE
/* Not all linkonce sections are flagged... */
- && strncmp (S_GET_NAME (sym), ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) != 0)
+ && !startswith (S_GET_NAME (sym), ".gnu.linkonce"))
{
/* Create a version note. */
frag_now_fix ();