mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
tc: create helper to access toolchain tools
This commit is contained in:
@@ -924,8 +924,7 @@ so it is close to the failing `0xbf0000cc`.
|
|||||||
`readelf`:
|
`readelf`:
|
||||||
|
|
||||||
....
|
....
|
||||||
./out/x86_64/buildroot/host/usr/bin/x86_64-buildroot-linux-uclibc-readelf \
|
./runtc readelf -s ./out/x86_64/buildroot/build/kernel_module-1.0/hello.ko
|
||||||
-s ./out/x86_64/buildroot/build/kernel_module-1.0/hello.ko
|
|
||||||
....
|
....
|
||||||
|
|
||||||
does not give any interesting hits at `cc`, no symbol was placed that far.
|
does not give any interesting hits at `cc`, no symbol was placed that far.
|
||||||
@@ -998,7 +997,7 @@ The base address shows on terminal:
|
|||||||
Now let's find the offset of `myinit`:
|
Now let's find the offset of `myinit`:
|
||||||
|
|
||||||
....
|
....
|
||||||
./out/x86_64/buildroot/host/usr/bin/x86_64-buildroot-linux-uclibc-readelf \
|
./runtc readelf \
|
||||||
-s ./out/x86_64/buildroot/build/kernel_module-1.0/fops.ko | \
|
-s ./out/x86_64/buildroot/build/kernel_module-1.0/fops.ko | \
|
||||||
grep myinit
|
grep myinit
|
||||||
....
|
....
|
||||||
@@ -1295,7 +1294,7 @@ Cannot access memory at address 0x10604
|
|||||||
We have also double checked the address with:
|
We have also double checked the address with:
|
||||||
|
|
||||||
....
|
....
|
||||||
./out/arm/buildroot/host/bin/arm-buildroot-linux-uclibcgnueabi-readelf-s \
|
./runtc -a arm readelf \
|
||||||
./out/arm/buildroot/build/kernel_module-1.0/user/hello.out | \
|
./out/arm/buildroot/build/kernel_module-1.0/user/hello.out | \
|
||||||
grep main
|
grep main
|
||||||
....
|
....
|
||||||
@@ -2737,7 +2736,7 @@ Notes:
|
|||||||
It can be found from:
|
It can be found from:
|
||||||
+
|
+
|
||||||
....
|
....
|
||||||
readelf -e out/x86_64/buildroot/build/linux-*/vmlinux | grep Entry
|
./runtc readelf -e out/x86_64/buildroot/build/linux-*/vmlinux | grep Entry
|
||||||
....
|
....
|
||||||
+
|
+
|
||||||
TODO confirm further. If I try to break there with:
|
TODO confirm further. If I try to break there with:
|
||||||
|
|||||||
1
build
1
build
@@ -9,7 +9,6 @@ touch "$br2_cli_file"
|
|||||||
configure=true
|
configure=true
|
||||||
config_fragments="${root_dir}/br2"
|
config_fragments="${root_dir}/br2"
|
||||||
extra_make_args=
|
extra_make_args=
|
||||||
gem5=false
|
|
||||||
j="$(nproc)"
|
j="$(nproc)"
|
||||||
linux_reconfigure=false
|
linux_reconfigure=false
|
||||||
linux_kernel_custom_config_file=
|
linux_kernel_custom_config_file=
|
||||||
|
|||||||
1
common
1
common
@@ -49,3 +49,4 @@ if [ -f "$f" ]; then
|
|||||||
fi
|
fi
|
||||||
# Default arch.
|
# Default arch.
|
||||||
arch=x86_64
|
arch=x86_64
|
||||||
|
gem5=false
|
||||||
|
|||||||
1
run
1
run
@@ -18,7 +18,6 @@ extra_append='console_msg_format=syslog nokaslr norandmaps printk.devkmsg=on pri
|
|||||||
extra_append_after_dash=
|
extra_append_after_dash=
|
||||||
extra_flags=
|
extra_flags=
|
||||||
extra_flags_qemu=
|
extra_flags_qemu=
|
||||||
gem5=false
|
|
||||||
gem5opts=
|
gem5opts=
|
||||||
lkmc_eval=
|
lkmc_eval=
|
||||||
initrd=false
|
initrd=false
|
||||||
|
|||||||
1
rungdb
1
rungdb
@@ -4,7 +4,6 @@ set -eu
|
|||||||
set -- ${cli_rungdb:-} "$@"
|
set -- ${cli_rungdb:-} "$@"
|
||||||
after=
|
after=
|
||||||
before=
|
before=
|
||||||
gem5=false
|
|
||||||
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\
|
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\
|
||||||
"
|
"
|
||||||
kgdb=false
|
kgdb=false
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ set -eu
|
|||||||
. common
|
. common
|
||||||
set -- ${cli_rungdb_user:-} "$@"
|
set -- ${cli_rungdb_user:-} "$@"
|
||||||
usage="$0 <exec-relative-path> [<brk-symbol>]"
|
usage="$0 <exec-relative-path> [<brk-symbol>]"
|
||||||
gem5=false
|
|
||||||
gem5_opt=
|
gem5_opt=
|
||||||
while getopts a:gh OPT; do
|
while getopts a:gh OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
@@ -34,8 +33,7 @@ else
|
|||||||
fi
|
fi
|
||||||
set_common_vars "$arch" "$gem5"
|
set_common_vars "$arch" "$gem5"
|
||||||
executable="${build_dir}/${executable_rel}"
|
executable="${build_dir}/${executable_rel}"
|
||||||
readelf="${host_dir}/usr/bin/${arch}-linux-readelf"
|
addr="$("${root_dir}/runtc" readelf -h "$executable" | awk '/Entry/{ print $NF }' )"
|
||||||
addr="$("$readelf" -h "$executable" | awk '/Entry/{ print $NF }' )"
|
|
||||||
ex="-ex \"add-symbol-file $executable $addr\""
|
ex="-ex \"add-symbol-file $executable $addr\""
|
||||||
# -L or else lx-symbols throws for arm:
|
# -L or else lx-symbols throws for arm:
|
||||||
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc
|
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
set -eu
|
set -eu
|
||||||
. common
|
. common
|
||||||
set -- ${cli_rungdbserver:-} "$@"
|
set -- ${cli_rungdbserver:-} "$@"
|
||||||
gem5=false
|
|
||||||
while getopts a:g OPT; do
|
while getopts a:g OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
|
|||||||
28
runtc
Executable file
28
runtc
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eu
|
||||||
|
. common
|
||||||
|
set -- ${cli_tc:-} "$@"
|
||||||
|
while getopts a:gh OPT; do
|
||||||
|
case "$OPT" in
|
||||||
|
a)
|
||||||
|
arch="$OPTARG"
|
||||||
|
;;
|
||||||
|
g)
|
||||||
|
gem5=true
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
printf "Usage: $0 TOOL [TOOL_ARGS]...
|
||||||
|
Call a built ToolChain tool. Example:
|
||||||
|
|
||||||
|
$0 -a arm readelf -h
|
||||||
|
" 2>&1
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift "$(($OPTIND - 1))"
|
||||||
|
tool="$1"
|
||||||
|
shift
|
||||||
|
set_common_vars "$arch" "$gem5"
|
||||||
|
"${buildroot_out_dir}/host/bin/"*-buildroot-*"${tool}" "$@"
|
||||||
|
exit "$?"
|
||||||
@@ -17,7 +17,7 @@ time ./qemu-trace2txt -a "$arch"
|
|||||||
# We could put this on a separate script, but it just adds more arch boilerplate to a new script.
|
# We could put this on a separate script, but it just adds more arch boilerplate to a new script.
|
||||||
# So let's just leave it here for now since it did not add a significant processing time.
|
# So let's just leave it here for now since it did not add a significant processing time.
|
||||||
echo "instructions $(wc -l "${qemu_trace_txt_file}" | cut -d' ' -f1)"
|
echo "instructions $(wc -l "${qemu_trace_txt_file}" | cut -d' ' -f1)"
|
||||||
entry_addr=$("${host_dir}"/bin/*-buildroot-*-readelf -h "${build_dir}/linux-custom/vmlinux" | grep 'Entry point address' | sed -E 's/.*: *//')
|
entry_addr=$("${root_dir}/runtc" readelf -h "${build_dir}/linux-custom/vmlinux" | grep 'Entry point address' | sed -E 's/.*: *//')
|
||||||
echo "entry_address ${entry_addr}"
|
echo "entry_address ${entry_addr}"
|
||||||
sed "/${entry_addr}/q" "${qemu_trace_txt_file}" >"${qemu_out_dir}/trace-boot.txt"
|
sed "/${entry_addr}/q" "${qemu_trace_txt_file}" >"${qemu_out_dir}/trace-boot.txt"
|
||||||
echo "instructions_firmware $(wc -l "${qemu_out_dir}/trace-boot.txt" | cut -d' ' -f1)"
|
echo "instructions_firmware $(wc -l "${qemu_out_dir}/trace-boot.txt" | cut -d' ' -f1)"
|
||||||
|
|||||||
Reference in New Issue
Block a user