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

Message ID d025861b-3166-6e0c-b4bf-3e1a5805f426@suse.com
State New
Headers show
Series
  • gas: missing (re-)initialization of local variable in fixup_segment()
Related show

Commit Message

Jan Beulich via Binutils March 31, 2021, 8:50 a.m.
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.

Comments

Jan Beulich via Binutils April 1, 2021, 4:17 p.m. | #1
Hi Jan,

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

> 

> 	* write.c (fixup_segment): Move add_symbol_segment declaration

> 	into main loop.


Approved - please apply.

Cheers
   Nick

Patch

--- 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);