From 5bc113360ccc33797a3f882e02824a5c426da175 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 16 Apr 2019 15:47:02 +0930 Subject: [PATCH] Move fixup fx_bit_fixP and fx_im_disp fields to TC_FIX_TYPE These are only used by dlx and ns32k. * write.h: Don't include bit_fix.h. (struct fix): Rearrange some fields. Delete fx_im_disp and fx_bit_fixP. Use bitfields for fx_size and fx_pcrel_adjust. * write.c (fix_new_internal): Don't init fx_im_disp and fx_bit_fixP. (fixup_segment): Don't exclude overflow checks on fx_bit_fixP. (print_fixup): Don't print im_disp. * config/tc-cris.c (md_apply_fix): Remove tests of fx_bit_fixP and fx_im_disp. * config/tc-dlx.c (md_apply_fix): Remove wrong debug code. Set fx_no_overflow when fx_bit_fixP. * config/tc-dlx.h: Include bit_fix.h. (TC_FIX_TYPE, tc_fix_data, TC_INIT_FIX_DATA): Define. * config/tc-ns32k.c (fix_new_ns32k, fix_new_ns32k_exp): Set fx_no_overflow when bit_fixP. * config/tc-ns32k.h (TC_FIX_TYPE): Add fx_bit_fixP and fx_im_disp. (fix_im_disp, fix_bit_fixP): Adjust to suit. (TC_INIT_FIX_DATA, TC_FIX_DATA_PRINT): Likewise. --- gas/ChangeLog | 20 ++++++++++++++++++++ gas/config/tc-cris.c | 24 ++++++++---------------- gas/config/tc-dlx.c | 14 ++------------ gas/config/tc-dlx.h | 6 ++++++ gas/config/tc-ns32k.c | 4 ++-- gas/config/tc-ns32k.h | 18 ++++++++++++------ gas/write.c | 14 ++------------ gas/write.h | 34 ++++++++++++++-------------------- 8 files changed, 66 insertions(+), 68 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 4a08de155cd..d74071bf12f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,23 @@ +2019-04-16 Alan Modra + + * write.h: Don't include bit_fix.h. + (struct fix): Rearrange some fields. Delete fx_im_disp and + fx_bit_fixP. Use bitfields for fx_size and fx_pcrel_adjust. + * write.c (fix_new_internal): Don't init fx_im_disp and fx_bit_fixP. + (fixup_segment): Don't exclude overflow checks on fx_bit_fixP. + (print_fixup): Don't print im_disp. + * config/tc-cris.c (md_apply_fix): Remove tests of fx_bit_fixP + and fx_im_disp. + * config/tc-dlx.c (md_apply_fix): Remove wrong debug code. Set + fx_no_overflow when fx_bit_fixP. + * config/tc-dlx.h: Include bit_fix.h. + (TC_FIX_TYPE, tc_fix_data, TC_INIT_FIX_DATA): Define. + * config/tc-ns32k.c (fix_new_ns32k, fix_new_ns32k_exp): Set + fx_no_overflow when bit_fixP. + * config/tc-ns32k.h (TC_FIX_TYPE): Add fx_bit_fixP and fx_im_disp. + (fix_im_disp, fix_bit_fixP): Adjust to suit. + (TC_INIT_FIX_DATA, TC_FIX_DATA_PRINT): Likewise. + 2019-04-16 Alan Modra * write.h (struct fix ): Make unsigned. diff --git a/gas/config/tc-cris.c b/gas/config/tc-cris.c index 07f68575280..198a2d71c9e 100644 --- a/gas/config/tc-cris.c +++ b/gas/config/tc-cris.c @@ -4054,23 +4054,15 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg) if (fixP->fx_addsy == 0 && !fixP->fx_pcrel) fixP->fx_done = 1; - if (fixP->fx_bit_fixP || fixP->fx_im_disp != 0) - { - as_bad_where (fixP->fx_file, fixP->fx_line, _("Invalid relocation")); - fixP->fx_done = 1; - } - else - { - /* We can't actually support subtracting a symbol. */ - if (fixP->fx_subsy != (symbolS *) NULL) - as_bad_where (fixP->fx_file, fixP->fx_line, - _("expression too complex")); + /* We can't actually support subtracting a symbol. */ + if (fixP->fx_subsy != (symbolS *) NULL) + as_bad_where (fixP->fx_file, fixP->fx_line, + _("expression too complex")); - /* This operand-type is scaled. */ - if (fixP->fx_r_type == BFD_RELOC_CRIS_LAPCQ_OFFSET) - val /= 2; - cris_number_to_imm (buf, val, fixP->fx_size, fixP, seg); - } + /* This operand-type is scaled. */ + if (fixP->fx_r_type == BFD_RELOC_CRIS_LAPCQ_OFFSET) + val /= 2; + cris_number_to_imm (buf, val, fixP->fx_size, fixP, seg); } /* All relocations are relative to the location just after the fixup; diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c index f1be6dba915..0b0fe2f1502 100644 --- a/gas/config/tc-dlx.c +++ b/gas/config/tc-dlx.c @@ -1014,10 +1014,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) free (fixP->fx_bit_fixP); fixP->fx_bit_fixP = NULL; } -#ifdef DEBUG - else - know ((fixP->fx_bit_fixP != NULL)); -#endif break; case RELOC_DLX_HI16: @@ -1027,10 +1023,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) free (fixP->fx_bit_fixP); fixP->fx_bit_fixP = NULL; } -#ifdef DEBUG - else - know ((fixP->fx_bit_fixP != NULL)); -#endif break; case RELOC_DLX_REL26: @@ -1040,10 +1032,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) free (fixP->fx_bit_fixP); fixP->fx_bit_fixP = NULL; } -#ifdef DEBUG - else - know ((fixP->fx_bit_fixP != NULL)); -#endif break; case BFD_RELOC_VTABLE_INHERIT: @@ -1066,6 +1054,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) number_to_chars_bigendian (place, val, fixP->fx_size); if (fixP->fx_addsy == NULL) fixP->fx_done = 1; + if (fixP->fx_bit_fixP != NULL) + fixP->fx_no_overflow = 1; } const char *md_shortopts = ""; diff --git a/gas/config/tc-dlx.h b/gas/config/tc-dlx.h index b6450aec36a..03659345d96 100644 --- a/gas/config/tc-dlx.h +++ b/gas/config/tc-dlx.h @@ -31,6 +31,12 @@ #define LEX_DOLLAR 1 +#include "bit_fix.h" + +#define TC_FIX_TYPE bit_fixS * +#define tc_fix_data fx_bit_fixP +#define TC_INIT_FIX_DATA(FIX) do (FIX)->fx_bit_fixP = NULL; while (0) + extern void dlx_pop_insert (void); extern int dlx_unrecognized_line (int); extern bfd_boolean md_dlx_fix_adjustable (struct fix *); diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c index 357cf00ff71..75cdabae885 100644 --- a/gas/config/tc-ns32k.c +++ b/gas/config/tc-ns32k.c @@ -1331,7 +1331,7 @@ fix_new_ns32k (fragS *frag, /* Which frag? */ fix_bsr (fixP) = bsr; fix_bit_fixP (fixP) = bit_fixP; /* We have a MD overflow check for displacements. */ - fixP->fx_no_overflow = (im_disp != 0); + fixP->fx_no_overflow = im_disp != 0 || bit_fixP != NULL; } static void @@ -1359,7 +1359,7 @@ fix_new_ns32k_exp (fragS *frag, /* Which frag? */ fix_bsr (fixP) = bsr; fix_bit_fixP (fixP) = bit_fixP; /* We have a MD overflow check for displacements. */ - fixP->fx_no_overflow = (im_disp != 0); + fixP->fx_no_overflow = im_disp != 0 || bit_fixP != NULL; } /* Convert number to chars in correct order. */ diff --git a/gas/config/tc-ns32k.h b/gas/config/tc-ns32k.h index a53ef976e44..d905f663845 100644 --- a/gas/config/tc-ns32k.h +++ b/gas/config/tc-ns32k.h @@ -91,14 +91,16 @@ extern const struct relax_type md_relax_table[]; struct \ { \ fragS * opcode_fragP; \ + bit_fixS * fx_bit_fixP; \ unsigned int opcode_offset; \ unsigned int bsr : 1; \ + unsigned int fx_im_disp : 2; \ } /* Accessor macros for things which may move around. See comments in write.h. */ -#define fix_im_disp(X) (X)->fx_im_disp -#define fix_bit_fixP(X) (X)->fx_bit_fixP +#define fix_im_disp(X) (X)->tc_fix_data.fx_im_disp +#define fix_bit_fixP(X) (X)->tc_fix_data.fx_bit_fixP #define fix_opcode_frag(X) (X)->tc_fix_data.opcode_fragP #define fix_opcode_offset(X) (X)->tc_fix_data.opcode_offset #define fix_bsr(X) (X)->tc_fix_data.bsr @@ -108,16 +110,20 @@ extern const struct relax_type md_relax_table[]; { \ fix_opcode_frag(X) = NULL; \ fix_opcode_offset(X) = 0; \ + fix_bit_fixP(X) = NULL; \ fix_bsr(X) = 0; \ + fix_im_disp(X) = 0; \ } \ while (0) #define TC_FIX_DATA_PRINT(FILE, FIX) \ do \ { \ - fprintf ((FILE), "opcode_frag=%ld, operand offset=%d, bsr=%d\n", \ - (unsigned long) fix_opcode_frag (FIX), \ - fix_opcode_offset (FIX), \ - fix_bsr (FIX)); \ + fprintf ((FILE), "opcode_frag=%ld, operand offset=%d, bsr=%d, " \ + "im_disp=%d\n", \ + (unsigned long) fix_opcode_frag (FIX), \ + fix_opcode_offset (FIX), \ + fix_bsr (FIX), \ + fix_im_disp (FIX)); \ } \ while (0) diff --git a/gas/write.c b/gas/write.c index 91767fbb36d..050fbe8da62 100644 --- a/gas/write.c +++ b/gas/write.c @@ -174,9 +174,7 @@ fix_new_internal (fragS *frag, /* Which frag? */ fixP->fx_dot_frag = dot_frag; fixP->fx_pcrel = pcrel; fixP->fx_r_type = r_type; - fixP->fx_im_disp = 0; fixP->fx_pcrel_adjust = 0; - fixP->fx_bit_fixP = 0; fixP->fx_addnumber = 0; fixP->fx_tcbit = 0; fixP->fx_tcbit2 = 0; @@ -1093,7 +1091,7 @@ fixup_segment (fixS *fixP, segT this_segment) symbol_mark_used_in_reloc (fixP->fx_subsy); } - if (!fixP->fx_bit_fixP && !fixP->fx_no_overflow && fixP->fx_size != 0) + if (!fixP->fx_no_overflow && fixP->fx_size != 0) { if (fixP->fx_size < sizeof (valueT)) { @@ -1131,7 +1129,7 @@ fixup_segment (fixS *fixP, segT this_segment) (long) add_number, (long) (fragP->fr_address + fixP->fx_where)); #endif - } /* Not a bit fix. */ + } #ifdef TC_VALIDATE_FIX skip: ATTRIBUTE_UNUSED_LABEL @@ -3142,14 +3140,6 @@ print_fixup (fixS *fixp) fprintf (stderr, " pcrel"); if (fixp->fx_pcrel_adjust) fprintf (stderr, " pcrel_adjust=%d", fixp->fx_pcrel_adjust); - if (fixp->fx_im_disp) - { -#ifdef TC_NS32K - fprintf (stderr, " im_disp=%d", fixp->fx_im_disp); -#else - fprintf (stderr, " im_disp"); -#endif - } if (fixp->fx_tcbit) fprintf (stderr, " tcbit"); if (fixp->fx_done) diff --git a/gas/write.h b/gas/write.h index a69ec3cd17c..96ad791d228 100644 --- a/gas/write.h +++ b/gas/write.h @@ -40,28 +40,21 @@ #define FAKE_LABEL_CHAR '\001' #endif -#include "bit_fix.h" - /* * FixSs may be built up in any order. */ struct fix { + /* Next fixS in linked list, or NULL. */ + struct fix *fx_next; + /* These small fields are grouped together for compactness of this structure, and efficiency of access on some architectures. */ /* Is this a pc-relative relocation? */ unsigned fx_pcrel : 1; - /* Is this value an immediate displacement? */ - /* Only used on ns32k; merge it into TC_FIX_TYPE sometime. */ - unsigned fx_im_disp : 2; - - /* Some bits for the CPU specific code. */ - unsigned fx_tcbit : 1; - unsigned fx_tcbit2 : 1; - /* Has this relocation already been applied? */ unsigned fx_done : 1; @@ -75,11 +68,20 @@ struct fix /* The value is signed when checking for overflow. */ unsigned fx_signed : 1; + /* Some bits for the CPU specific code. */ + unsigned fx_tcbit : 1; + unsigned fx_tcbit2 : 1; + + /* Spare bits. */ + unsigned fx_unused : 10; + /* pc-relative offset adjust (only used by some CPU specific code) */ - signed char fx_pcrel_adjust; + int fx_pcrel_adjust : 8; /* How many bytes are involved? */ - unsigned char fx_size; + unsigned fx_size : 8; + + bfd_reloc_code_real_type fx_r_type; /* Which frag does this fix apply to? */ fragS *fx_frag; @@ -102,14 +104,6 @@ struct fix /* The frag fx_dot_value is based on. */ fragS *fx_dot_frag; - /* Next fixS in linked list, or NULL. */ - struct fix *fx_next; - - /* If NULL, no bitfix's to do. */ - bit_fixS *fx_bit_fixP; - - bfd_reloc_code_real_type fx_r_type; - /* This field is sort of misnamed. It appears to be a sort of random scratch field, for use by the back ends. The main gas code doesn't do anything but initialize it to zero. The use of it does need to -- 2.30.2