+2019-05-10 Nick Clifton <nickc@redhat.com>
+
+ PR 24538
+ * macro.c (get_any_string): Increase size of buffer used to hold
+ decimal value of expression result.
+ * dw2gencfi.c (get_debugseg_name): Handle an empty name.
+ * dwarf2dbg.c (get_filenum): Catch integer wraparound when
+ extending allocate file array.
+ (dwarf2_directive_filename): Add extra checks of the computed file
+ number.
+ * config/tc-arm.c (arm_tc_equal_in_insn): Insert copy of name into
+ warning hash table.
+ (s_arm_eabi_attribute): Check for obj_elf_vendor_attribute
+ returning -1.
+ * config/tc-i386.c (i386_output_nops): Catch an attempt to
+ generate nops of negative lengths.
+ * as.h (MAX_LITTLENUMS): Move definition to here from...
+ * config/atof-ieee.c: ...here.
+ * config/tc-aarch64.c: ...here.
+ * config/tc-arc.c: ...here.
+ * config/tc-arm.c: ...here.
+ * config/tc-epiphany.c: ...here.
+ * config/tc-i386.c: ...here.
+ * config/tc-ia64.c: ...here. (And correct the value).
+ * config/tc-m32c.c: ...here.
+ * config/tc-m32r.c: ...here.
+ * config/tc-metag.c: ...here.
+ * config/tc-microblaze.c: ...here.
+ * config/tc-nds32.c: ...here.
+ * config/tc-or1k.c: ...here.
+ * config/tc-score.c: ...here.
+ * config/tc-score7.c: ...here.
+ * config/tc-tic4x.c: ...here.
+ * config/tc-tilegx.c: ...here.
+ * config/tc-tilepro.c: ...here.
+ * config/tc-visium.c: ...here.
+ * config/tc-sh.c (md_assemble): Add check for an instruction with
+ no opcodes.
+ * config/tc-mips.c (mips_lookup_insn): Add check for very short
+ instruction name.
+ * config/tc-tic54x.c: Use unsigned chars to access is_end_of_line
+ array.
+ (tic54x_start_line_hook): Check for an empty line.
+ (next_line_shows_parallel): Do not walk off the end of the string.
+ (tic54x_macro_start): Check for too much macro nesting.
+ (tic54x_start_label): Add label_start parameter. Use this
+ parameter to check the first character of the label.
+
+ * config/tc-tic54x.h (TC_START_LABEL_WITHOUT_COLON): Pass
+ line_start variable to tic54x_start_label.
+
2019-05-10 Faraz Shahbazker <fshahbazker@wavecomp.com>
* config/tc-mips.c (macro) <M_ADD_I, M_SUB_I, M_DADD_I, M_DSUB_I>:
const char *, unsigned);
void print_version_id (void);
char * app_push (void);
+
+/* Number of littlenums required to hold an extended precision number. */
+#define MAX_LITTLENUMS 6
+
char * atof_ieee (char *, int, LITTLENUM_TYPE *);
const char * ieee_md_atof (int, char *, int *, bfd_boolean);
const char * vax_md_atof (int, char *, int *);
}
#endif
-#define MAX_LITTLENUMS 6
-
/* This is a utility function called from various tc-*.c files. It
is here in order to reduce code duplication.
set_error (AARCH64_OPDE_FATAL_SYNTAX_ERROR, error);
}
\f
-/* Number of littlenums required to hold an extended precision number. */
-#define MAX_LITTLENUMS 6
-
/* Return value for certain parsers when the parsing fails; those parsers
return the information of the parsed result, e.g. register number, on
success. */
#define LP_INSN(x) ((MAJOR_OPCODE (x) == 0x4) \
&& (SUB_OPCODE (x) == 0x28))
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
#ifndef TARGET_WITH_CPU
#define TARGET_WITH_CPU "arc700"
#endif /* TARGET_WITH_CPU */
"0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0", 0
};
-/* Number of littlenums required to hold an extended precision number. */
-#define MAX_LITTLENUMS 6
-
LITTLENUM_TYPE fp_values[NUM_FLOAT_VALS][MAX_LITTLENUMS];
#define FAIL (-1)
{
int tag = obj_elf_vendor_attribute (OBJ_ATTR_PROC);
- if (tag < NUM_KNOWN_OBJ_ATTRIBUTES)
+ if (tag >= 0 && tag < NUM_KNOWN_OBJ_ATTRIBUTES)
attributes_set_explicitly[tag] = 1;
}
already_warned = hash_new ();
/* Only warn about the symbol once. To keep the code
simple we let hash_insert do the lookup for us. */
- if (hash_insert (already_warned, name, NULL) == NULL)
+ if (hash_insert (already_warned, nbuf, NULL) == NULL)
as_warn (_("[-mwarn-syms]: Assignment makes a symbol match an ARM instruction: %s"), name);
}
else
of LITTLENUMS emitted is stored in *SIZEP. An error message is
returned, or NULL on OK. */
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
const char *
md_atof (int type, char *litP, int *sizeP)
{
/* Place the longer NOP first. */
int last;
int offset;
- const unsigned char *nops = patt[max_single_nop_size - 1];
+ const unsigned char *nops;
+
+ if (max_single_nop_size < 1)
+ {
+ as_fatal (_("i386_output_nops called to generate nops of at most %d bytes!"),
+ max_single_nop_size);
+ return;
+ }
+
+ nops = patt[max_single_nop_size - 1];
/* Use the smaller one if the requsted one isn't available. */
if (nops == NULL)
of LITTLENUMS emitted is stored in *SIZE. An error message is
returned, or NULL on OK. */
-#define MAX_LITTLENUMS 5
-
const char *
md_atof (int type, char *lit, int *size)
{
type, and store the appropriate bytes in *litP. The number of LITTLENUMS
emitted is stored in *sizeP . An error message is returned, or NULL on OK. */
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
const char *
md_atof (int type, char * litP, int * sizeP)
{
of LITTLENUMS emitted is stored in *SIZEP. An error message is
returned, or NULL on OK. */
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
const char *
md_atof (int type, char *litP, int *sizeP)
{
emitted is stored in *sizeP . An error message is returned, or NULL on OK.
*/
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
const char *
md_atof (int type, char * litP, int * sizeP)
{
return NULL;
}
-/* Various routines to kill one day. */
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
/* Turn a string in input_line_pointer into a floating point constant of type
type, and store the appropriate bytes in *litP. The number of LITTLENUMS
emitted is stored in *sizeP. An error message is returned, or NULL on OK.*/
+
const char *
md_atof (int type, char * litP, int * sizeP)
{
opend = dot != NULL ? dot - name : length;
if (opend >= 3 && name[opend - 2] == '1' && name[opend - 1] == '6')
suffix = 2;
- else if (name[opend - 2] == '3' && name[opend - 1] == '2')
+ else if (opend >= 2 && name[opend - 2] == '3' && name[opend - 1] == '2')
suffix = 4;
else
suffix = 0;
number_to_chars_littleendian (buf, val, n);
}
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
/* This function is called to convert an ASCII string into a floating point
value in format used by the CPU. */
type, and store the appropriate bytes in *litP. The number of LITTLENUMS
emitted is stored in *sizeP . An error message is returned, or NULL on OK. */
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
const char *
md_atof (int type, char * litP, int * sizeP)
{
? s3_INSN16_SIZE : (s3_GET_INSN_CLASS (type) == INSN_CLASS_48) \
? s3_INSN48_SIZE : s3_INSN_SIZE)
-#define s3_MAX_LITTLENUMS 6
#define s3_INSN_NAME_LEN 16
/* Relax will need some padding for alignment. */
s3_atof (int type, char *litP, int *sizeP)
{
int prec;
- LITTLENUM_TYPE words[s3_MAX_LITTLENUMS];
+ LITTLENUM_TYPE words[MAX_LITTLENUMS];
char *t;
int i;
#define s7_GET_INSN_SIZE(type) ((s7_GET_INSN_CLASS (type) == INSN_CLASS_16) \
? s7_INSN16_SIZE : s7_INSN_SIZE)
-#define s7_MAX_LITTLENUMS 6
#define s7_INSN_NAME_LEN 16
/* Relax will need some padding for alignment. */
s7_atof (int type, char *litP, int *sizeP)
{
int prec;
- LITTLENUM_TYPE words[s7_MAX_LITTLENUMS];
+ LITTLENUM_TYPE words[MAX_LITTLENUMS];
char *t;
int i;
char *name = initial_str;
int name_length = 0;
const sh_opcode_info *op;
- int found = 0;
+ bfd_boolean found = FALSE;
- /* identify opcode in string */
+ /* Identify opcode in string. */
while (ISSPACE (*name))
- {
- name++;
- }
- while (!ISSPACE (name[name_length]))
- {
- name_length++;
- }
+ name++;
+
+ while (name[name_length] != '\0' && !ISSPACE (name[name_length]))
+ name_length++;
- /* search for opcode in full list */
+ /* Search for opcode in full list. */
for (op = sh_table; op->name; op++)
{
if (strncasecmp (op->name, name, name_length) == 0
&& op->name[name_length] == '\0')
{
- found = 1;
+ found = TRUE;
break;
}
}
- if ( found )
- {
- as_bad (_("opcode not valid for this cpu variant"));
- }
+ if (found)
+ as_bad (_("opcode not valid for this cpu variant"));
else
- {
- as_bad (_("unknown opcode"));
- }
+ as_bad (_("unknown opcode"));
+
return;
}
#define TIC4X_ALT_SYNTAX
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6 /* (12 bytes) */
-
/* Handle of the inst mnemonic hash table. */
static struct hash_control *tic4x_op_hash = NULL;
first_inst = inst;
ok = 0;
}
- } while (!ok && !strcmp (inst->name, inst[1].name) && inst++);
+ }
+ while (!ok && !strcmp (inst->name, inst[1].name) && inst++);
if (ok > 0)
{
static struct hash_control *math_hash; /* Built-in math functions. */
/* Allow maximum levels of macro nesting; level 0 is the main substitution
symbol table. The other assembler only does 32 levels, so there! */
-static struct hash_control *subsym_hash[100];
+#define MAX_SUBSYM_HASH 100
+static struct hash_control *subsym_hash[MAX_SUBSYM_HASH];
/* Keep track of local labels so we can substitute them before GAS sees them
since macros use their own 'namespace' for local labels, use a separate hash
str = input_line_pointer;
while ((c = *input_line_pointer) != ',')
{
- if (is_end_of_line[(int) *input_line_pointer])
+ if (is_end_of_line[(unsigned char) c])
break;
++input_line_pointer;
}
{
/* Offset is ignored in inner structs. */
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
start_offset = get_absolute_expression ();
else
start_offset = 0;
int longword_align = 0;
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
count = get_absolute_expression ();
switch (type)
if (c == ',')
{
input_line_pointer++;
- if (is_end_of_line[(int) *input_line_pointer])
+ if (is_end_of_line[(unsigned char) *input_line_pointer])
c = *input_line_pointer;
}
}
SKIP_WHITESPACE ();
ver = input_line_pointer;
- while (!is_end_of_line[(int) *input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = 0;
/* Only ".align" with no argument is allowed within .struct/.union. */
int count = arg;
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
{
if (arg == 2)
as_warn (_("Argument to .even ignored"));
else
{
filename = input_line_pointer;
- while (!is_end_of_line[(int) *input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = '\0';
else
{
msg = input_line_pointer;
- while (!is_end_of_line[(int) *input_line_pointer])
+ while (!is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
c = *input_line_pointer;
*input_line_pointer = 0;
ILLEGAL_WITHIN_STRUCT ();
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
count = get_absolute_expression ();
do_repeat ((size_t) count, "LOOP", "ENDLOOP");
ILLEGAL_WITHIN_STRUCT ();
SKIP_WHITESPACE ();
- if (!is_end_of_line[(int) *input_line_pointer])
+ if (!is_end_of_line[(unsigned char) *input_line_pointer])
cond = get_absolute_expression ();
if (cond)
seg->flags |= SEC_TIC54X_BLOCK;
c = *input_line_pointer;
- if (!is_end_of_line[(int) c])
+ if (!is_end_of_line[(unsigned char) c])
++input_line_pointer;
}
if (c == ',')
{
++input_line_pointer;
- if (is_end_of_line[(int) *input_line_pointer])
+ if (is_end_of_line[(unsigned char) *input_line_pointer])
c = *input_line_pointer;
}
}
{
SKIP_WHITESPACE ();
len = 0;
- while (!is_end_of_line[(int) *input_line_pointer]
+ while (!is_end_of_line[(unsigned char) *input_line_pointer]
&& !ISSPACE (*input_line_pointer))
{
obstack_1grow (¬es, *input_line_pointer);
void
tic54x_macro_start (void)
{
- ++macro_level;
+ if (++macro_level >= MAX_SUBSYM_HASH)
+ {
+ as_fatal (_("Macro nesting is too deep"));
+ return;
+ }
subsym_hash[macro_level] = hash_new ();
local_label_hash[macro_level] = hash_new ();
}
int expecting_operand = 0;
int i;
- while (numexp < MAX_OPERANDS && !is_end_of_line[(int) *lptr])
+ while (numexp < MAX_OPERANDS && !is_end_of_line[(unsigned char) *lptr])
{
int paren_not_balanced = 0;
char *op_start, *op_end;
while (*lptr && ISSPACE (*lptr++))
;
- if (!is_end_of_line[(int) *lptr])
+ if (!is_end_of_line[(unsigned char) *lptr])
{
as_bad (_("Extra junk on line"));
return -1;
next_line_shows_parallel (char *next_line)
{
/* Look for the second half. */
- while (ISSPACE (*next_line))
+ while (*next_line != 0 && ISSPACE (*next_line))
++next_line;
return (next_line[0] == PARALLEL_SEPARATOR
if (strstr (line, ".macro"))
return line;
- while (!is_end_of_line[(int) *ptr])
+ unsigned char current_char;
+ while (!is_end_of_line[(current_char = * (unsigned char *) ptr)])
{
- int current_char = *ptr;
-
/* Need to update this since LINE may have been modified. */
if (eval_line)
eval_end = strrchr (ptr, ',');
char *replacement = NULL;
/* Work with a copy of the input line, including EOL char. */
- endp = input_line_pointer;
- while (!is_end_of_line[(int) *endp++])
- ;
+ for (endp = input_line_pointer; ; endp ++)
+ {
+ unsigned char c = * (unsigned char *) endp;
+ if (c == 0 || is_end_of_line [c])
+ break;
+ }
+
line = xmemdup0 (input_line_pointer, endp - input_line_pointer);
/* Scan ahead for parallel insns. */
Don't allow labels to start with '.' */
int
-tic54x_start_label (int nul_char, int next_char)
+tic54x_start_label (char * label_start, int nul_char, int next_char)
{
char *rest;
/* Disallow labels starting with "." */
if (next_char != ':')
{
- char *label = input_line_pointer;
-
- while (!is_end_of_line[(int) label[-1]])
- --label;
- if (*label == '.')
+ if (*label_start == '.')
{
- as_bad (_("Invalid label '%s'"), label);
+ as_bad (_("Invalid label '%s'"), label_start);
return 0;
}
}
- if (is_end_of_line[(int) next_char])
+ if (is_end_of_line[(unsigned char) next_char])
return 1;
rest = input_line_pointer;
#define TC_FRAG_TYPE int
#define TC_FRAG_INIT(FRAGP, MAX_BYTES) do {(FRAGP)->tc_frag_data = 0;}while (0)
-/* tell GAS whether the given token is indeed a code label */
+/* Tell GAS whether the given token is indeed a code label.
+ Note - we make of the knowledge that this macro will be called from
+ read.c:read_a_source_file() in that we also pass the local variable
+ line_start. */
#define TC_START_LABEL_WITHOUT_COLON(NUL_CHAR, NEXT_CHAR) \
- tic54x_start_label(NUL_CHAR, NEXT_CHAR)
-extern int tic54x_start_label (int, int);
+ tic54x_start_label (line_start, NUL_CHAR, NEXT_CHAR)
+extern int tic54x_start_label (char *, int, int);
/* custom handling for relocations in cons expressions */
#define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP, RELOC) \
{ NULL, 0, 0 }
};
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
void
md_number_to_chars (char * buf, valueT val, int n)
{
{ NULL, 0, 0 }
};
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
/* Turn the string pointed to by litP into a floating point constant
of type TYPE, and emit the appropriate bytes. The number of
LITTLENUMS emitted is stored in *SIZEP. An error message is
emitted is stored in *sizeP . An error message is returned,
or NULL on OK. */
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
const char *
md_atof (int type, char *litP, int *sizeP)
{
static char *
get_debugseg_name (segT seg, const char *base_name)
{
- const char *name;
+ const char * name;
+ const char * dollar;
+ const char * dot;
if (!seg)
- name = "";
- else
- {
- const char * dollar;
- const char * dot;
+ return concat (base_name, NULL);
- name = bfd_get_section_name (stdoutput, seg);
+ name = bfd_get_section_name (stdoutput, seg);
- dollar = strchr (name, '$');
- dot = strchr (name + 1, '.');
+ if (name == NULL || *name == 0)
+ return concat (base_name, NULL);
+
+ dollar = strchr (name, '$');
+ dot = strchr (name + 1, '.');
- if (!dollar && !dot)
- {
- if (!strcmp (base_name, ".eh_frame_entry")
- && strcmp (name, ".text") != 0)
- return concat (base_name, ".", name, NULL);
+ if (!dollar && !dot)
+ {
+ if (!strcmp (base_name, ".eh_frame_entry")
+ && strcmp (name, ".text") != 0)
+ return concat (base_name, ".", name, NULL);
- name = "";
- }
- else if (!dollar)
- name = dot;
- else if (!dot)
- name = dollar;
- else if (dot < dollar)
- name = dot;
- else
- name = dollar;
+ name = "";
}
+ else if (!dollar)
+ name = dot;
+ else if (!dot)
+ name = dollar;
+ else if (dot < dollar)
+ name = dot;
+ else
+ name = dollar;
return concat (base_name, name, NULL);
}
unsigned int old = files_allocated;
files_allocated = i + 32;
- files = XRESIZEVEC (struct file_entry, files, files_allocated);
+ /* Catch wraparound. */
+ if (files_allocated <= old)
+ {
+ as_bad (_("file number %u is too big"), i);
+ return 0;
+ }
+ files = XRESIZEVEC (struct file_entry, files, files_allocated);
memset (files + old, 0, (i + 32 - old) * sizeof (struct file_entry));
}
being supplied. Turn off gas generated debug info. */
debug_type = DEBUG_NONE;
- if (num < (int) files_in_use && files[num].filename != 0)
+ if (num < (offsetT) files_in_use && files[num].filename != 0)
{
as_bad (_("file number %ld already allocated"), (long) num);
return NULL;
}
+ else if (num < 0)
+ {
+ as_bad (_("file number %ld is too small!"), (long) num);
+ return NULL;
+ }
- get_filenum (filename, num);
+ get_filenum (filename, (unsigned int) num);
return filename;
}
else if (in->ptr[idx] == '%' && macro_alternate)
{
offsetT val;
- char buf[20];
+ char buf[64];
/* Turns the next expression into a string. */
/* xgettext: no-c-format */
input_line_pointer++;
/* Return pointing just after end-of-line. */
- know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
+ if (input_line_pointer <= buffer_limit)
+ know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
}
/* Sets frag for given symbol to zero_address_frag, except when the
+2019-05-10 Nick Clifton <nickc@redhat.com>
+
+ PR 24538
+ * ia64-opc.c (ia64_find_matching_opcode): Check for reaching the
+ end of the table prematurely.
+
2019-05-10 Faraz Shahbazker <fshahbazker@wavecomp.com>
* mips-opc.c (mips_opcodes): Enable ADD, SUB, DADD and DSUB
find_main_ent (short nameindex)
{
short start = 0;
- short end = sizeof (main_table) / sizeof (struct ia64_main_table);
+ short end = ARRAY_SIZE (main_table);
short i = (start + end) / 2;
if (nameindex < main_table[0].name_index
const char *suffix;
short name_index;
+ if ((unsigned) place >= ARRAY_SIZE (main_table))
+ return NULL;
+
if (strlen (name) > 128)
{
return NULL;