]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: cater for changes in the way the kernel is linked
authorKris Van Hees <kris.van.hees@oracle.com>
Thu, 18 Oct 2012 15:56:46 +0000 (16:56 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jun 2015 21:41:38 +0000 (22:41 +0100)
3.6 started linking using a shell script, scripts/linux-vmlinux.sh, rather than
the old hair in the top-level Makefile. The SDT stub creation has to move in
there too.

Also, skip debugging sections explicitly when hunting for SDT probes in objdump
output.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
scripts/dtrace_sdt.sh
scripts/link-vmlinux.sh

index 11c3bf5efd5147d49e04e0fb8c1f72dd340774ee..8ec0aab7664310848bc222f1607e7dab00a95ae7 100755 (executable)
@@ -40,13 +40,12 @@ lfn="$2"
                 next;
             }
 
-            /__dtrace_probe_/ {
+            /__dtrace_probe_/ && sect !~ /debug/ {
                 $3 = substr($3, 16);
                 sub(/-.*$/, "", $3);
                 printf "%16s %s R %s %s\n", sect, $1, $3, sectbase[sect];
                 next;
             }' | \
-tee /tmp/sdt.log | \
        sort
     [ "x${lfn}" != "x" ] && nm ${lfn}
 ) | \
index 86a4fe75f453735936e3b218f885dcd887216659..5cc4baea072898050086908133ae42eb04fd0f5c 100755 (executable)
@@ -37,6 +37,39 @@ info()
        fi
 }
 
+# Generate the SDT probe point stubs object file
+# ${1} output file
+sdtstubs()
+{
+       info MKSTUBS ${1}
+       ${NM} -u ${KBUILD_VMLINUX_INIT} ${KBUILD_VMLINUX_MAIN} | \
+               grep __dtrace_probe_ | sort | uniq | \
+               ${AWK} '{
+                         printf("\t.globl %s\n\t.type %s,@function\n%s:\n",
+                                $2, $2, $2);
+                       }' > .tmp_sdtstubs.S
+       echo "  ret" >> .tmp_sdtstubs.S
+
+       local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL}               \
+                     ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
+
+       ${CC} ${aflags} -c -o ${1} .tmp_sdtstubs.S
+}
+
+# Generate the SDT probe info for object file ${1} and kernel image ${2}
+# ${3} output file
+sdtinfo()
+{
+       info DT-SDT ${3}
+
+       scripts/dtrace_sdt.sh ${1} ${2} > .tmp_sdtinfo.S
+
+       local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL}               \
+                     ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
+
+       ${CC} ${aflags} -c -o ${3} .tmp_sdtinfo.S
+}
+
 # Link of vmlinux.o used for section mismatch analysis
 # ${1} output file
 modpost_link()
@@ -117,6 +150,8 @@ cleanup()
        rm -f .old_version
        rm -f .tmp_System.map
        rm -f .tmp_kallsyms*
+       rm -f .tmp_sdtstubs.*
+       rm -f .tmp_sdtinfo.*
        rm -f .tmp_version
        rm -f .tmp_vmlinux*
        rm -f System.map
@@ -148,6 +183,14 @@ case "${KCONFIG_CONFIG}" in
        . "./${KCONFIG_CONFIG}"
 esac
 
+sdtstubso=""
+sdtinfoo=""
+if [ -n "${CONFIG_DTRACE}" ]; then
+       sdtstubso=.tmp_sdtstubs.o
+       sdtinfoo=.tmp_sdtinfo.o
+       sdtstubs ${sdtstubso}
+fi
+
 #link vmlinux.o
 info LD vmlinux.o
 modpost_link vmlinux.o
@@ -194,12 +237,20 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
        kallsymso=.tmp_kallsyms2.o
        kallsyms_vmlinux=.tmp_vmlinux2
 
+       if [ -n "${CONFIG_DTRACE}" ]; then
+               sdtinfo vmlinux.o "" ${sdtinfoo}
+       fi
+
        # step 1
-       vmlinux_link "" .tmp_vmlinux1
+       vmlinux_link "${sdtstubso} ${sdtinfoo}" .tmp_vmlinux1
        kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
 
+       if [ -n "${CONFIG_DTRACE}" ]; then
+               sdtinfo vmlinux.o .tmp_vmlinux1 ${sdtinfoo}
+       fi
+
        # step 2
-       vmlinux_link .tmp_kallsyms1.o .tmp_vmlinux2
+       vmlinux_link "${sdtstubso} .tmp_kallsyms1.o ${sdtinfoo}" .tmp_vmlinux2
        kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
 
        # step 2a
@@ -207,14 +258,14 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
                kallsymso=.tmp_kallsyms3.o
                kallsyms_vmlinux=.tmp_vmlinux3
 
-               vmlinux_link .tmp_kallsyms2.o .tmp_vmlinux3
+               vmlinux_link "${sdtstubso} .tmp_kallsyms2.o ${sdtinfoo}" .tmp_vmlinux3
 
                kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o
        fi
 fi
 
 info LD vmlinux
-vmlinux_link "${kallsymso}" vmlinux
+vmlinux_link "${sdtstubso} ${kallsymso} ${sdtinfoo}" vmlinux
 
 if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then
        info SORTEX vmlinux