)]}'
{
  "commit": "8da3821ba5634497da63d58a69e24a97697c4a2b",
  "tree": "47d4d097b1cd2aafae2e3596a9ae0d1293228782",
  "parents": [
    "8b1fa1d7b22f386747c7b78b918d4c680c16066f"
  ],
  "author": {
    "name": "Steven Rostedt",
    "email": "rostedt@goodmis.org",
    "time": "Thu Aug 14 15:45:07 2008 -0400"
  },
  "committer": {
    "name": "Ingo Molnar",
    "email": "mingo@elte.hu",
    "time": "Tue Oct 14 10:34:40 2008 +0200"
  },
  "message": "ftrace: create __mcount_loc section\n\nThis patch creates a section in the kernel called \"__mcount_loc\".\nThis will hold a list of pointers to the mcount relocation for\neach call site of mcount.\n\nFor example:\n\nobjdump -dr init/main.o\n[...]\nDisassembly of section .text:\n\n0000000000000000 \u003cdo_one_initcall\u003e:\n   0:   55                      push   %rbp\n[...]\n000000000000017b \u003cinit_post\u003e:\n 17b:   55                      push   %rbp\n 17c:   48 89 e5                mov    %rsp,%rbp\n 17f:   53                      push   %rbx\n 180:   48 83 ec 08             sub    $0x8,%rsp\n 184:   e8 00 00 00 00          callq  189 \u003cinit_post+0xe\u003e\n                        185: R_X86_64_PC32      mcount+0xfffffffffffffffc\n[...]\n\nWe will add a section to point to each function call.\n\n   .section __mcount_loc,\"a\",@progbits\n[...]\n   .quad .text + 0x185\n[...]\n\nThe offset to of the mcount call site in init_post is an offset from\nthe start of the section, and not the start of the function init_post.\nThe mcount relocation is at the call site 0x185 from the start of the\n.text section.\n\n  .text + 0x185  \u003d\u003d init_post + 0xa\n\nWe need a way to add this __mcount_loc section in a way that we do not\nlose the relocations after final link.  The .text section here will\nbe attached to all other .text sections after final link and the\noffsets will be meaningless.  We need to keep track of where these\n.text sections are.\n\nTo do this, we use the start of the first function in the section.\ndo_one_initcall.  We can make a tmp.s file with this function as a reference\nto the start of the .text section.\n\n   .section __mcount_loc,\"a\",@progbits\n[...]\n   .quad do_one_initcall + 0x185\n[...]\n\nThen we can compile the tmp.s into a tmp.o\n\n  gcc -c tmp.s -o tmp.o\n\nAnd link it into back into main.o.\n\n  ld -r main.o tmp.o -o tmp_main.o\n  mv tmp_main.o main.o\n\nBut we have a problem.  What happens if the first function in a section\nis not exported, and is a static function. The linker will not let\nthe tmp.o use it.  This case exists in main.o as well.\n\nDisassembly of section .init.text:\n\n0000000000000000 \u003cset_reset_devices\u003e:\n   0:   55                      push   %rbp\n   1:   48 89 e5                mov    %rsp,%rbp\n   4:   e8 00 00 00 00          callq  9 \u003cset_reset_devices+0x9\u003e\n                        5: R_X86_64_PC32        mcount+0xfffffffffffffffc\n\nThe first function in .init.text is a static function.\n\n00000000000000a8 t __setup_set_reset_devices\n000000000000105f t __setup_str_set_reset_devices\n0000000000000000 t set_reset_devices\n\nThe lowercase \u0027t\u0027 means that set_reset_devices is local and is not exported.\nIf we simply try to link the tmp.o with the set_reset_devices we end\nup with two symbols: one local and one global.\n\n .section __mcount_loc,\"a\",@progbits\n .quad set_reset_devices + 0x10\n\n00000000000000a8 t __setup_set_reset_devices\n000000000000105f t __setup_str_set_reset_devices\n0000000000000000 t set_reset_devices\n                 U set_reset_devices\n\nWe still have an undefined reference to set_reset_devices, and if we try\nto compile the kernel, we will end up with an undefined reference to\nset_reset_devices, or even worst, it could be exported someplace else,\nand then we will have a reference to the wrong location.\n\nTo handle this case, we make an intermediate step using objcopy.\nWe convert set_reset_devices into a global exported symbol before linking\nit with tmp.o and set it back afterwards.\n\n00000000000000a8 t __setup_set_reset_devices\n000000000000105f t __setup_str_set_reset_devices\n0000000000000000 T set_reset_devices\n\n00000000000000a8 t __setup_set_reset_devices\n000000000000105f t __setup_str_set_reset_devices\n0000000000000000 T set_reset_devices\n\n00000000000000a8 t __setup_set_reset_devices\n000000000000105f t __setup_str_set_reset_devices\n0000000000000000 t set_reset_devices\n\nNow we have a section in main.o called __mcount_loc that we can place\nsomewhere in the kernel using vmlinux.ld.S and access it to convert\nall these locations that call mcount into nops before starting SMP\nand thus, eliminating the need to do this with kstop_machine.\n\nNote, A well documented perl script (scripts/recordmcount.pl) is used\nto do all this in one location.\n\nSigned-off-by: Steven Rostedt \u003csrostedt@redhat.com\u003e\nSigned-off-by: Ingo Molnar \u003cmingo@elte.hu\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3d8e472a09c824db071d3587eba1fd8863bc989c",
      "old_mode": 33188,
      "old_path": "include/asm-generic/vmlinux.lds.h",
      "new_id": "838d9b2a0da179cc63253fc3d9facb697bd1e2b4",
      "new_mode": 33188,
      "new_path": "include/asm-generic/vmlinux.lds.h"
    },
    {
      "type": "modify",
      "old_id": "cae2637d5e68eec46c93bf211702ce800743d3bc",
      "old_mode": 33188,
      "old_path": "kernel/trace/Kconfig",
      "new_id": "14d9505178caacf014a497793969676fff809fa7",
      "new_mode": 33188,
      "new_path": "kernel/trace/Kconfig"
    },
    {
      "type": "modify",
      "old_id": "277cfe0b71001e69bc67d3eda6407250d07d7ab8",
      "old_mode": 33188,
      "old_path": "scripts/Makefile.build",
      "new_id": "463ddcc583edb93caac0d0da2079e65fc9f5593f",
      "new_mode": 33188,
      "new_path": "scripts/Makefile.build"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "44b4b23e91b274101360a3e1cf402dae0ed62659",
      "new_mode": 33261,
      "new_path": "scripts/recordmcount.pl"
    }
  ]
}
