[PATCH] gas: missing (re-)initialization of local variable in fixup_segment()

Jan Beulich jbeulich@suse.com
Wed Mar 31 08:50:23 GMT 2021


At the very least this has been causing bogus diagnostics, e.g.

	.text
	.data
	.long .bss - .
	.long -.text
	.bss

yielding

Error: can't resolve `0' {.bss section} - `.text' {.text section}

instead of

Error: can't resolve `0' {*ABS* section} - `.text' {.text section}

In particular for targets overriding any of TC_FORCE_RELOCATION_* & Co
or for ones setting md_register_arithmetic to true the problems may be
worse.

gas/
2021-04-XX  Jan Beulich  <jbeulich@suse.com>

	* write.c (fixup_segment): Move add_symbol_segment declaration
	into main loop.

--- a/gas/write.c
+++ b/gas/write.c
@@ -923,7 +923,6 @@ fixup_segment (fixS *fixP, segT this_seg
 {
   valueT add_number;
   fragS *fragP;
-  segT add_symbol_segment = absolute_section;
 
   if (fixP != NULL && abs_section_sym == NULL)
     abs_section_sym = section_symbol (absolute_section);
@@ -954,6 +953,8 @@ fixup_segment (fixS *fixP, segT this_seg
 
   for (; fixP; fixP = fixP->fx_next)
     {
+      segT add_symbol_segment = absolute_section;
+
 #ifdef DEBUG5
       fprintf (stderr, "\nprocessing fixup:\n");
       print_fixup (fixP);


More information about the Binutils mailing list