0

I've read the parts "6 The Base Procedure Call Standard" and "7 The Standard Variants" of Procedure Call Standard for the Arm® Architecture aapcs32 - Github

The Base Procedure Call Standard specifies that r0-r3 in processor can be used to pass parameters. And the Standard Variants introduced in part 7 specifies s0-s15 in VFP-v2 co-processor can be used to do so. However, I cannot find aapcs specifying the reflection between arguments list in C and parameters passing registers. What else, the sequence for stacking arguments is unspecified.

So how can I know the implementation defined behaviour by arm-linux-gnueabihf-gcc?

Xshell
  • 33
  • 2
  • https://github.com/ARM-software/abi-aa/blob/2982a9f3b512a5bfdc9e3fea5d3b298f9165c36b/aapcs64/aapcs64.rst – 0___________ Jul 30 '23 at 13:19
  • The AAPCS is an extension of the APCS. If you can not find something in that section, assume it is the same for the 'Advanced' version. I had to read your question many times to try and discern what you are asking. Note: that options to `arm-linux-gnueabihf-gcc` can affect some register use. Such as `-msingle-pic-base` and possibly others (`-mabi=name`). – artless noise Aug 02 '23 at 19:28
  • A more difficult question with AAPCS is how to create the winding/unwinding information in assembler. With APCS, everything was dependant on the frame pointer. However, if you custom code assembler to inter-operate with GCC, you may need to add unwind information for applications with signals, etc. See: https://sourceware.org/binutils/docs-2.21/as/ARM-Directives.html – artless noise Aug 02 '23 at 19:33
  • `int foo(int a, int b, int c, int d)`. `a` is in R0, `b` is in R1, `c` is in R2, `d` is in R3. The URL you reference had all information, but that. If your question is something else, it is in the URL references. R4-R8 are consistent. Above R8, compiler/system options can affect register use. Mainly for shared libraries, PIC code, and other issues. – artless noise Aug 02 '23 at 19:41
  • This question may interest you. https://stackoverflow.com/questions/45359408/r12-in-the-arm-procedure-call-standard – artless noise Aug 02 '23 at 19:47
  • @artlessnoise Thanks a lot! That's very helpful! Maybe I didn't phase it very clearly because English is not my native language. The example `int foo(...)` you give is intuitive. But it may be a litttle bit more complex considering `int foo(float a,int b,int c,int d,long long e,double f)` with option `-mfloat-abi=hard`. I feel confused since I cannot find the mentions about a arguments list in C language mixed int and float data types in the document. – Xshell Aug 13 '23 at 13:25
  • You can look at the documentation or run an [example on godbolt](https://godbolt.org/z/7aK941Exa). We can see that 'b' is place in R0 and 'a' is in 's0'. So (for hard float-abi), the arguments are pass in s0.. and r0... and assigned by type. The 'gnueabihf' is as per [ARM float-abi](https://stackoverflow.com/questions/3321468/whats-the-difference-between-hard-and-soft-floating-point-numbers/29705738#29705738). – artless noise Aug 14 '23 at 17:01

0 Answers0