tc: create helper to access toolchain tools

This commit is contained in:
Ciro Santilli
2018-04-19 08:01:01 +01:00
parent 3fdabbda61
commit 9805d333ea
9 changed files with 35 additions and 13 deletions

View File

@@ -924,8 +924,7 @@ so it is close to the failing `0xbf0000cc`.
`readelf`:
....
./out/x86_64/buildroot/host/usr/bin/x86_64-buildroot-linux-uclibc-readelf \
-s ./out/x86_64/buildroot/build/kernel_module-1.0/hello.ko
./runtc readelf -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.
@@ -998,7 +997,7 @@ The base address shows on terminal:
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 | \
grep myinit
....
@@ -1295,7 +1294,7 @@ Cannot access memory at address 0x10604
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 | \
grep main
....
@@ -2737,7 +2736,7 @@ Notes:
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:

1
build
View File

@@ -9,7 +9,6 @@ touch "$br2_cli_file"
configure=true
config_fragments="${root_dir}/br2"
extra_make_args=
gem5=false
j="$(nproc)"
linux_reconfigure=false
linux_kernel_custom_config_file=

1
common
View File

@@ -49,3 +49,4 @@ if [ -f "$f" ]; then
fi
# Default arch.
arch=x86_64
gem5=false

1
run
View File

@@ -18,7 +18,6 @@ extra_append='console_msg_format=syslog nokaslr norandmaps printk.devkmsg=on pri
extra_append_after_dash=
extra_flags=
extra_flags_qemu=
gem5=false
gem5opts=
lkmc_eval=
initrd=false

1
rungdb
View File

@@ -4,7 +4,6 @@ set -eu
set -- ${cli_rungdb:-} "$@"
after=
before=
gem5=false
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\
"
kgdb=false

View File

@@ -3,7 +3,6 @@ set -eu
. common
set -- ${cli_rungdb_user:-} "$@"
usage="$0 <exec-relative-path> [<brk-symbol>]"
gem5=false
gem5_opt=
while getopts a:gh OPT; do
case "$OPT" in
@@ -34,8 +33,7 @@ else
fi
set_common_vars "$arch" "$gem5"
executable="${build_dir}/${executable_rel}"
readelf="${host_dir}/usr/bin/${arch}-linux-readelf"
addr="$("$readelf" -h "$executable" | awk '/Entry/{ print $NF }' )"
addr="$("${root_dir}/runtc" readelf -h "$executable" | awk '/Entry/{ print $NF }' )"
ex="-ex \"add-symbol-file $executable $addr\""
# -L or else lx-symbols throws for arm:
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc

View File

@@ -2,7 +2,6 @@
set -eu
. common
set -- ${cli_rungdbserver:-} "$@"
gem5=false
while getopts a:g OPT; do
case "$OPT" in
a)

28
runtc Executable file
View 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 "$?"

View File

@@ -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.
# 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)"
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}"
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)"