kit

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

14_got_pic.c (354B)


      1 /* Exercises GOT-relative addressing relocs:
      2  *   R_AARCH64_ADR_GOT_PAGE  + R_AARCH64_LD64_GOT_LO12_NC
      3  *
      4  * `-fpic` forces externals to be addressed via the GOT (ADRP + LDR
      5  * loads the GOT entry, then a final LDR loads the value). */
      6 
      7 extern int g_int;
      8 extern char g_buf[];
      9 
     10 int read_g(void) { return g_int; }
     11 char read_buf(int i) { return g_buf[i]; }