diff options
author | Alan Modra <amodra@gmail.com> | 2022-07-07 19:56:10 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-07-09 21:20:31 +0930 |
commit | 07e64e0b7c6cd4a73220eb57588d0db6b2a192e3 (patch) | |
tree | b21fcb73f362e326904533bdbfa648bb9dce50b3 /gas | |
parent | c30081c1f955a9fea2da8988bab96191e3d2171e (diff) | |
download | fsf-binutils-gdb-07e64e0b7c6cd4a73220eb57588d0db6b2a192e3.zip fsf-binutils-gdb-07e64e0b7c6cd4a73220eb57588d0db6b2a192e3.tar.gz fsf-binutils-gdb-07e64e0b7c6cd4a73220eb57588d0db6b2a192e3.tar.bz2 |
gas: output_file_close
This is mostly a tidy with the aim of being able to free
out_file_name, but it does fix a possible attempt to unlink the output
file twice (not that that matters).
* as.h (keep_it): New global.
* as.c (keep_it): Delete.
(close_output_file): Delete, merged into..
* output-file.c (output_file_close): ..here. Delete parameter.
* output-file.h (output_file_close): Update prototype.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/as.c | 13 | ||||
-rw-r--r-- | gas/as.h | 3 | ||||
-rw-r--r-- | gas/output-file.c | 10 | ||||
-rw-r--r-- | gas/output-file.h | 2 |
4 files changed, 13 insertions, 15 deletions
@@ -111,9 +111,6 @@ int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON; bool flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES; #endif -/* Keep the output file. */ -static int keep_it = 0; - segT reg_section; segT expr_section; segT text_section; @@ -1155,14 +1152,6 @@ dump_statistics (void) #endif } -static void -close_output_file (void) -{ - output_file_close (out_file_name); - if (!keep_it) - unlink_if_ordinary (out_file_name); -} - /* The interface between the macro code and gas expression handling. */ static size_t @@ -1361,7 +1350,7 @@ main (int argc, char ** argv) expr_begin (); /* It has to be called after dump_statistics (). */ - xatexit (close_output_file); + xatexit (output_file_close); if (flag_print_statistics) xatexit (dump_statistics); @@ -340,6 +340,9 @@ COMMON int flag_noexecstack; /* name of emitted object file */ COMMON const char *out_file_name; +/* Keep the output file. */ +COMMON int keep_it; + /* name of file defining extensions to the basic instruction set */ COMMON char *insttbl_file_name; diff --git a/gas/output-file.c b/gas/output-file.c index 95e21d2..584deb2 100644 --- a/gas/output-file.c +++ b/gas/output-file.c @@ -64,12 +64,13 @@ stash_frchain_obs (asection *sec) } void -output_file_close (const char *filename) +output_file_close (void) { bool res; bfd *obfd = stdoutput; struct obstack **obs; asection *sec; + const char *filename; if (obfd == NULL) return; @@ -97,8 +98,13 @@ output_file_close (const char *filename) else res = bfd_close (obfd); + filename = out_file_name; + out_file_name = NULL; + if (!keep_it && filename) + unlink_if_ordinary (filename); + subsegs_end (obs); - if (! res) + if (!res) as_fatal ("%s: %s", filename, bfd_errmsg (bfd_get_error ())); } diff --git a/gas/output-file.h b/gas/output-file.h index 8e738df..3c65e25 100644 --- a/gas/output-file.h +++ b/gas/output-file.h @@ -19,7 +19,7 @@ the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ void output_file_append (char *where, long length, char *filename); -void output_file_close (const char *filename); +void output_file_close (void); void output_file_create (const char *name); /* end of output-file.h */ |