We found this problem when building a ppc64 Linux kernel. It turns out r30 was not preserved in a function that was using a local TOC. The compiler used was:
gcc version 4.0.3 20051201 (prerelease) (Debian 4.0.2-5) Although it seems to reproduce on older toolchains too (eg 3.4). pinskia cut the original test case down to: /* Compile with -m64 -O2 -mminimal-toc */ int per_cpu__kstat; int *f() { int *__ptr; asm volatile(";%0":"=g"(__ptr):"0"(&per_cpu__kstat)); return __ptr; } /* .f: ld 30,[EMAIL PROTECTED](2) ld 9,.LC0-.LCTOC1(30) mr 3,9 #APP ;3 #NO_APP */ -- Summary: ppc64 -mminimal-toc trashes r30 Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: anton at samba dot org GCC target triplet: powerpc64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25572