diff --git a/source/tools/combine/btf/Makefile b/source/tools/combine/btf/Makefile index d4e7d95ef0bd85123a508be93839a19d3c6e4abf..bad09711e6f1f8b1037d8bbafde515bf96319477 100644 --- a/source/tools/combine/btf/Makefile +++ b/source/tools/combine/btf/Makefile @@ -1,4 +1,5 @@ target := btf $(target): cp btf.sh $(OBJPATH)/.sysak_compoents/tools/btf - cp vmlinux-btf $(OBJPATH)/.sysak_compoents/tools -rf \ No newline at end of file + cp vmlinux-btf $(OBJPATH)/.sysak_compoents/tools -rf + cp pahole $(OBJPATH)/.sysak_compoents/tools/pahole \ No newline at end of file diff --git a/source/tools/combine/btf/btf.sh b/source/tools/combine/btf/btf.sh index fc0ebb8a1bdb69bcfdfc1dc0cffbd23ab4e301cd..f683bda2096a1e5356d4068e32aeb6124c542b0a 100644 --- a/source/tools/combine/btf/btf.sh +++ b/source/tools/combine/btf/btf.sh @@ -5,12 +5,14 @@ zip_path=${SYSAK_WORK_PATH}/tools/BTF/btf.7z btf_dir=${SYSAK_WORK_PATH}/tools btf_path=${btf_dir}/vmlinux-$(uname -r) +vmlinux_path="" usage() { echo "sysak btf: Extract the btf file to the specified directory" echo "options: -h, help information" echo " -d, Specify the path, default directory path: ${btf_dir}" echo " -l, show vmlinux btf list" + echo " -g, Specify the vmlinux file path, which is used to generate btf. The generated btf file path is: ${btf_path} " } extract_btf() { @@ -22,11 +24,19 @@ extract_btf() { cp $source_path ${btf_path} } +generate_btf() { + if [ ! -f "$vmlinux_path" ]; then + echo "vmlinux file not exist: $vmlinux_path}" + fi + ${btf_dir}/pahole -J --kabi_prefix=__UNIQUE_ID_rh_kabi_hide --btf_encode_detached=${btf_path} ${vmlinux_path} + echo "btf file has been generated, the path is: ${btf_path}" +} + show_list() { ls ${SYSAK_WORK_PATH}/tools/vmlinux-btf } -while getopts 'd:lh' OPT; do +while getopts 'g:d:lh' OPT; do case $OPT in "h") usage @@ -35,12 +45,15 @@ while getopts 'd:lh' OPT; do "d") btf_dir=$OPTARG btf_path=${btf_dir}/vmlinux-$(uname -r) - ;; "l") show_list exit 0 ;; + "g") + vmlinux_path=$OPTARG + generate_btf + ;; *) usage exit -1 diff --git a/source/tools/combine/btf/pahole b/source/tools/combine/btf/pahole new file mode 100755 index 0000000000000000000000000000000000000000..b4453b275f6b0a7ae6b85871096adf11350bab84 Binary files /dev/null and b/source/tools/combine/btf/pahole differ