kit

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

glob_rw.c (619B)


      1 /* glob: read AND write a file-scope global int. The write forces an adrp/str
      2  * pair (ADR_PREL_PG_HI21 + LDST32_ABS_LO12_NC against `g`) in addition to the
      3  * load, so both the symbolic store and load round-trip. A volatile local
      4  * defeats folding the final value to a constant. `g` is initialized nonzero so
      5  * it lands in .data (a zero-init global would land in .bss, which the
      6  * assembler currently mis-emits as SHT_PROGBITS — see glob_bss_write.skip).
      7  * Exit: g becomes 42. */
      8 int g = 1;
      9 int test_main(void) {
     10   volatile int v = 42;
     11   g = v;    /* adrp/str against g */
     12   return g; /* adrp/ldr against g */
     13 }