I am using gcc's extended asm to invoke a system call. I am working on a proprietary RTOS on a PowerPC (Freescale MPC5200B).
According to gcc's documentation I should add all registers that the assembly code uses - and that are neither input nor output - to the clobbers list, because gcc does not analyse the assembly code and thus does not know which registers are being altered.
The problem is that I don't know which registers the system call alters. In fact I'm observing a case where the system call alters a register holding a pointer. After the system call has returned, the pointer in the register is being used, which leads to an invalid memory access.
How should I deal with this situation?
For future readers:
The general answer is that you can find the registers altered by a system call in the documentation of the system's ABI.
For my system (Freescale MPC5200B) I found the answer is the IBM Application Note 'Developing PowerPC Embedded Application Binary Interface (EABI) Compliant Programs'.
So I added the registers marked volatile (namely R3..R12, F0..F13 and the flags register) to the clobbers list.