Make frag fr_fix unsigned

The field only stores unsigned values, so let's make it unsigned to
stop people worrying about the possibility of negative values.

	* frags.h (struct frag <fr_fix>): Use unsigned type.
	* frags.c (frag_new): Assert that current size exceeds
	old_frags_var_max_size.
	* ehopt.c (get_cie_info): Adjust for unsigned fr_fix.
	* listing.c (calc_hex): Likewise.
	* write.c (cvt_frag_to_fill, write_relocs): Likewise.
	* config/tc-arc.c (md_convert_frag): Likewise.
	* config/tc-avr.c (avr_patch_gccisr_frag): Likewise.
	* config/tc-mips.c (md_convert_frag): Likewise.
	* config/tc-rl78.c (md_convert_frag): Likewise.
	* config/tc-rx.c (md_convert_frag): Likewise.
	* config/tc-sparc.c (md_apply_fix): Likewise.
	* config/tc-xtensa.c (next_instrs_are_b_retw): Likewise.
	(unrelaxed_frag_min_insn_count, unrelaxed_frag_has_b_j): Likewise.
This commit is contained in:
Alan Modra 2019-04-15 21:51:44 +09:30
parent 02e902e1a1
commit 871a6bd2d8
13 changed files with 40 additions and 23 deletions

View File

@ -1,3 +1,20 @@
2019-04-16 Alan Modra <amodra@gmail.com>
* frags.h (struct frag <fr_fix>): Use unsigned type.
* frags.c (frag_new): Assert that current size exceeds
old_frags_var_max_size.
* ehopt.c (get_cie_info): Adjust for unsigned fr_fix.
* listing.c (calc_hex): Likewise.
* write.c (cvt_frag_to_fill, write_relocs): Likewise.
* config/tc-arc.c (md_convert_frag): Likewise.
* config/tc-avr.c (avr_patch_gccisr_frag): Likewise.
* config/tc-mips.c (md_convert_frag): Likewise.
* config/tc-rl78.c (md_convert_frag): Likewise.
* config/tc-rx.c (md_convert_frag): Likewise.
* config/tc-sparc.c (md_apply_fix): Likewise.
* config/tc-xtensa.c (next_instrs_are_b_retw): Likewise.
(unrelaxed_frag_min_insn_count, unrelaxed_frag_has_b_j): Likewise.
2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
* config/tc-arm.c (parse_sys_vldr_vstr): New function.

View File

@ -3271,7 +3271,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED,
int size, fix;
struct arc_relax_type *relax_arg = &fragP->tc_frag_data;
fix = (fragP->fr_fix < 0 ? 0 : fragP->fr_fix);
fix = fragP->fr_fix;
dest = fragP->fr_literal + fix;
table_entry = TC_GENERIC_RELAX_TABLE + fragP->fr_subtype;

View File

@ -2635,8 +2635,8 @@ avr_patch_gccisr_frag (fragS *fr, int reg)
/* Turn frag into ordinary code frag of now known size. */
fr->fr_var = 0;
fr->fr_fix = (offsetT) (where - fr->fr_literal);
gas_assert (fr->fr_fix <= fr->fr_offset);
fr->fr_fix = where - fr->fr_literal;
gas_assert (fr->fr_fix <= (valueT) fr->fr_offset);
fr->fr_offset = 0;
fr->fr_type = rs_fill;
fr->fr_subtype = 0;

View File

@ -19056,7 +19056,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
relax_substateT subtype = fragp->fr_subtype;
bfd_boolean second_longer = (subtype & RELAX_SECOND_LONGER) != 0;
bfd_boolean use_second = (subtype & RELAX_USE_SECOND) != 0;
int first, second;
unsigned int first, second;
fixS *fixp;
first = RELAX_FIRST (subtype);
@ -19099,7 +19099,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
sequence instead. */
while (fixp
&& fixp->fx_frag == fragp
&& fixp->fx_where < fragp->fr_fix - second)
&& (valueT) fixp->fx_where + second < fragp->fr_fix)
{
if (subtype & RELAX_USE_SECOND)
fixp->fx_done = 1;

View File

@ -1233,8 +1233,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
fragP->fr_next);
if (fragP->fr_next != NULL
&& ((offsetT) (fragP->fr_next->fr_address - fragP->fr_address)
!= fragP->fr_fix))
&& fragP->fr_next->fr_address - fragP->fr_address != fragP->fr_fix)
as_bad (_("bad frag at %p : fix %ld addr %ld %ld \n"), fragP,
(long) fragP->fr_fix,
(long) fragP->fr_address, (long) fragP->fr_next->fr_address);

View File

@ -2179,8 +2179,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
fragP->fr_var = 0;
if (fragP->fr_next != NULL
&& ((offsetT) (fragP->fr_next->fr_address - fragP->fr_address)
!= fragP->fr_fix))
&& fragP->fr_next->fr_address - fragP->fr_address != fragP->fr_fix)
as_bad (_("bad frag at %p : fix %ld addr %ld %ld \n"), fragP,
(long) fragP->fr_fix,
(long) fragP->fr_address, (long) fragP->fr_next->fr_address);

View File

@ -3566,7 +3566,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
can be completely resolved here, i.e. if no undefined
symbol is associated with it. */
if (sparc_relax && fixP->fx_addsy == NULL
&& fixP->fx_where + 8 <= fixP->fx_frag->fr_fix)
&& (valueT) fixP->fx_where + 8 <= fixP->fx_frag->fr_fix)
{
#define G0 0
#define O7 15

View File

@ -8295,7 +8295,7 @@ next_instrs_are_b_retw (fragS *fragP)
static xtensa_insnbuf insnbuf = NULL;
static xtensa_insnbuf slotbuf = NULL;
xtensa_isa isa = xtensa_default_isa;
int offset = 0;
unsigned int offset = 0;
int slot;
bfd_boolean branch_seen = FALSE;
@ -8688,7 +8688,7 @@ unrelaxed_frag_min_insn_count (fragS *fragP)
xtensa_isa isa = xtensa_default_isa;
static xtensa_insnbuf insnbuf = NULL;
int insn_count = 0;
int offset = 0;
unsigned int offset = 0;
if (!fragP->tc_frag_data.is_insn)
return insn_count;
@ -8741,7 +8741,7 @@ unrelaxed_frag_has_b_j (fragS *fragP)
{
static xtensa_insnbuf insnbuf = NULL;
xtensa_isa isa = xtensa_default_isa;
int offset = 0;
unsigned int offset = 0;
if (!fragP->tc_frag_data.is_insn)
return FALSE;

View File

@ -103,7 +103,7 @@ get_cie_info (struct cie_info *info)
{
fragS *f;
fixS *fix;
int offset;
unsigned int offset;
char CIE_id;
char augmentation[10];
int iaug;

View File

@ -165,7 +165,9 @@ frag_new (size_t old_frags_var_max_size
gas_assert (frchain_now->frch_last == frag_now);
/* Fix up old frag's fr_fix. */
frag_now->fr_fix = frag_now_fix_octets () - old_frags_var_max_size;
frag_now->fr_fix = frag_now_fix_octets ();
gas_assert (frag_now->fr_fix >= old_frags_var_max_size);
frag_now->fr_fix -= old_frags_var_max_size;
/* Make sure its type is valid. */
gas_assert (frag_now->fr_type != 0);

View File

@ -45,7 +45,7 @@ struct frag {
addressT last_fr_address;
/* (Fixed) number of octets we know we have. May be 0. */
offsetT fr_fix;
valueT fr_fix;
/* May be used for (Variable) number of octets after above.
The generic frag handling code no longer makes any use of fr_var. */
offsetT fr_var;

View File

@ -783,7 +783,7 @@ calc_hex (list_info_type *list)
{
/* Print as many bytes from the fixed part as is sensible. */
octet_in_frag = 0;
while ((offsetT) octet_in_frag < frag_ptr->fr_fix
while (octet_in_frag < frag_ptr->fr_fix
&& data_buffer_size < MAX_BYTES - 3)
{
if (address == ~(unsigned int) 0)
@ -801,8 +801,8 @@ calc_hex (list_info_type *list)
unsigned int var_rep_idx = octet_in_frag;
/* Print as many bytes from the variable part as is sensible. */
while (((offsetT) octet_in_frag
< (frag_ptr->fr_fix + frag_ptr->fr_var * frag_ptr->fr_offset))
while ((octet_in_frag
< frag_ptr->fr_fix + frag_ptr->fr_var * frag_ptr->fr_offset)
&& data_buffer_size < MAX_BYTES - 3)
{
if (address == ~(unsigned int) 0)
@ -816,7 +816,7 @@ calc_hex (list_info_type *list)
var_rep_idx++;
octet_in_frag++;
if ((offsetT) var_rep_idx >= frag_ptr->fr_fix + frag_ptr->fr_var)
if (var_rep_idx >= frag_ptr->fr_fix + frag_ptr->fr_var)
var_rep_idx = var_rep_max;
}
}

View File

@ -502,8 +502,8 @@ skip_align:
md_convert_frag (stdoutput, sec, fragP);
gas_assert (fragP->fr_next == NULL
|| ((offsetT) (fragP->fr_next->fr_address - fragP->fr_address)
== fragP->fr_fix));
|| (fragP->fr_next->fr_address - fragP->fr_address
== fragP->fr_fix));
/* After md_convert_frag, we make the frag into a ".space 0".
md_convert_frag() should set up any fixSs and constants
@ -1264,7 +1264,7 @@ write_relocs (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
for (fixp = seginfo->fix_root; fixp != (fixS *) NULL; fixp = fixp->fx_next)
{
int fx_size, slack;
offsetT loc;
valueT loc;
arelent **reloc;
#ifndef RELOC_EXPANSION_POSSIBLE
arelent *rel;