]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: default TC_VALIDATE_FIX_SUB to 0
authorAlan Modra <amodra@gmail.com>
Sat, 10 Jul 2021 06:28:44 +0000 (15:58 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 14 Jul 2021 12:22:20 +0000 (21:52 +0930)
gas/write.c provides a fallback TC_VALIDATE_FIX_SUB define that can be
a problem for some targets, the problem being that a non-zero
definition of TC_VALIDATE_FIX_SUB says that some uses of fx_subsy are
OK, in effect that the target will handle fx_subsy in md_apply_fix
and/or tc_gen_reloc.  A lot of targets don't have the necessary
md_apply_fix and tc_gen_reloc support.  So a safer default is to
disallow fx_subsy by default.

I've had a good look over target usage of fx_subsy, and think I've
caught all the cases where targets need TC_VALIDATE_FIX_SUB.  Possible
failures would be limited to alpha, microblaze, ppc and s390 (the
targets that define UNDEFINED_DIFFERENCE_OK), or targets that generate
fixups with BFD_RELOC_GPREL32/16 and use a syntax explicitly showing
a difference expression.

* write.c (TC_VALIDATE_FIX_SUB): Default to 0.
* config/tc-hppa.h (TC_VALIDATE_FIX_SUB): Define.
* config/tc-microblaze.h (TC_VALIDATE_FIX_SUB): Define.
* config/tc-alpha.h (TC_VALIDATE_FIX_SUB): Define for ECOFF.
* config/tc-ppc.h (TC_VALIDATE_FIX_SUB): Don't define for ELF.
Do define for XCOFF.

gas/ChangeLog
gas/config/tc-alpha.h
gas/config/tc-hppa.h
gas/config/tc-microblaze.h
gas/config/tc-ppc.h
gas/write.c

index 7aaf08f0afe4f9a10f358d5c08c5f6ab02acd9f1..fbb112f622413d145eaac77d0b36ebd4cdaef080 100644 (file)
@@ -1,3 +1,12 @@
+2021-07-14  Alan Modra  <amodra@gmail.com>
+
+       * write.c (TC_VALIDATE_FIX_SUB): Default to 0.
+       * config/tc-hppa.h (TC_VALIDATE_FIX_SUB): Define.
+       * config/tc-microblaze.h (TC_VALIDATE_FIX_SUB): Define.
+       * config/tc-alpha.h (TC_VALIDATE_FIX_SUB): Define for ECOFF.
+       * config/tc-ppc.h (TC_VALIDATE_FIX_SUB): Don't define for ELF.
+       Do define for XCOFF.
+
 2021-07-14  ClĂ©ment Chigot  <clement.chigot@atos.net>
 
        * config/tc-ppc.c (ppc_change_debug_section): Update to
        * testsuite/gas/mips/mips2@cp3m.d: New test.
        * testsuite/gas/mips/r3000@cp3m.d: New test.
        * testsuite/gas/mips/r3900@cp3m.d: New test.
-       * testsuite/gas/mips/mips2@cp3d.d: New test.
+       * testsuite/gas/mips/mips2@cp3d.d: New test.
        * testsuite/gas/mips/cp0b.l: New test stderr output.
        * testsuite/gas/mips/cp0bl.l: New test stderr output.
        * testsuite/gas/mips/cp0c.l: New test stderr output.
index b7d7e8704e77c1783a0e9e427257026bba062d26..ed0ae63407cbc1872ba39a67fb8188e0df2f873e 100644 (file)
@@ -116,6 +116,11 @@ extern void alpha_handle_align (struct frag *);
 #ifdef OBJ_ECOFF
 #define tc_frob_file_before_adjust() alpha_frob_file_before_adjust ()
 extern void alpha_frob_file_before_adjust (void);
+
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
+  ((md_register_arithmetic || (SEG) != reg_section)    \
+   && ((FIX)->fx_r_type == BFD_RELOC_GPREL32           \
+       || (FIX)->fx_r_type == BFD_RELOC_GPREL16))
 #endif
 
 #define DIFF_EXPR_OK   /* foo-. gets turned into PC relative relocs.  */
index b4189918967eeeda68001a896a29d22ba06837f3..6842a7d8a0edefc8a47c1ffb17eabc3f70761811 100644 (file)
@@ -127,6 +127,10 @@ int hppa_fix_adjustable (struct fix *);
 /* Values passed to md_apply_fix don't include the symbol value.  */
 #define MD_APPLY_SYM_VALUE(FIX) 0
 
+/* The PA needs this for PIC code generation.  */
+#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
+  (md_register_arithmetic || (SEG) != reg_section)
+
 #ifdef OBJ_SOM
 /* If a symbol is imported, but never used, then the symbol should
    *not* end up in the symbol table.  Likewise for absolute symbols
index c6d33f873c4683b43b10822184d424d536057ba0..b2868fe1531cb5f864fc8240c5b942a5ad4e03bb 100644 (file)
@@ -51,6 +51,9 @@ extern bfd_reloc_code_real_type parse_cons_expression_microblaze
    || (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_GOTOFF       \
    || (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_32_GOTOFF)
 
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
+  (md_register_arithmetic || (SEG) != reg_section)
+
 #define tc_fix_adjustable(X)  tc_microblaze_fix_adjustable(X)
 extern int tc_microblaze_fix_adjustable (struct fix *);
 
index 790994e1314c83f8789d63ec9bdddaedfe37d8bf..4e175b0b70cf3e5079a6ada1c02064004cb16203 100644 (file)
@@ -285,8 +285,6 @@ extern int ppc_force_relocation (struct fix *);
      || (FIX)->fx_r_type == BFD_RELOC_PPC64_D34                        \
      || (FIX)->fx_r_type == BFD_RELOC_PPC64_D28))
 
-#define TC_VALIDATE_FIX_SUB(FIX, SEG) 0
-
 #endif /* OBJ_ELF */
 
 #define RELOC_EXPANSION_POSSIBLE
@@ -303,6 +301,10 @@ extern int ppc_force_relocation (struct fix *);
 /* XCOFF allows undefined differences which will be encoded with
    R_NEG relocations.  */
 #define UNDEFINED_DIFFERENCE_OK
+
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
+  (md_register_arithmetic || (SEG) != reg_section)
+
 #endif /* OBJ_XCOFF */
 
 /* Various frobbings of labels and their addresses.  */
index 7dc78b7fe19f42c172d386dd62583c6078b5dd28..2d67f167ff0a85444edd00cf36b1e3db10da2430 100644 (file)
 #endif
 
 #ifndef TC_VALIDATE_FIX_SUB
-#ifdef UNDEFINED_DIFFERENCE_OK
-/* The PA needs this for PIC code generation.  */
-#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
-  (md_register_arithmetic || (SEG) != reg_section)
-#else
-#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
-  ((md_register_arithmetic || (SEG) != reg_section)    \
-   && ((FIX)->fx_r_type == BFD_RELOC_GPREL32           \
-       || (FIX)->fx_r_type == BFD_RELOC_GPREL16))
-#endif
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) 0
 #endif
 
 #ifndef TC_LINKRELAX_FIXUP