Skip to content

Commit dff38e3

Browse files
Andi KleenH. Peter Anvin
authored andcommitted
x86: Use inline assembler instead of global register variable to get sp
LTO in gcc 4.6/47. has trouble with global register variables. They were used to read the stack pointer. Use a simple inline assembler statement with a mov instead. This also helps LLVM/clang, which does not support global register variables. [ hpa: Ideally this should become a builtin in both gcc and clang. ] v2: More general asm constraint. Fix description (Jan Beulich) Signed-off-by: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/1382458079-24450-6-git-send-email-andi@firstfloor.org Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
1 parent a2e7f0e commit dff38e3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎arch/x86/include/asm/thread_info.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ struct thread_info {
163163
*/
164164
#ifndef __ASSEMBLY__
165165

166-
167-
/* how to get the current stack pointer from C */
168-
register unsigned long current_stack_pointer asm("esp") __used;
166+
#define current_stack_pointer ({ \
167+
unsigned long sp; \
168+
asm("mov %%esp,%0" : "=g" (sp)); \
169+
sp; \
170+
})
169171

170172
/* how to get the thread information struct from C */
171173
static inline struct thread_info *current_thread_info(void)

0 commit comments

Comments
 (0)