+2020-08-27 Alan Modra <amodra@gmail.com>
+
+ PR 26469
+ * elflink.c: Include limits.h.
+ (CHAR_BIT): Provide fallback define.
+ (set_symbol_value): Correct complex reloc comment.
+ (undefined_reference): Set bfd_error.
+ (BINARY_OP_HEAD, BINARY_OP_TAIL): Split out from..
+ (BINARY_OP): ..this.
+ (eval_symbol): Limit shifts. Force unsigned for left shift.
+ Catch divide by zero.
+ * configure.ac (AC_CHECK_HEADERS): Combine, sort and add limits.h.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2020-08-27 Alan Modra <amodra@gmail.com>
PR 26462
fi
-for ac_header in alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h wchar.h wctype.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-for ac_header in fcntl.h sys/file.h sys/time.h sys/stat.h sys/resource.h
+for ac_header in alloca.h fcntl.h limits.h stddef.h stdlib.h string.h \
+ strings.h sys/file.h sys/resource.h sys/stat.h sys/time.h \
+ time.h unistd.h wchar.h wctype.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
BFD_CC_FOR_BUILD
-AC_CHECK_HEADERS(alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h wchar.h wctype.h)
-AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h sys/resource.h)
+AC_CHECK_HEADERS(alloca.h fcntl.h limits.h stddef.h stdlib.h string.h \
+ strings.h sys/file.h sys/resource.h sys/stat.h sys/time.h \
+ time.h unistd.h wchar.h wctype.h)
GCC_HEADER_STDINT(bfd_stdint.h)
AC_HEADER_TIME
AC_HEADER_DIRENT
AC_SUBST(bfd_file_ptr)
AC_SUBST(bfd_ufile_ptr)
-dnl AC_CHECK_HEADERS(sys/mman.h)
AC_FUNC_MMAP
AC_CHECK_FUNCS(madvise mprotect)
case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in
#include "plugin.h"
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
/* This struct is used to pass information to routines called via
elf_link_hash_traverse which must return failure. */
implementation of them consists of two parts: complex symbols, and the
relocations themselves.
- The relocations are use a reserved elf-wide relocation type code (R_RELC
+ The relocations use a reserved elf-wide relocation type code (R_RELC
external / BFD_RELOC_RELC internal) and an encoding of relocation field
information (start bit, end bit, word width, etc) into the addend. This
information is extracted from CGEN-generated operand tables within gas.
- Complex symbols are mangled symbols (BSF_RELC external / STT_RELC
+ Complex symbols are mangled symbols (STT_RELC external / BSF_RELC
internal) representing prefix-notation expressions, including but not
limited to those sorts of expressions normally encoded as addends in the
addend field. The symbol mangling format is:
/* xgettext:c-format */
_bfd_error_handler (_("undefined %s reference in complex symbol: %s"),
reftype, name);
+ bfd_set_error (bfd_error_bad_value);
}
static bfd_boolean
return TRUE; \
}
-#define BINARY_OP(op) \
+#define BINARY_OP_HEAD(op) \
if (strncmp (sym, #op, strlen (#op)) == 0) \
{ \
sym += strlen (#op); \
++*symp; \
if (!eval_symbol (&b, symp, input_bfd, flinfo, dot, \
isymbuf, locsymcount, signed_p)) \
- return FALSE; \
+ return FALSE;
+#define BINARY_OP_TAIL(op) \
if (signed_p) \
*result = ((bfd_signed_vma) a) op ((bfd_signed_vma) b); \
else \
*result = a op b; \
return TRUE; \
}
+#define BINARY_OP(op) BINARY_OP_HEAD(op) BINARY_OP_TAIL(op)
default:
UNARY_OP (0-);
- BINARY_OP (<<);
- BINARY_OP (>>);
+ BINARY_OP_HEAD (<<);
+ if (b >= sizeof (a) * CHAR_BIT)
+ {
+ *result = 0;
+ return TRUE;
+ }
+ signed_p = 0;
+ BINARY_OP_TAIL (<<);
+ BINARY_OP_HEAD (>>);
+ if (b >= sizeof (a) * CHAR_BIT)
+ {
+ *result = signed_p && (bfd_signed_vma) a < 0 ? -1 : 0;
+ return TRUE;
+ }
+ BINARY_OP_TAIL (>>);
BINARY_OP (==);
BINARY_OP (!=);
BINARY_OP (<=);
UNARY_OP (~);
UNARY_OP (!);
BINARY_OP (*);
- BINARY_OP (/);
- BINARY_OP (%);
+ BINARY_OP_HEAD (/);
+ if (b == 0)
+ {
+ _bfd_error_handler (_("division by zero"));
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ BINARY_OP_TAIL (/);
+ BINARY_OP_HEAD (%);
+ if (b == 0)
+ {
+ _bfd_error_handler (_("division by zero"));
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ BINARY_OP_TAIL (%);
BINARY_OP (^);
BINARY_OP (|);
BINARY_OP (&);