0

I am trying to find a way around compilers for some platforms that do not have much C++11 support, but use x86 assembly. I know assembly, but I have not done much with it. What I would like to do is write a C++ function, with a header, and source file, compile the header, and source to x86 assembly (no - dependencies, not even S.T.L) with GCC 4.8, and then use the assembly files in a program compiled with GCC 4.4 (maybe compile them to a static lib first with 4.4[?]). Is it possible to do this? I have been playing around with it for a few hours, but have not had many good results. Does anyone have any incite on this?

  • Take care of ABI incompatibilities. –  Nov 02 '13 at 18:15
  • @delnan Wouldn't, not using any dependencies take care of that if it is just pure standard C++? – The Floating Brain Nov 02 '13 at 18:16
  • Even something as simple as passing a POD struct as parameter can vary wildly between ABIs. I'm not sure whether there even are multiple ABIs involved in your specific case, but it's a concern as soon as you start mixing machine code from several different compiler (versions). –  Nov 02 '13 at 18:18
  • Of course it's possible, but you will need to specify the ISA/ABI you are using. A C++ function will most likely require a [name mangled](http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B) function name - some gory details [here](http://www.agner.org/optimize/calling_conventions.pdf). – Brett Hale Nov 02 '13 at 18:20
  • @delnan On that I am just crossing my fingers, the target would be from MinGW GCC to Google Native - Client. – The Floating Brain Nov 02 '13 at 18:22
  • @BrettHale Is there a way to specify that? – The Floating Brain Nov 02 '13 at 18:22
  • @TheFloatingBrain - your best bet is to look at the assembly generated for a C++ 'stub' function that does nothing, or does something trivial with the arguments, and adapt it to your requirements. – Brett Hale Nov 02 '13 at 18:29
  • @BrettHale I would do that however, the feature I want to use is varidic templates, and GCC 4.4 does not have them fully implemented. I am not sure if V.Ts will get along very well with a standard stub (again, I am no expert on x86 assembly, so I may just sound silly at the moment). – The Floating Brain Nov 02 '13 at 18:34

0 Answers0