After spending some time on the previous question , the user introduced me to the email regarding the problem below:
[PATCH] ftrace / x86: Fix function graph tracer reset path
On my system, just turning the graphical tracer feature on and off is a kernel crash. I donโt know how it works so far.
ftrace_disable_ftrace_graph_caller() changes the jmp instruction to ftrace_graph_call , assuming it is 5 bytes around jmp (e9). However, this is a short jmp consisting of only 2 bytes (eb). And ftrace_stub() is located just below ftrace_graph_caller , so above it violates the instruction leading to ftrace_stub() with an invalid operation code, as shown below:
One solution to this problem is the following patch:
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S index ed48a9f465f8..e13a695c3084 100644 --- a/arch/x86/kernel/mcount_64.S +++ b/arch/x86/kernel/mcount_64.S @@ -182,7 +182,8 @@ GLOBAL(ftrace_graph_call) jmp ftrace_stub #endif -GLOBAL(ftrace_stub) + +WEAK(ftrace_stub) retq END(ftrace_caller)
via https://lkml.org/lkml/2016/5/16/493
I do not understand that the effect is to replace GLOBAL(ftrace_stub) with WEAK(ftrace_stub) . Neither the comment included in the patch, nor the view of GLOBAL () and WEAK () helped me understand why this solution works.
My question, as the name suggests, is this: What are the consequences of changing a symbol from .globl to .weak? I would appreciate an answer that takes into account how replacing GLOBAL(ftrace_stub) with WEAK(ftrace_stub) can solve this problem.
c assembly x86 linux linux-kernel
buratino
source share