]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix RELOC_HIDE miscompilation
authorAndi Kleen <ak@muc.de>
Tue, 3 Sep 2002 12:43:59 +0000 (05:43 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Tue, 3 Sep 2002 12:43:59 +0000 (05:43 -0700)
RELOC_HIDE got miscompiled on gcc3.1/x86-64 in the access to softirq.c's per
cpu variables.  This fixes the problem.

Clearly to hide the relocation the addition needs to be done after the
value obfuscation, not before.

I don't know if it triggers on other architectures (x86-64 is especially
stressf here because it has negative kernel addresses), but seems like the
right thing to do.

include/linux/compiler.h

index eea3d3636e2afae2058ef6853d1c33beeb454cc9..6b19413b47a6e16e966f641640bbf45dc9e36c07 100644 (file)
@@ -16,7 +16,7 @@
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)                                   \
-  ({ __typeof__(ptr) __ptr;                                    \
-    __asm__ ("" : "=g"(__ptr) : "0"((void *)(ptr) + (off)));   \
-    __ptr; })
+  ({ unsigned long __ptr;                                      \
+    __asm__ ("" : "=g"(__ptr) : "0"(ptr));             \
+    (typeof(ptr)) (__ptr + (off)); })
 #endif /* __LINUX_COMPILER_H */