]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* write.c (md_register_arithmetic): Define.
authorAlan Modra <amodra@gmail.com>
Fri, 19 Sep 2008 10:53:51 +0000 (10:53 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 19 Sep 2008 10:53:51 +0000 (10:53 +0000)
(fixup_segment): Pass segment to TC_FORCE_RELOCATION_SUB_ABS,
TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB invocations.
Modify error message when registers involved.
(TC_FORCE_RELOCATION_SUB_ABS): Heed md_register_arithmetic.
(TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB): Likewise.
* config/tc-frv.h (TC_FORCE_RELOCATION_SUB_LOCAL): Likewise.
* config/tc-hppa.h (TC_FORCE_RELOCATION_SUB_LOCAL): Likewise.
* config/tc-mn10300.h (TC_VALIDATE_FIX_SUB): Likewise.
* config/tc-sh.h (TC_FORCE_RELOCATION_SUB_ABS): Likewise.
(TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB): Likewise.
* config/tc-sh64.h (TC_VALIDATE_FIX_SUB): Likewise.
* config/tc-xtensa.h (TC_VALIDATE_FIX_SUB): Likewise.
* doc/internals.texi (TC_FORCE_RELOCATION_SUB_ABS,
TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB): Show new param.

gas/ChangeLog
gas/config/tc-frv.h
gas/config/tc-hppa.h
gas/config/tc-mn10300.h
gas/config/tc-sh.h
gas/config/tc-sh64.h
gas/config/tc-xtensa.h
gas/doc/internals.texi
gas/write.c

index 56cbe731c6550f486158c8b1b223f7e31408a8c2..49e7320845270e2a3a9adca6d7fabf9283682b27 100644 (file)
@@ -1,3 +1,21 @@
+2008-09-19  Alan Modra  <amodra@bigpond.net.au>
+
+       * write.c (md_register_arithmetic): Define.
+       (fixup_segment): Pass segment to TC_FORCE_RELOCATION_SUB_ABS,
+       TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB invocations.
+       Modify error message when registers involved.
+       (TC_FORCE_RELOCATION_SUB_ABS): Heed md_register_arithmetic.
+       (TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB): Likewise.
+       * config/tc-frv.h (TC_FORCE_RELOCATION_SUB_LOCAL): Likewise.
+       * config/tc-hppa.h (TC_FORCE_RELOCATION_SUB_LOCAL): Likewise.
+       * config/tc-mn10300.h (TC_VALIDATE_FIX_SUB): Likewise.
+       * config/tc-sh.h (TC_FORCE_RELOCATION_SUB_ABS): Likewise.
+       (TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB): Likewise.
+       * config/tc-sh64.h (TC_VALIDATE_FIX_SUB): Likewise.
+       * config/tc-xtensa.h (TC_VALIDATE_FIX_SUB): Likewise.
+       * doc/internals.texi (TC_FORCE_RELOCATION_SUB_ABS,
+       TC_FORCE_RELOCATION_SUB_LOCAL, TC_VALIDATE_FIX_SUB): Show new param.
+
 2008-09-15  Alan Modra  <amodra@bigpond.net.au>
 
        * write.c (install_reloc): Correct EMIT_SECTION_SYMBOLS test.
index ad7eee0d353f0406e015ae460f47971b19888d2e..732dacd43c4fef8547e2e30798c3612f86dcb774 100644 (file)
@@ -61,7 +61,7 @@ extern int frv_force_relocation (struct fix *);
 /* If we simplify subtractions that aren't SUB_SAME or SUB_ABS, we end
    up with PCrel fixups, but since we don't have any PCrel relocs, we
    crash.  Preventing simplification gets us a good, early error.  */
-#define TC_FORCE_RELOCATION_SUB_LOCAL(fixP) 1
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
 
 #undef GAS_CGEN_MAX_FIXUPS
 #define GAS_CGEN_MAX_FIXUPS 1
index 498cb25bae783fc6eed1d6dd0e51ffaa6afc06ca..05168b150c84d5e275e1dcad618d3946c1f1569d 100644 (file)
@@ -155,7 +155,7 @@ int hppa_fix_adjustable (struct fix *);
    difference expression can't be used between text and data symbols,
    or between symbols in different executable modules.  */
 #define DIFF_EXPR_OK 1
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) 1
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
 #define UNDEFINED_DIFFERENCE_OK
 #endif
 
index 63ca74ae1d4853d73c2cae48640d8d520ea8ba6f..2fffaa3a2eb7f15c19ad82a2a2cb5545ad53d44b 100644 (file)
@@ -70,7 +70,7 @@ void mn10300_cons_fix_new (fragS *, int, int, expressionS *);
 
 /* We validate subtract arguments within tc_gen_reloc(), so don't
    report errors at this point.  */
-#define TC_VALIDATE_FIX_SUB(FIX) 1
+#define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
 
 /* Fixup debug sections since we will never relax them.  Ideally, we
    could do away with this and instead check every single fixup with
index dfdabd479c67675776a3b68539af883dc0dd15dd..51b656197f6dc7acb504f776fc702eda5dec8891 100644 (file)
@@ -83,8 +83,9 @@ extern int sh_force_relocation (struct fix *);
    || (sh_relax && SWITCH_TABLE (FIX)))
 
 /* Don't complain when we leave fx_subsy around.  */
-#define TC_VALIDATE_FIX_SUB(FIX)                       \
-  (sh_relax && SWITCH_TABLE (FIX))
+#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
+  ((md_register_arithmetic || (SEG) != reg_section)    \
+   && sh_relax && SWITCH_TABLE (FIX))
 
 #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC)
 extern long md_pcrel_from_section (struct fix *, segT);
@@ -207,18 +208,22 @@ extern bfd_boolean sh_fix_adjustable (struct fix *);
    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC           \
    || TC_FORCE_RELOCATION (FIX))
 
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) (sh_relax && SWITCH_TABLE (FIX))
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG)                \
+  ((!md_register_arithmetic && (SEG) == reg_section)   \
+   || (sh_relax && SWITCH_TABLE (FIX)))
 
 /* This keeps the subtracted symbol around, for use by PLT_PCREL
    relocs.  */
-#define TC_FORCE_RELOCATION_SUB_ABS(FIX)               \
-  ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL)
+#define TC_FORCE_RELOCATION_SUB_ABS(FIX, SEG)          \
+  ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL          \
+   || (!md_register_arithmetic && (SEG) == reg_section))
 
 /* Don't complain when we leave fx_subsy around.  */
 #undef TC_VALIDATE_FIX_SUB
-#define TC_VALIDATE_FIX_SUB(FIX)                       \
-  ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL          \
-   || (sh_relax && SWITCH_TABLE (FIX)))
+#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
+  ((md_register_arithmetic || (SEG) != reg_section)    \
+   && ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL      \
+       || (sh_relax && SWITCH_TABLE (FIX))))
 
 #define md_parse_name(name, exprP, mode, nextcharP) \
   sh_parse_name ((name), (exprP), (mode), (nextcharP))
index 23e72f62f2ceff09c539580a574de59ce427ec10..17f09003c8ba29e228a900310b7a70c4c710e2c3 100644 (file)
@@ -115,10 +115,11 @@ extern int sh64_target_mach (void);
 
 /* Don't complain when we leave fx_subsy around.  */
 #undef TC_VALIDATE_FIX_SUB
-#define TC_VALIDATE_FIX_SUB(FIX)                       \
-  ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL          \
-   || (sh_relax && SWITCH_TABLE (FIX))                 \
-   || *symbol_get_tc ((FIX)->fx_addsy) != NULL)
+#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
+  ((md_register_arithmetic || (SEG) != reg_section)    \
+   && ((FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL      \
+       || (sh_relax && SWITCH_TABLE (FIX))             \
+       || *symbol_get_tc ((FIX)->fx_addsy) != NULL))
 
 /* Note the kludge: we want to put back C, and we also want to consume the
    expression, since we have handled it ourselves.  FIXME: What we really
index 987b82adb9c5105f14cee7595636bb2ce487c69c..dbb5267102f4a170610efb0040e8b9c8fd40d342 100644 (file)
@@ -335,7 +335,7 @@ extern char *xtensa_section_rename (char *);
 #define TC_FORCE_RELOCATION(fix)       xtensa_force_relocation (fix)
 #define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
   (! SEG_NORMAL (seg) || xtensa_force_relocation (fix))
-#define        TC_VALIDATE_FIX_SUB(fix)        xtensa_validate_fix_sub (fix)
+#define        TC_VALIDATE_FIX_SUB(fix, seg)   xtensa_validate_fix_sub (fix)
 #define NO_PSEUDO_DOT                  xtensa_check_inside_bundle ()
 #define tc_canonicalize_symbol_name(s) xtensa_section_rename (s)
 #define tc_canonicalize_section_name(s)        xtensa_section_rename (s)
index cfb9a93e63acf9fc3936035f0c7412d9f93f2e43..7c6172c5f840fc67fb342ee33b12c8ff1055911a 100644 (file)
@@ -1309,17 +1309,17 @@ the subtrahend will be resolved and @code{fx_subsy} set to @code{NULL} for
 @w{@code{! SEG_NORMAL (@var{seg}) || TC_FORCE_RELOCATION (@var{fix})}} will
 be used.
 
-@item TC_FORCE_RELOCATION_SUB_ABS (@var{fix})
+@item TC_FORCE_RELOCATION_SUB_ABS (@var{fix}, @var{seg)
 @cindex TC_FORCE_RELOCATION_SUB_ABS
 Like @code{TC_FORCE_RELOCATION_SUB_SAME}, but used when the subtrahend is an
 absolute symbol.  If the macro is undefined a default of @code{0} is used.
 
-@item TC_FORCE_RELOCATION_SUB_LOCAL (@var{fix})
+@item TC_FORCE_RELOCATION_SUB_LOCAL (@var{fix}, @var{seg)
 @cindex TC_FORCE_RELOCATION_SUB_LOCAL
 Like @code{TC_FORCE_RELOCATION_SUB_ABS}, but the subtrahend is a symbol in the
 same section as the fixup.
 
-@item TC_VALIDATE_FIX_SUB (@var{fix})
+@item TC_VALIDATE_FIX_SUB (@var{fix}, @var{seg})
 @cindex TC_VALIDATE_FIX_SUB
 This macro is evaluated for any fixup with a @code{fx_subsy} that
 @code{fixup_segment} cannot reduce to a number.  If the macro returns
index f164e2eeab06e590972eeba811adbb748a3a96e4..1af81a7df9ba97232835fcce6567a4c966876ea9 100644 (file)
   (! SEG_NORMAL (SEG))
 #endif
 
+#ifndef md_register_arithmetic
+# define md_register_arithmetic 1
+#endif
+
 #ifndef TC_FORCE_RELOCATION_SUB_ABS
-#define TC_FORCE_RELOCATION_SUB_ABS(FIX)       0
+#define TC_FORCE_RELOCATION_SUB_ABS(FIX, SEG)  \
+  (!md_register_arithmetic && (SEG) == reg_section)
 #endif
 
 #ifndef TC_FORCE_RELOCATION_SUB_LOCAL
 #ifdef DIFF_EXPR_OK
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX)     0
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG)        \
+  (!md_register_arithmetic && (SEG) == reg_section)
 #else
-#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX)     1
+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG)        1
 #endif
 #endif
 
 #ifndef TC_VALIDATE_FIX_SUB
 #ifdef UNDEFINED_DIFFERENCE_OK
 /* The PA needs this for PIC code generation.  */
-#define TC_VALIDATE_FIX_SUB(FIX) 1
+#define TC_VALIDATE_FIX_SUB(FIX, SEG)                  \
+  (md_register_arithmetic || (SEG) != reg_section)
 #else
-#define TC_VALIDATE_FIX_SUB(FIX)               \
-  ((FIX)->fx_r_type == BFD_RELOC_GPREL32       \
-   || (FIX)->fx_r_type == BFD_RELOC_GPREL16)
+#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
 #endif
 
@@ -924,14 +932,14 @@ fixup_segment (fixS *fixP, segT this_segment)
 #endif
            }
          else if (sub_symbol_segment == absolute_section
-                  && !TC_FORCE_RELOCATION_SUB_ABS (fixP))
+                  && !TC_FORCE_RELOCATION_SUB_ABS (fixP, add_symbol_segment))
            {
              add_number -= S_GET_VALUE (fixP->fx_subsy);
              fixP->fx_offset = add_number;
              fixP->fx_subsy = NULL;
            }
          else if (sub_symbol_segment == this_segment
-                  && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP))
+                  && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP, add_symbol_segment))
            {
              add_number -= S_GET_VALUE (fixP->fx_subsy);
              fixP->fx_offset = (add_number + fixP->fx_dot_value
@@ -953,14 +961,20 @@ fixup_segment (fixS *fixP, segT this_segment)
              fixP->fx_subsy = NULL;
              fixP->fx_pcrel = 1;
            }
-         else if (!TC_VALIDATE_FIX_SUB (fixP))
+         else if (!TC_VALIDATE_FIX_SUB (fixP, add_symbol_segment))
            {
-             as_bad_where (fixP->fx_file, fixP->fx_line,
-                           _("can't resolve `%s' {%s section} - `%s' {%s section}"),
-                           fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
-                           segment_name (add_symbol_segment),
-                           S_GET_NAME (fixP->fx_subsy),
-                           segment_name (sub_symbol_segment));
+             if (!md_register_arithmetic
+                 && (add_symbol_segment == reg_section
+                     || sub_symbol_segment == reg_section))
+               as_bad_where (fixP->fx_file, fixP->fx_line,
+                             _("register value used as expression"));
+             else
+               as_bad_where (fixP->fx_file, fixP->fx_line,
+                             _("can't resolve `%s' {%s section} - `%s' {%s section}"),
+                             fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : "0",
+                             segment_name (add_symbol_segment),
+                             S_GET_NAME (fixP->fx_subsy),
+                             segment_name (sub_symbol_segment));
            }
        }