/* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
- Copyright (C) 1998-2020 Free Software Foundation, Inc.
+ Copyright (C) 1998-2021 Free Software Foundation, Inc.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of GAS, the GNU Assembler.
#include "elf/ia64.h"
#include "bfdver.h"
#include <time.h>
-
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
{
struct label_fix *next;
struct symbol *sym;
- bfd_boolean dw2_mark_labels;
+ bool dw2_mark_labels;
};
#ifdef TE_VMS
segT saved_seg;
subsegT saved_subseg;
unw_rec_list *ptr;
- bfd_boolean mark;
+ bool mark;
if (!md.last_text_seg)
return;
/* In case there are labels following the last instruction, resolve
those now. */
- mark = FALSE;
+ mark = false;
for (lfix = CURR_SLOT.label_fixups; lfix; lfix = lfix->next)
{
symbol_set_value_now (lfix->sym);
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;
drpp = &dr->next;
base_reg += num_regs;
- str_hash_insert (md.dynreg_hash, name, dr);
+ if (str_hash_insert (md.dynreg_hash, name, dr, 0) != NULL)
+ {
+ as_bad (_("Attempt to redefine register set `%s'"), name);
+ obstack_free (¬es, name);
+ goto err;
+ }
if (*input_line_pointer != ',')
break;
c = get_symbol_name (&name);
symbolP = symbol_find_or_make (name);
- str_hash_insert (md.entry_hash, S_GET_NAME (symbolP), (void *) symbolP);
+ if (str_hash_insert (md.entry_hash, S_GET_NAME (symbolP), symbolP, 0))
+ as_bad (_("duplicate entry hint %s"), name);
*input_line_pointer = c;
SKIP_WHITESPACE_AFTER_NAME ();
sym = symbol_create (name, reg_section, &zero_address_frag, regnum);
- str_hash_insert (md.reg_hash, S_GET_NAME (sym), (void *) sym);
+ if (str_hash_insert (md.reg_hash, S_GET_NAME (sym), sym, 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
return sym;
}
{
if (i < NELEMS (CURR_SLOT.opnd))
{
- sep = parse_operand_maybe_eval (CURR_SLOT.opnd + i, '=',
- idesc->operands[i]);
+ enum ia64_opnd op = IA64_OPND_NIL;
+ if (i < NELEMS (idesc->operands))
+ op = idesc->operands[i];
+ sep = parse_operand_maybe_eval (CURR_SLOT.opnd + i, '=', op);
if (CURR_SLOT.opnd[i].X_op == O_absent)
break;
}
int n, i, j, first, curr, last_slot;
bfd_vma t0 = 0, t1 = 0;
struct label_fix *lfix;
- bfd_boolean mark_label;
+ bool mark_label;
struct insn_fix *ifix;
char mnemonic[16];
fixS *fix;
continue; /* Try next slot. */
/* Now is a good time to fix up the labels for this insn. */
- mark_label = FALSE;
+ mark_label = false;
for (lfix = md.slot[curr].label_fixups; lfix; lfix = lfix->next)
{
S_SET_VALUE (lfix->sym, frag_now_fix () - 16);
for (j = 0; j < md.slot[curr].num_fixups; ++j)
{
+ unsigned long where;
+
ifix = md.slot[curr].fixup + j;
- fix = fix_new_exp (frag_now, frag_now_fix () - 16 + i, 8,
+ where = frag_now_fix () - 16 + i;
+#ifdef TE_HPUX
+ /* Fix offset for PCREL60B relocation on HP-UX. */
+ if (ifix->code == BFD_RELOC_IA64_PCREL60B)
+ ++where;
+#endif
+
+ fix = fix_new_exp (frag_now, where, 8,
&ifix->expr, ifix->is_pcrel, ifix->code);
fix->tc_fix_data.opnd = ifix->opnd;
fix->fx_file = md.slot[curr].src_file;
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;
md.pseudo_hash = str_htab_create ();
for (i = 0; i < NELEMS (pseudo_opcode); ++i)
- str_hash_insert (md.pseudo_hash, pseudo_opcode[i].name,
- (void *) (pseudo_opcode + i));
+ if (str_hash_insert (md.pseudo_hash, pseudo_opcode[i].name,
+ pseudo_opcode + i, 0) != NULL)
+ as_fatal (_("duplicate %s"), pseudo_opcode[i].name);
md.reg_hash = str_htab_create ();
md.dynreg_hash = str_htab_create ();
declare_register ("psp", REG_PSP);
for (i = 0; i < NELEMS (const_bits); ++i)
- str_hash_insert (md.const_hash, const_bits[i].name,
- (void *) (const_bits + i));
+ if (str_hash_insert (md.const_hash, const_bits[i].name, const_bits + i, 0))
+ as_fatal (_("duplicate %s"), const_bits[i].name);
/* Set the architecture and machine depending on defaults and command line
options. */
fix = XOBNEW (¬es, struct label_fix);
fix->sym = sym;
fix->next = CURR_SLOT.tag_fixups;
- fix->dw2_mark_labels = FALSE;
+ fix->dw2_mark_labels = false;
CURR_SLOT.tag_fixups = fix;
return;
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 ();
h->file = as_where (&h->line);
h->name = name;
- str_hash_insert (ahash, alias, (void *) h);
- str_hash_insert (nhash, name, (void *) alias);
+ str_hash_insert (ahash, alias, h, 0);
+ str_hash_insert (nhash, name, alias, 0);
out:
demand_empty_rest_of_line ();
/* 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"),