arm: LLVMLinux: Use __builtin_frame_address instead of named registers
Subsystems (2)
PATCH 1/1 arm: LLVMLinux: Use __builtin_frame_address instead of named registers
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 end of the stack for current_pt_regs() The existing code uses the stack pointer to do this calculation. Using the frame pointer yeilds the same value in a more portable way. This change supports being able to compile the kernel with gcc and clang.
Behan Webster (1):
arm: LLVMLinux: Calculate pt_regs address from fp
arch/arm/include/asm/ptrace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.1.2
PATCH 1/1 arm: LLVMLinux: Calculate pt_regs address from fp
From: Behan Webster <[email protected]>
Use the frame pointer to calculate the end of the stack for current_pt_regs() The existing code uses the stack pointer to do this calculation. Using the frame pointer yeilds the same value in a more portable way. This change supports being able to compile the kernel with gcc and clang.
--- arch/arm/include/asm/ptrace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/ptrace.h +3 -3
@@ -138,9 +138,9 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs) return regs->ARM_sp; } -#define current_pt_regs (void) ({ \ - register unsigned long sp asm ("sp"); \ - (struct pt_regs *)((sp | (THREAD_SIZE - 1)) - 7) - 1; \ +#define current_pt_regs (void) ({ \ + (struct pt_regs *)(((unsigned long)(__builtin_frame_address(0)) \ + | (THREAD_SIZE - 1)) - 7) - 1; \ })#endif /* __ASSEMBLY__ */
Signature · 1 line
1.8.1.2
Re: [PATCH] arm: LLVMLinux: Calculate pt_regs address from fp
Quoted 6 lines · behanw at converseincode.com
From: Behan Webster <[email protected]>
Use the frame pointer to calculate the end of the stack for
current_pt_regs()The existing code uses the stack pointer to do this calculation. Using the frame pointer yeilds the same value in a more portable way. This change supports being able to compile the kernel with gcc and clang.
What happens when frame pointers are disabled on gcc?
PATCH 1/1 arm: LLVMLinux: Calculate pt_regs address from fp
Quoted 8 lines · Russell King - ARM Linux
Quoted 6 lines · behanw at converseincode.com
From: Behan Webster <[email protected]>
Use the frame pointer to calculate the end of the stack for
current_pt_regs()The existing code uses the stack pointer to do this calculation. Using the frame pointer yeilds the same value in a more portable way. This change supports being able to compile the kernel with gcc and clang.What happens when frame pointers are disabled on gcc?
Drat. Good point. Didn't think of that.
Could be rewritten to use current_stack_pointer (assuming the patch series that implements that would be amenable).
Thanks,
Behan
Signature · 2 lines
Behan Webster behanw at converseincode.com