Skip to contentSkip to conversation

arm: LLVMLinux: Use __builtin_frame_address to get thread info

PATCH New [email protected] 1 participant 2 messages Sep 6, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: LLVMLinux: Use __builtin_frame_address to get thread info

From: Behan Webster <[email protected]>

The LLVMLinux Project is working to be able to build the Linux kernel with clang/LLVM. With the release of LLVM 3.3 clang is now able to compile the Linux kernel with a number of small patches (available from the LLVMLinux git repo).

Use the frame pointer to calculate the start of the stack for current_thread_info() The existing code uses the stack pointer to do this calculation.
Using the frame pointer yeilds the same value in a portable way.
This change supports being able to compile the kernel with gcc and Clang.

Behan Webster (1):
arm: LLVMLinux: Calculate current_thread_info from fp

 arch/arm/include/asm/thread_info.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 arm: LLVMLinux: Calculate current_thread_info from fp

From: Behan Webster <[email protected]>

Use the frame pointer to calculate the start of the stack for current_thread_info() The existing code uses the stack pointer to do this calculation.
Using the frame pointer yeilds the same value in a portable way.
This change supports being able to compile the kernel with gcc and Clang.

---
 arch/arm/include/asm/thread_info.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/include/asm/thread_info.h +3 -2
index df5e13d..cb50933 100644
@@ -106,8 +106,9 @@ static inline struct thread_info *current_thread_info(void) __attribute_const__;
 
 static inline struct thread_info *current_thread_info(void)
 {
-	register unsigned long sp asm ("sp");
-	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
+	return (struct thread_info *)
+		((u32)(__builtin_frame_address(0))
+		& ~(THREAD_SIZE - 1));
 }
 
 #define thread_saved_pc(tsk)	\
Signature · 1 line
1.8.1.2