NationalSecurityAgency/ghidra · error
Usage: %s target-str, arch, mach, disassembly base-addr (for
Error message
Usage: %s target-str, arch, mach, disassembly base-addr (for rel offsets instrs), full-path to Little and Big Elfs, big/little ascii-byte-string up to %d chars\n
What it means
GnuDisassembler (gdis) usage error. main() requires at least 8 argv elements: program name, target-str, arch, mach, disassembly base-addr, path to little-endian ELF, path to big-endian ELF, and an ascii hex byte-string. When argc < 8 it prints the Usage line to stderr, lists supported arch/mach targets and all BFD-known architectures, then continues (does not exit at this point).
Source
Thrown at GPL/GnuDisassembler/src/gdis/c/disasm_1.c:240
int main(int argc, char* argv[]){
struct disassemble_info DI;
enum bfd_architecture arch;
struct bfd_arch_info ai;
unsigned long mach;
enum bfd_endian endian;
unsigned int end;
bfd_vma offset;
disassembler_ftype disassemble_fn;
char *target = default_target;
bfd *bfdfile;
unsigned long a,m;
char* byteString;
char elf_file_location[MAX_ELF_FILE_PATH_LEN];
char arch_str[256];
char mach_str[256];
if ( argc < 8) {
fprintf(stderr, "Usage: %s target-str, arch, mach, disassembly base-addr (for rel offsets instrs), full-path to Little and Big Elfs, big/little ascii-byte-string up to %d chars\n", argv[0], MAX_ASCII_CHAR_BYTE_STRING);
listSupportedArchMachTargets();
const char** archList = bfd_arch_list();
const bfd_arch_info_type* ait;
while(*archList != NULL){
printf("checking against architecture: %s.\n", *archList);
ait = NULL;
ait = bfd_scan_arch(*archList);
if(ait != NULL){
printf("archname: %s arch: 0x%08X, mach: 0x%08lX.\n", ait->arch_name, ait->arch, ait->mach);
}
archList++;
}
return(1);
}
end = 0x00000000;
endian = (enum bfd_endian) 0x00;
mach = 0x00000000;View on GitHub (pinned to d5f144c24d)
Solutions
- Supply all 7 arguments in order: target arch mach base-addr little-elf big-elf bytestring.
- Run with no/insufficient args intentionally to dump the supported arch/mach list, then re-invoke correctly.
- Wrap the binary in a script that validates argc >= 8 before exec.
- Check the two ELF file paths exist and the byte-string is within MAX_ASCII_CHAR_BYTE_STRING.
Example fix
// before $ gdis i386:x86-64 // after (target arch mach base-addr little-elf big-elf bytes) $ gdis "i386:x86-64" "i386" "x86-64" 0x400000 ./prog.le ./prog.be 90909090
Defensive patterns
Strategy: validation
Validate before calling
if (argc < 8) {
fprintf(stderr, "gdis needs 7 args: target arch mach base-addr le-elf be-elf bytes\n");
return 2;
} Prevention
- Wrap gdis in a launcher that checks argc >= 8.
- Validate file paths and byte-string length before exec.
- Run with insufficient args once to capture the supported arch list.
When it happens
Trigger: Invoking the gdis binary with fewer than 7 user arguments (argc < 8). E.g. calling `gdis <target>` without arch, mach, base-addr, and both ELF paths.
Common situations: First-time use without reading the argument contract; a wrapper/IDE launcher dropping trailing arguments; missing the dual (little + big endian) ELF path requirement.
Related errors
- %s: unrecognized option `%c%s'\n
- %s: illegal option -- %c\n
- %s: invalid option -- %c\n
- %s: option requires an argument -- %c\n
- %s: option `-W %s' is ambiguous\n
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/4784d5eb0742059b.
Report an issue: GitHub.