crt_arch.h (1203B)
1 /* tcc-build riscv64 crt_arch.h replacement. 2 * 3 * Stock musl uses several things tcc 0.9.26's riscv64 assembler can't: 4 * 5 * 1. `.option push/norelax/pop` directives — tcc has no .option 6 * handling at all. We don't run linker relaxation, so dropping 7 * these is harmless. 8 * 9 * 2. `lla gp, __global_pointer$` — sets the global pointer for 10 * gp-relative addressing under linker relaxation. Without 11 * relaxation, no code uses gp; leaving it at process-entry value 12 * is fine for static-only boot4 binaries. 13 * 14 * 3. `tail _start_c` — the `tail` pseudo (auipc+jalr indirect) is 15 * not in tcc's mnemonic table. Replace with `jal zero, _start_c` 16 * which tcc accepts and which reaches any in-TU target (crt1.c 17 * defines _start_c in the same translation unit). 18 * 19 * 4. _DYNAMIC handling — boot4 only links static binaries, so 20 * _start_c's second argument is unused. Don't pass it. 21 * 22 * What's left is the minimum kernel-to-userland glue: pass sp to 23 * _start_c so it can read argc/argv/envp/auxv, then jump. 24 */ 25 __asm__( 26 ".text\n" 27 ".global " START "\n" 28 ".type " START ",%function\n" 29 START ":\n" 30 " mv a0, sp\n" 31 " jal zero, " START "_c\n" 32 );