Commit 444758636439810f110f86a3042c2dfd3626a9e2

Authored by Steven Rostedt
Committed by Steven Rostedt
1 parent cf4db2597a

ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program

The file kernel/trace/ftrace.c references the mcount() call to
convert the mcount() callers to nops. But because it references
mcount(), the mcount() address is placed in the relocation table.

The C version of recordmcount reads the relocation table of all
object files, and it will add all references to mcount to the
__mcount_loc table that is used to find the places that call mcount()
and change the call to a nop. When recordmcount finds the mcount reference
in kernel/trace/ftrace.o, it saves that location even though the code
is not a call, but references mcount as data.

On boot up, when all calls are converted to nops, the code has a safety
check to determine what op code it is actually replacing before it
replaces it. If that op code at the address does not match, then
a warning is printed and the function tracer is disabled.

The reference to mcount in ftrace.c, causes this warning to trigger,
since the reference is not a call to mcount(). The ftrace.c file is
not compiled with the -pg flag, so no calls to mcount() should be
expected.

This patch simply makes recordmcount.c skip the kernel/trace/ftrace.c
file. This was the same solution used by the perl version of
recordmcount.

Reported-by: Ingo Molnar <mingo@elte.hu>
Cc: John Reiser <jreiser@bitwagon.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Showing 1 changed file with 20 additions and 2 deletions Side-by-side Diff

scripts/recordmcount.c
... ... @@ -313,12 +313,30 @@
313 313 int
314 314 main(int argc, char const *argv[])
315 315 {
  316 + const char ftrace[] = "kernel/trace/ftrace.o";
  317 + int ftrace_size = sizeof(ftrace) - 1;
316 318 int n_error = 0; /* gcc-4.3.0 false positive complaint */
317   - if (argc <= 1)
  319 +
  320 + if (argc <= 1) {
318 321 fprintf(stderr, "usage: recordmcount file.o...\n");
319   - else /* Process each file in turn, allowing deep failure. */
  322 + return 0;
  323 + }
  324 +
  325 + /* Process each file in turn, allowing deep failure. */
320 326 for (--argc, ++argv; 0 < argc; --argc, ++argv) {
321 327 int const sjval = setjmp(jmpenv);
  328 + int len;
  329 +
  330 + /*
  331 + * The file kernel/trace/ftrace.o references the mcount
  332 + * function but does not call it. Since ftrace.o should
  333 + * not be traced anyway, we just skip it.
  334 + */
  335 + len = strlen(argv[0]);
  336 + if (len >= ftrace_size &&
  337 + strcmp(argv[0] + (len - ftrace_size), ftrace) == 0)
  338 + continue;
  339 +
322 340 switch (sjval) {
323 341 default: {
324 342 fprintf(stderr, "internal error: %s\n", argv[0]);