Re: back online again...



"cr88192" <cr88192@xxxxxxxxxxx> wrote in message
news:gjvrcb$b2h$1@xxxxxxxxxxxxxxxxxxxxx
"Rod Pemberton" <do_not_have@xxxxxxxxxxxxx> wrote in message
news:gjvggt$4g8$1@xxxxxxxxxxxxxxxxxxxxx
"cr88192" <cr88192@xxxxxxxxxxx> wrote in message
news:gjv0a2$qbc$1@xxxxxxxxxxxxxxxxxxxxx

I am using tornevall...


So am I... Thank you for pointing out tornevall to me. :)

I've been considering just using left-to-right. How often do I use
varargs?
Never... Varargs are the key reason for right-to-left order, rigth?
And,
varargs must be indicated by ellipsis, "...", yes? How often does one
see
ellipsis in C code? Never... I'd also like to free up ebp for use.

printf uses varargs...

Yes, you're correct, sigh... I'd probably make printf() take exactly ten
arguments. I'd then have the compiler automatically fill in "dummy"
arguments if printf() had less than ten. Etc., until, of if I ever chose to
fix it. :)

Back to your earlier post:

then interface with external C
code via special autogenerated attachment thunks.
...
and so then, dynamically compiled code uses this convention as if it were
the native convention...

Basically, a custom prolog and epilog or wrapper function for calling SysV
from Win64 or whatever. Yes?

the question is than what happens if a function is called that does not
exist?

At the assembler level instead of C level, if the function call doesn't
exist, there won't be a "_XC_foo_4dd_5d" label, so the assembler should warn
about the missing label when "call _XC_foo_4dd_5d" is assembled. (OK, I
know that's not what you were talking about...)

well, the idea could be that the linker could detect this case,

Oh, if it's an external function, then the linker will notice it can't be
linked with if it's missing. The linker will detect the external function
is missing, but at that point, isn't it a bit late to be trying to patch up
the internal code so it can call the external code? I'd think you'd want
your compiler to insert "dummy" or wrapper functions for missing or external
functions which are then used to generate your "special autogenerated
attachment thunks" and call the external function.

linker ... automatically generate a stub to allow calling the
native function using the native convention

AH! You want a method to select between the "custom calling convention" for
internal C functions and the SysV calling convention for external C
functions. And, you're trying to determine a method to know which is which
so the arguments and returns are properly setup for a different calling
convention when linked. Okay, your second post makes sense now... :)
Interesting... IIRC, I worked on a system where they needed to place
wrappers around a larger number of OS system functions. What they did was
have the compiler captilize the names of the system functions. They were
all external. Then, the linker linked to the wrapper library function if
the function name was uppercase instead of the original OS library
functions, which it'd link to if it was lowercase. The wrapper did some
stuff, called the original function, did some more stuff, then exited, much
like a prolog and epilog.


Rod Pemberton


.



Relevant Pages

  • Re: debug error
    ... > convention with a function pointer declared with a different calling ... called the 'calling convention' of a function. ... specify with prefixes to your function declarations or compiler settings. ... If you call one function with the compiler believing it was convention X ...
    (comp.lang.c)
  • Re: "C" calling convention on x86
    ... > convention does not depend on what compiler or mode. ... > which is almost identical to the C calling convention. ... ISO 7185 Standard Pascal web site: http://www.moorecad.com/standardpascal ...
    (comp.lang.asm.x86)
  • Re: x86-64 and calling conventions
    ... and there is no particular relation between the registers and the ... but is in the process of writing a compiler in Ruby (currently ... to the calling convention and just hiding them to the users of your ... wrapper. ...
    (comp.compilers)
  • Re: printf doubt
    ... At least one popular compiler does not. ... The __stdcall calling convention is used to call Win32 API functions. ...
    (comp.lang.c)
  • Re: printf doubt
    ... At least one popular compiler does not. ... The __stdcall calling convention is used to call Win32 API functions. ...
    (comp.lang.c)