aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-nds32.c
diff options
context:
space:
mode:
Diffstat (limited to 'gas/config/tc-nds32.c')
-rw-r--r--gas/config/tc-nds32.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c
index 2e0b8e5..647744f 100644
--- a/gas/config/tc-nds32.c
+++ b/gas/config/tc-nds32.c
@@ -3896,7 +3896,7 @@ nds32_adjust_label (int n)
/* Only frag by alignment when needed.
Otherwise, it will fail to optimize labels on 4-byte boundary. (bug8454)
See md_convert_frag () and RELAX_SET_RELAXABLE (frag) for details. */
- if (frag_now_fix () & ((1 << n) -1 ))
+ if (frag_now_fix () & (((addressT) 1 << n) - 1))
{
if (subseg_text_p (now_seg))
{
@@ -3921,7 +3921,7 @@ nds32_adjust_label (int n)
old_frag = symbol_get_frag (label);
old_value = S_GET_VALUE (label);
- new_value = (valueT) frag_now_fix ();
+ new_value = frag_now_fix ();
/* Multiple labels may be on the same address. And the last symbol
may not be a label at all, e.g., register name, external function names,
@@ -4015,7 +4015,7 @@ add_mapping_symbol (enum mstate state, unsigned int padding_byte,
/* start adding mapping symbol */
seg_info (now_seg)->tc_segment_info_data.mapstate = state;
- make_mapping_symbol (state, (valueT) frag_now_fix () + padding_byte,
+ make_mapping_symbol (state, frag_now_fix () + padding_byte,
frag_now, align);
}
@@ -4208,8 +4208,6 @@ struct relax_hint_id *record_id_head = NULL;
/* Is the buffer large enough? */
#define MAX_BUFFER 12
-static char *nds_itoa (int n);
-
static char *
nds_itoa (int n)
{
@@ -4633,16 +4631,15 @@ nds32_handle_align (fragS *fragp)
{
static const unsigned char nop16[] = { 0x92, 0x00 };
static const unsigned char nop32[] = { 0x40, 0x00, 0x00, 0x09 };
- int bytes;
- char *p;
if (fragp->fr_type != rs_align_code)
return;
- bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
- p = fragp->fr_literal + fragp->fr_fix;
+ int bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
+ char *p = fragp->fr_literal + fragp->fr_fix;
+ int fix = bytes & 1;
- if (bytes & 1)
+ if (fix != 0)
{
*p++ = 0;
bytes--;
@@ -4659,17 +4656,15 @@ nds32_handle_align (fragS *fragp)
memcpy (p, nop16, 2);
p += 2;
bytes -= 2;
+ fix += 2;
}
+ fragp->fr_fix += fix;
- while (bytes >= 4)
+ if (bytes != 0)
{
+ fragp->fr_var = 4;
memcpy (p, nop32, 4);
- p += 4;
- bytes -= 4;
}
-
- bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
- fragp->fr_fix += bytes;
}
/* md_flush_pending_output */
@@ -5212,7 +5207,7 @@ static struct nds32_relax_hint_table relax_ls_table[] =
elimination itself or not, we have to return the next instruction range. */
static int
-nds32_elf_sethi_range (struct nds32_relocs_pattern *pattern)
+nds32_elf_sethi_range (const struct nds32_relocs_pattern *pattern)
{
int range = 0;
while (pattern)
@@ -5661,12 +5656,12 @@ static struct nds32_hint_map hint_map [] =
/* Find the relaxation pattern according to instructions. */
static bool
-nds32_find_reloc_table (struct nds32_relocs_pattern *relocs_pattern,
+nds32_find_reloc_table (const struct nds32_relocs_pattern *relocs_pattern,
struct nds32_relax_hint_table *hint_info)
{
unsigned int opcode, seq_size;
enum nds32_br_range range;
- struct nds32_relocs_pattern *pattern, *hi_pattern = NULL;
+ const struct nds32_relocs_pattern *pattern, *hi_pattern = NULL;
const char *opc = NULL;
relax_info_t *relax_info = NULL;
nds32_relax_fixup_info_t *fixup_info, *hint_fixup;
@@ -5931,9 +5926,8 @@ nds32_match_hint_insn (struct nds32_opcode *opcode, uint32_t seq)
static void
nds32_elf_append_relax_relocs (const char *key, const void *value)
{
- struct nds32_relocs_pattern *relocs_pattern =
- (struct nds32_relocs_pattern *) value;
- struct nds32_relocs_pattern *pattern_temp, *pattern_now;
+ const struct nds32_relocs_pattern *relocs_pattern = value;
+ const struct nds32_relocs_pattern *pattern_temp, *pattern_now;
symbolS *sym, *hi_sym = NULL;
expressionS exp;
fragS *fragP;
@@ -6268,7 +6262,7 @@ static int
nds32_elf_append_relax_relocs_traverse (void **slot, void *arg ATTRIBUTE_UNUSED)
{
string_tuple_t *tuple = *((string_tuple_t **) slot);
- nds32_elf_append_relax_relocs (tuple->key, tuple->value);
+ nds32_elf_append_relax_relocs (tuple->key, (const void *) tuple->value);
return 1;
}
@@ -6612,7 +6606,7 @@ md_section_align (segT segment, valueT size)
{
int align = bfd_section_alignment (segment);
- return ((size + (1 << align) - 1) & ((valueT) -1 << align));
+ return (size + ((valueT) 1 << align) - 1) & -((valueT) 1 << align);
}
/* GAS will call this function when a symbol table lookup fails, before it
@@ -7356,8 +7350,7 @@ md_atof (int type, char *litP, int *sizeP)
{
for (i = 0; i < prec; i++)
{
- md_number_to_chars (litP, (valueT) words[i],
- sizeof (LITTLENUM_TYPE));
+ md_number_to_chars (litP, words[i], sizeof (LITTLENUM_TYPE));
litP += sizeof (LITTLENUM_TYPE);
}
}
@@ -7365,8 +7358,7 @@ md_atof (int type, char *litP, int *sizeP)
{
for (i = prec - 1; i >= 0; i--)
{
- md_number_to_chars (litP, (valueT) words[i],
- sizeof (LITTLENUM_TYPE));
+ md_number_to_chars (litP, words[i], sizeof (LITTLENUM_TYPE));
litP += sizeof (LITTLENUM_TYPE);
}
}
@@ -7690,10 +7682,10 @@ nds32_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
return;
}
- if (fixP->fx_addsy == (symbolS *) NULL)
+ if (fixP->fx_addsy == NULL)
fixP->fx_done = 1;
- if (fixP->fx_subsy != (symbolS *) NULL)
+ if (fixP->fx_subsy != NULL)
{
/* HOW DIFF RELOCATION WORKS.
@@ -7834,7 +7826,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
code = fixP->fx_r_type;
reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
- if (reloc->howto == (reloc_howto_type *) NULL)
+ if (reloc->howto == NULL)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("internal error: can't export reloc type %d (`%s')"),