aa64_symdiff_reloc.s (969B)
1 // Cross-section symbol difference resolved at link time. `diff` holds 2 // (m - s): the subtrahend `s` is local to .text (the fixup's own section) 3 // while the minuend `m` lives in .data, so the difference cannot be a 4 // pure assembly-time constant and lowers to a PC-relative relocation 5 // against `m`. test_main recomputes (m - s) from the runtime addresses 6 // and returns 0 iff the linker-resolved value stored in `diff` matches — 7 // a self-check that needs no fixed section layout. No `.expected.hex` 8 // golden: the H lane skips and only the exec lanes (D/J/E) run. 9 .text 10 .globl test_main 11 test_main: 12 adrp x0, diff 13 add x0, x0, :lo12:diff 14 ldr x0, [x0] // linker-resolved (m - s) 15 adrp x1, m 16 add x1, x1, :lo12:m 17 adrp x2, s 18 add x2, x2, :lo12:s 19 sub x1, x1, x2 // runtime (m - s) 20 subs x0, x0, x1 21 cset w0, ne // 0 iff equal 22 ret 23 s: 24 diff: 25 .quad m - s 26 .data 27 .skip 7 28 m: 29 .byte 0