weakref gas internal error

Alan Modra amodra@gmail.com
Sun Jun 1 03:56:15 GMT 2025


This horrible testcase (cleaned up from oss-fuzz)
 r=x*2
 x=r-r
 .weakref r,x
 r=r-5
triggers resolve_symbol_value "gas_assert (final_val == 0)" in weakref
handling.

I'm not at all certain what we should do with this, but for now I'm
treating any assignment to r after the .weakref as a redefinition
that loses the weakrefr flag.

	* read.c (assign_symbol): Clear weakrefr.

diff --git a/gas/read.c b/gas/read.c
index 145a39c8652..c9cbd224a7d 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3306,6 +3306,7 @@ assign_symbol (char *name, int mode)
 	 retain the value of the symbol at the point of use.  */
       else if (S_IS_VOLATILE (symbolP))
 	symbolP = symbol_clone (symbolP, 1);
+      S_CLEAR_WEAKREFR (symbolP);
     }
 
   if (mode == 0)
	* read.c (assign_symbol): Clear weakrefr.

-- 
Alan Modra


More information about the Binutils mailing list