• Willy Tarreau's avatar
    tools/nolibc: support thumb mode with frame pointers on ARM · 5a51b6de
    Willy Tarreau authored
    In Thumb mode, register r7 is normally used to store the frame pointer.
    By default when optimizing at -Os there's no frame pointer so this works
    fine. But if no optimization is set, then build errors occur, indicating
    that r7 cannot not be used. It's difficult to cheat because it's the
    compiler that is complaining, not the assembler, so it's not even possible
    to report that the register was clobbered. The solution consists in saving
    and restoring r7 around the syscall, but this slightly inflates the code.
    The syscall number is passed via r6 which is never used by syscalls.
    
    The current patch adds a few macroes which do that only in Thumb mode,
    and which continue to directly assign the syscall number to register r7
    in ARM mode. Now this always builds and works for all modes (tested on
    Arm, Thumbv1, Thumbv2 modes, at -Os, -O0, -O0 -fomit-frame-pointer).
    The code is very slightly inflated in thumb-mode without frame-pointers
    compared to previously (e.g. 7928 vs 7864 bytes for nolibc-test) but at
    least it's always operational. And it's possible to disable this mechanism
    by setting NOLIBC_OMIT_FRAME_POINTER.
    Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    5a51b6de
arch-arm.h 11 KB