glob_string_addr.c (713B)
1 /* glob: pass the address of a string literal to a noinline function. The .L 2 * string label is materialized with adrp/add into the arg register (the reloc 3 * is against the local .Lstr symbol, not a global), and the callee reads bytes 4 * through the pointer. sumlen walks until the NUL. The 6-char body sums to 42: 5 * '\1'+'\2'+'\3'+'\4'+'\5'+'\6' = 21, doubled by adding twice... actually we 6 * pick bytes summing to 42 directly. Exit: 42. */ 7 __attribute__((noinline)) static int sumbytes(const char* p) { 8 int s = 0; 9 while (*p) { 10 s += (unsigned char)*p; 11 ++p; 12 } 13 return s; 14 } 15 int test_main(void) { 16 /* bytes 0x0c + 0x0c + 0x0c + 0x06 = 42, none are NUL */ 17 return sumbytes("\x0c\x0c\x0c\x06"); 18 }