shecc icon indicating copy to clipboard operation
shecc copied to clipboard

Support the `long` specifier and ensure ABI compliance

Open DrXiao opened this issue 2 months ago • 0 comments

Description

The current parser cannot recognize the long specifier, so shecc cannot handle related types such as long, long long, long long int.

Therefore, this issue is created to track the long specifier implementation.

Target

  • long / long int (32-bit or 64-bit)
  • long long / long long int (at least 64-bit)
  • Combined with unsigned modifier
  • Ensure the ABI compliance when using the relevant types.

For example:

#include <stdio.h>
int test_ll(int a, int b, int c, int d, long long e) {
    return (e == 1000LL) ? 0 : 1;
}

int main() {
    if (test_ll(1, 2, 3, 4, 1000LL) == 0) {
        printf("PASS\n");
        return 0;
    }
    printf("FAIL: long long corrupted\n");
    return 1;
}

Under the Arm Architecture, it is required to ensure that the stack is 8-byte aligned when calling a function that has 8 byte object(s) on the stack. Besides, when passing 8 byte object(s) to registers, the use of registers should also comply with the ABI requirements.

When targeting the RISC-V architecture, the corresponding ABI compliance should also be ensured.

DrXiao avatar Nov 09 '25 12:11 DrXiao