From 65879393f04e14a9ab8797a8e66e0ec8d94108b5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 14 Oct 2014 13:36:20 +1030 Subject: Avoid undefined behaviour with signed expressions PR 17453 bfd/ * libbfd.c (COERCE16, COERCE32, COERCE64): Use unsigned types. (EIGHT_GAZILLION): Delete. binutils/ * dwarf.c (read_leb128): Avoid signed overflow. (read_debug_line_header): Likewise. gas/ * config/tc-i386.c (fits_in_signed_long): Use unsigned param and expression to avoid signed overflow. (fits_in_signed_byte, fits_in_unsigned_byte, fits_in_unsigned_word, fits_in_signed_word, fits_in_unsigned_long): Similarly. * expr.c (operand <'-'>): Avoid signed overflow. * read.c (s_comm_internal): Likewise. --- gas/write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gas/write.c') diff --git a/gas/write.c b/gas/write.c index 0657b56..263b002 100644 --- a/gas/write.c +++ b/gas/write.c @@ -2309,7 +2309,7 @@ relax_align (register relax_addressT address, /* Address now. */ relax_addressT mask; relax_addressT new_address; - mask = ~((~0) << alignment); + mask = ~((relax_addressT) ~0 << alignment); new_address = (address + mask) & (~mask); #ifdef LINKER_RELAXING_SHRINKS_ONLY if (linkrelax) -- cgit v1.1