I have an executable file (or a .o
) generated by GCC from C source files. How can I show the calling convention for each function contained within the file, using objdump
or a similar tool?
Reason
When looking at the disassembly, I seem to have a function A()
which calls another function B(x, y)
by pushing y
and x
on the stack, but B(x, y)
looks for its parameters in registers.
I don't see any __cdecl
, __stdcall
or similar annotation on the C source code of B(x, y)
, and there don't see any C/C++ incompatibility weirdness, so I'd like to query the convention it's using from the actual .o
or executable file instead of guessing at random.
… interesting, good observation.
This reasoning is wrong. In your case,
B
must have been defined asstatic
; the optimization of loading parameters from registers is not done in functions with external linkage. And this explains why when calling a function in a separate.o
, GCC … generates the right code - it just doesn't perform that optimization then; thus it isn't necessary that GCC knows the convention from some information … contained in the.o
- which isn't there.