From db7354e3d31cd9052c0d8dd0b961c862fbb2e889 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 11 Jan 2023 20:22:31 +1030 Subject: [PATCH] Update binutils/fuzz_as initialisation (#9400) Upstream gas has changed, resulting in issues like https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48997 --- projects/binutils/fuzz_as.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/projects/binutils/fuzz_as.c b/projects/binutils/fuzz_as.c index 9cd4eb0d5..dea6d9d98 100644 --- a/projects/binutils/fuzz_as.c +++ b/projects/binutils/fuzz_as.c @@ -31,13 +31,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { reg_section = NULL; const char *fakeArgv[3]; - fakeArgv[0] = "fuzz_objdump"; + fakeArgv[0] = "fuzz_as"; fakeArgv[1] = filename; // Assemble our fake source file. fakeArgv[2] = NULL; out_file_name = "/tmp/tmp-out"; // as initialition. This follows the flow of ordinary main function + hex_init (); + if (bfd_init () != BFD_INIT_MAGIC) + abort (); + obstack_begin (¬es, chunksize); symbol_begin (); frag_init (); subsegs_begin (); @@ -47,21 +51,25 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { macro_init (flag_macro_alternate, flag_mri, 0, macro_expr); output_file_create (out_file_name); + dot_symbol_init (); itbl_init (); dwarf2_init (); - cond_finish_check (-1); - - dot_symbol_init (); + local_symbol_make (".gasversion.", absolute_section, + &predefined_address_frag, BFD_VERSION / 10000UL); // Main fuzzer target. Assemble our random data. perform_an_assembly_pass (2, (char**)fakeArgv); // Cleanup cond_finish_check (-1); + codeview_finish (); dwarf2_finish (); cfi_finish (); input_scrub_end (); + keep_it = 0; + output_file_close (); + free_notes (); unlink(filename); return 0;