kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

aa64_symdiff_pair.s (1229B)


      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 applies
      4 // additively. test_main recomputes (m - s) from runtime addresses and
      5 // returns 0 iff the linker-resolved value matches.
      6 //
      7 // Runs the in-process D lane only: aarch64 ELF has no wire encoding for the
      8 // R_ADD64/R_SUB64 pair (a cross-section difference is not representable in a
      9 // relocatable aarch64 object — the same limitation GNU as has), so the
     10 // --emit-based J/E lanes are skipped. The pair *is* applied correctly when
     11 // consumed by kit's own linker (D here; a final `kit build-exe` link too),
     12 // and round-trips on RISC-V ELF — see rv64_symdiff_pair.
     13 .text
     14 .globl test_main
     15 test_main:
     16     adrp x0, diff
     17     add  x0, x0, :lo12:diff
     18     ldr  x0, [x0]            // linker-resolved (m - s)
     19     adrp x1, m
     20     add  x1, x1, :lo12:m
     21     adrp x2, s
     22     add  x2, x2, :lo12:s
     23     sub  x1, x1, x2          // runtime (m - s)
     24     subs x0, x0, x1
     25     cset w0, ne              // 0 iff equal
     26     ret
     27 diff:
     28     .quad m - s
     29 .data
     30     .skip 3
     31 s:
     32     .byte 0
     33 .section .rodata
     34     .skip 5
     35 m:
     36     .byte 0