Skip to content

variadic functions broken on aarch64 #8032

Open
@alexdevsec

Description

@alexdevsec

[Describe the bug

When I decompile a call to a variadic function, it references the wrong registers.

To Reproduce
Steps to reproduce the behavior:

  1. Use this program:
#include <stdio.h>
#include <stdarg.h>

int main(int argc, char ** argv)
{

    printf("foo %d bar %s\n",1234,"quux");
    return 0;
}
  1. Compile:
    $ gcc main.c -o test-vargs

  2. In Ghidra, import file and do default analysis

  3. Edit entry function to look like main() should:

int entry(int param_1,char **param_2)

  1. See call to _printf contains reference to param_1 (which is register x1) and in_x2.

Expected behavior

I'd expect it to get the functions to

_fprintf() is properly labelled as a variadic function.

Using the _cdecl calling convention, it seems to be expecting args in x1 and x2, but entry() has them set up in x8 and x9.

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Image

Attachments
If applicable, please attach any files that caused problems or log files generated by the software.

Environment (please complete the following information):

  • OS: macOS Sequoia 15.3.2
  • Java Version: 23.0.1
  • Ghidra Version: 11.3.1
  • Ghidra Origin: official GitHub distro

Additional context
Maybe I need a different calling convention for aarch64? I'd expect cdecl to do this properly.

Metadata

Metadata

Assignees

Labels

Status: InternalThis is being tracked internally by the Ghidra team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions