I found a way to hide some information from GCC using inline assembler: extern volatile const int *ip; __attribute__((const)) static inline volatile const int *get_ip_asm(void) { volatile const int *p; __asm__ ("ld [%1], %0" : "=r" (p) : "r" (&ip)); return p; } int a(void) { return ((int) &ip) & 0xfffffc00; } static inline int i_asm(void) { return *get_ip_asm(); } void f(void); void g_asm(void) { i_asm(); f(); i_asm(); } .file "test.c" .section ".text" .align 4 .global a .type a, #function .proc 04 a: sethi %hi(ip), %o0 or %o0, %lo(ip), %o0 jmp %o7+8 and %o0, -1024, %o0 .size a, .-a .align 4 .global g_asm .type g_asm, #function .proc 020 g_asm: save %sp, -96, %sp sethi %hi(ip), %i5 or %i5, %lo(ip), %i5 ! 7 "test.c" 1 ld [%i5], %i5 ! 0 "" 2 ld [%i5], %g1 call f, 0 nop ld [%i5], %g1 jmp %i7+8 restore .size g_asm, .-g_asm .ident "GCC: (GNU) 4.9.0 20140103 (experimental)" This is next to optimal. Unfortunately GCC doesn't optimize a() to a: sethi %hi(ip), %o0 jmp %o7+8 nop -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.huber@xxxxxxxxxxxxxxxxxx PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.