now_seg after closing output file

Message ID Y75R4sYOPg/8UuHm@squeak.grove.modra.org
State Repeat Merge
Headers
Series now_seg after closing output file |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Alan Modra Jan. 11, 2023, 6:06 a.m. UTC
  now_seg, a pointer into the output file sections, isn't valid after
the output file is closed.  gas doesn't and shouldn't use now_seg
after this point of course, but let's be safe.

	* output-file.c (output_file_close): Clear now_seg and now_subseg.
  

Patch

diff --git a/gas/output-file.c b/gas/output-file.c
index 127dc735703..0c3a8115bb1 100644
--- a/gas/output-file.c
+++ b/gas/output-file.c
@@ -99,6 +99,8 @@  output_file_close (void)
     res = bfd_cache_close_all ();
   else
     res = bfd_close (obfd);
+  now_seg = NULL;
+  now_subseg = 0;
 
   filename = out_file_name;
   out_file_name = NULL;