Hello all,
The x86-64 ABI conventions on Linux says that a
function returning two word-values -e.g two pointers- have them passed
in two processor registers.
You can check by compiling the below C function with optimizations (and GCC 14):
#include <stdint.h>
struct twost {
void*x;
intptr_t y;
};
struct twost f(void*xx, intptr_t yy) {
struct twost r;
r.x = xx;
r.y = yy;
return r;
}
which is compiled by gcc-14 -O2 -fverbose-asm -S test2.c into:
.file "test2.c"
# GNU C17 (Debian 14.2.0-3) version 14.2.0 (x86_64-linux-gnu)
# compiled by GNU C version 14.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.27-GMP
# GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
# options passed: -mtune=generic -march=x86-64 -O2 -fasynchronous-unwind-tables
.text
.p2align 4
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
# test2.c:12: return r;
movq %rdi, %rax # tmp103, D.2870
movq %rsi, %rdx # tmp104, D.2870
# test2.c:13: }
ret
.cfi_endproc
.LFE0:
.size f, .-f
.ident "GCC: (Debian 14.2.0-3) 14.2.0"
.section .note.GNU-stack,"",@progbits
Observe that no stack allocated memory is returned.
My question is then how to generate the above function n GNU lightning without using stack allocated data?
Regards.
--
Basile STARYNKEVITCH
8 rue de la Faïencerie
92340 Bourg-la-Reine
France