NationalSecurityAgency/ghidra · error

Error: disassemble_fn is NULL. Nothing I can do.\n

Error message

Error: disassemble_fn is NULL. Nothing I can do.\n

What it means

gdis fatal error: after configureBfd() sets up the disassembler function pointer for the requested arch/mach/endian, disassemble_fn is still NULL, meaning BFD could not locate a disassembler for that combination. The program prints the message and calls exit(1).

Source

Thrown at GPL/GnuDisassembler/src/gdis/c/disasm_1.c:454

		//---------------------------------------

		/*
		  bfd_error_type err = bfd_get_error();
		  printf("bfd_error_msg: %s.\n", bfd_errmsg(err));
		 */

		/*if (disassemblerOptions[0] != '\0'){
		    DI.disassembler_options = disassemblerOptions;
		}*/
		configureBfd(bfdfile, arch, mach, endian, &DI, &disassemble_fn);

		/*
		  err = bfd_get_error();
		  printf("bfd_error_msg: %s.\n", bfd_errmsg(err));
		 */

		if (disassemble_fn == NULL){
			fprintf(stderr, "Error: disassemble_fn is NULL. Nothing I can do.\n");
			exit(1);
		}
		else{
			/*
			  printf("the disassemble_fn func pointer is: 0x%08X.\n", disassemble_fn);
			  printf("We can try to disassemble for this arch/mach. calling disassemble_init_for_target().\n");
			 */

			disassemble_init_for_target(&DI);
			if (disassemblerOptions[0] != '\0'){
				DI.disassembler_options = disassemblerOptions;
			}

			// go diassemble the buffer and build up the result in a accumulator string buffer.
			processBuffer(byteBuffer, size >> 1, offset, disassemble_fn, &DI); //

		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the arch/mach pair against the list printed by the Usage path (run with argc < 8) or bfd_arch_list().
  2. Correct typos in the arch/mach arguments (use canonical BFD names like 'i386:x86-64').
  3. Rebuild gdis against a full BFD configuration that includes the target (./configure --enable-targets=all).
  4. Try the alternate endian ELF path or a different mach for the same arch.

Example fix

// before
$ gdis "i386:x86-64" "i386" "bogus-mach" 0x400000 a.le a.be 9090
// configureBfd finds no disassembler -> NULL

// after
$ gdis "i386:x86-64" "i386" "x86-64" 0x400000 a.le a.be 9090
Defensive patterns

Strategy: validation

Validate before calling

// confirm BFD can produce a disassembler before relying on it
disassembler_ftype fn = disassembler(bfd_get_arch(bfd), bfd_big_endian(bfd), bfd_get_mach(bfd), bfd);
if (fn == NULL) { fprintf(stderr, "no disassembler for this arch/mach\n"); return 2; }

Prevention

When it happens

Trigger: Passing an arch/mach pair that BFD does not support with a disassembler, or an endian selection that has no disassembler backend, so disassembler() returns NULL via configureBfd.

Common situations: Typo in the arch or mach string; an arch that BFD knows but lacks a disassembler for; a gdis build with a stripped-down BFD that excluded the needed target; version mismatch where a target was removed/renamed.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/d67fad0f449a7b44. Report an issue: GitHub.