rv64_symdiff_pair.s (933B)
1 // General symbol difference: neither symbol lives in the fixup's section, 2 // so `diff` (in .text) holding (m - s) — with `s` in .data and `m` in 3 // .rodata — lowers to an R_ADD64/R_SUB64 relocation pair the linker 4 // applies additively. RISC-V ELF carries these as R_RISCV_ADD64 / 5 // R_RISCV_SUB64, so the relocatable object round-trips (the same pair has 6 // no aarch64/x86-64 ELF wire encoding). test_main recomputes (m - s) from 7 // runtime addresses and returns 0 iff the linker-resolved value matches. 8 // No `.expected.hex`: the H lane skips and only the exec lanes run. 9 .text 10 .globl test_main 11 test_main: 12 lla a0, diff 13 ld a0, 0(a0) // linker-resolved (m - s) 14 lla a1, m 15 lla a2, s 16 sub a1, a1, a2 // runtime (m - s) 17 sub a0, a0, a1 18 snez a0, a0 // 0 iff equal 19 ret 20 diff: 21 .quad m - s 22 .data 23 .skip 3 24 s: 25 .byte 0 26 .section .rodata 27 .skip 5 28 m: 29 .byte 0