+static void
+as_internal_value_out_of_range (const char *prefix,
+ offsetT val,
+ offsetT min,
+ offsetT max,
+ const char *file,
+ unsigned line,
+ bool bad)
+{
+ const char * err;
+ /* These buffer sizes are excessive, but better to be safe than sorry.
+ Note - these buffers are used in order to make the error message
+ string translateable. */
+ char val_buf [128];
+ char min_buf [128];
+ char max_buf [128];
+
+ if (prefix == NULL)
+ prefix = "";
+
+ if (val >= min && val <= max)
+ {
+ addressT right = max & -max;
+
+ if (max <= 1)
+ abort ();
+
+ sprintf (val_buf, "%" BFD_VMA_FMT "d", val);
+ sprintf (min_buf, "%" BFD_VMA_FMT "d", right);
+
+ /* xgettext:c-format */
+ err = _("%s out of domain (%s is not a multiple of %s)");
+
+ if (bad)
+ as_bad_where (file, line, err, prefix, val_buf, min_buf);
+ else
+ as_warn_where (file, line, err, prefix, val_buf, min_buf);
+ }
+ else if ( val < HEX_MAX_THRESHOLD
+ && min < HEX_MAX_THRESHOLD
+ && max < HEX_MAX_THRESHOLD
+ && val > HEX_MIN_THRESHOLD
+ && min > HEX_MIN_THRESHOLD
+ && max > HEX_MIN_THRESHOLD)
+ {
+ sprintf (val_buf, "%" BFD_VMA_FMT "d", val);
+ sprintf (min_buf, "%" BFD_VMA_FMT "d", min);
+ sprintf (max_buf, "%" BFD_VMA_FMT "d", max);
+
+ /* xgettext:c-format. */
+ err = _("%s out of range (%s is not between %s and %s)");
+
+ if (bad)
+ as_bad_where (file, line, err, prefix, val_buf, min_buf, max_buf);
+ else
+ as_warn_where (file, line, err, prefix, val_buf, min_buf, max_buf);
+ }
+ else
+ {
+ sprintf_vma (val_buf, (bfd_vma) val);
+ sprintf_vma (min_buf, (bfd_vma) min);
+ sprintf_vma (max_buf, (bfd_vma) max);
+
+ /* xgettext:c-format. */
+ err = _("%s out of range (0x%s is not between 0x%s and 0x%s)");
+
+ if (bad)
+ as_bad_where (file, line, err, prefix, val_buf, min_buf, max_buf);
+ else
+ as_warn_where (file, line, err, prefix, val_buf, min_buf, max_buf);
+ }
+}
+
+void
+as_warn_value_out_of_range (const char *prefix,
+ offsetT value,
+ offsetT min,
+ offsetT max,
+ const char *file,
+ unsigned line)
+{
+ as_internal_value_out_of_range (prefix, value, min, max, file, line, false);
+}
+
+void
+as_bad_value_out_of_range (const char *prefix,
+ offsetT value,
+ offsetT min,
+ offsetT max,
+ const char *file,
+ unsigned line)
+{
+ as_internal_value_out_of_range (prefix, value, min, max, file, line, true);
+}