Silence asan warnings in resolve_symbol_value

Alan Modra amodra@gmail.com
Fri Jan 17 08:37:31 GMT 2025


The ".quad with division (fwdref)" gas test fails with asan warning
negation of -9223372036854775808 cannot be represented in type 'long int'
Fix this and another similar case.

	* symbols.c (resolve_symbol_value): Cast "left" to valueT
	before negating.

diff --git a/gas/symbols.c b/gas/symbols.c
index 37a1e2b8215..14e6018b0cc 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -1596,7 +1596,7 @@ resolve_symbol_value (symbolS *symp)
 	    final_seg = absolute_section;
 
 	  if (op == O_uminus)
-	    left = -left;
+	    left = -(valueT) left;
 	  else if (op == O_logical_not)
 	    left = !left;
 	  else
@@ -1730,7 +1730,7 @@ resolve_symbol_value (symbolS *symp)
 		break;
 	      if (right == -1)
 		{
-		  left = -left;
+		  left = -(valueT) left;
 		  break;
 		}
 	      left /= right;

-- 
Alan Modra


More information about the Binutils mailing list