Pregunta

IDA (the interactive disassembler by hex-rays.com) reports native C++ functions (Android NDK, arm) as __fastcall, for example:

// int __fastcall QVariant::toULongLong(_DWORD, _DWORD); weak

By the way, this function is declared in the docs as

qulonglong QVariant::toULongLong ( bool * ok = 0 ) const

When I define a native function with __attribute__((fastcall)), I get

warning: 'fastcall' attribute directive ignored [-Wattributes]

Question: I need to call a library function whose prototype I can (hopefully) guess. How do I declare functions so that they would be called with the right calling convention (namely, the __fastcall one reported by IDA)?

¿Fue útil?

Solución

IDA just uses fastcall for any calling convention involving registers. In the case of ARM, fastcall basically means "default calling convention".

Adding #define __fastcall to the source should let you compile it. However, there is an additional issue for this function:

Note that QVariant::toULongLong() is a C++ method, so the first argument shown by the decompiler is actually the hidden this pointer which is passed to all non-static methods of C++ classes. Since the decompiler does not support C++ it converts it to an explicit argument. You may need to undo this operation to make it valid C++ code.

Or you could just use the actual source code.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top