Search code examples
androidgccarmcalling-conventiontoolchain

How should __attribute__((pcs("aapcs"))) be used in HardFP ABI programs?


I have a HardFP ABI (very) simple test program. It links with other HardFP binaries without any problems. Now I wanted to use a function from a Softfp ABI library in my code, so I changed the header file (.h) from this library to add the attibute: __ attribute__((pcs("aapcs"))) on every function which uses double args (like: void doSomething(double arg, double arg2)), so I'm telling the toolchain that this library uses softfp ABI. The problem is that the toolchain (arm-linux-androideabi-4.9) is yelling me that:

/media/data_disk/b2g/work/hardfp/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld: error: /tmp/cc6SmP3D.o uses VFP register arguments, output does not /media/data_disk/b2g/work/hardfp/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld: error: /home/jgomez/b2g/build.flatfish.hardfp/out/target/product/flatfish/obj/lib/libc.so uses VFP register arguments, output does not /media/data_disk/b2g/work/hardfp/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld: error: /home/jgomez/b2g/build.flatfish.hardfp/out/target/product/flatfish/obj/lib/libstdc++.so uses VFP register arguments, output does not /media/data_disk/b2g/work/hardfp/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld: error: /home/jgomez/b2g/build.flatfish.hardfp/out/target/product/flatfish/obj/lib/libm.so uses VFP register arguments, output does not

(Of course, libc, libstdc++, and libm are hardfp too).

It doesn't compile.

So my question is, How does __attribute__((pcs("aapcs"))) should be used to let HardFP ABI programs link with Softfp ABI binaries?

I thought that this was the purpose of such a flag. Am I wrong?

Thanks!!


Solution

  • Ok, I already figured out the problem.

    As I thought, the attribute works as expected. The assembly code generated by the compiler (gcc) if I write the prefix: __attribute__((pcs("aapcs"))) in front of the function declaration, is using r registers to pass the argument values, so the callee, in Softfp mode, works perfect.

    I just needed to add this flag to the compiler options:

    --no-warn-mismatch