From 3dfe8421810595ea18931dd6f1f3a183d5058c87 Mon Sep 17 00:00:00 2001 From: Will McVicker Date: Wed, 28 Apr 2021 14:37:13 -0700 Subject: [PATCH] GKI: update_symbol_list: add compiling with symbol trimming disabled When new symbols are needed by a kernel module, the new symbol(s) need to be added to the symbol list and the kernels needs to be recompiled to include the new symbol(s) (due to symbol trimming). Add support for this in update_symbol_list.sh so that the script: (1) recompiles the mixed build with symbol trimming disabled (2) extracts the necessary symbols from the kernel modules (3) updates both the pixel and aosp/ symbol lists Signed-off-by: Will McVicker Change-Id: I89fbd59c9bb2498ae2c1fb1d3b115bf91b1161be --- build.config.gs101 | 2 +- build_slider.sh | 6 ++++- update_symbol_list.sh | 52 +++++++++++++++++++++++++++++++++---------- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/build.config.gs101 b/build.config.gs101 index b7797cd1eefe..f56148fd667a 100644 --- a/build.config.gs101 +++ b/build.config.gs101 @@ -35,7 +35,7 @@ android/abi_gki_aarch64_hikey960 android/abi_gki_aarch64_exynos android/abi_gki_aarch64 " -TRIM_NONLISTED_KMI=1 +TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI:-1} KMI_SYMBOL_LIST_ADD_ONLY=1 KMI_SYMBOL_LIST_STRICT_MODE=${KMI_SYMBOL_LIST_STRICT_MODE:-1} KMI_SYMBOL_LIST_MODULE_GROUPING=0 diff --git a/build_slider.sh b/build_slider.sh index 265abdbe8bb4..e538a5980a9a 100755 --- a/build_slider.sh +++ b/build_slider.sh @@ -21,6 +21,7 @@ function build_gki { DIST_DIR=${DIST_DIR} \ LTO=${LTO} \ KMI_SYMBOL_LIST_STRICT_MODE=${ENABLE_STRICT_KMI} \ + TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI} \ BUILD_CONFIG=${KERNEL_BUILD_CONFIG} \ build/build.sh KCFLAGS=-Werror "$@" exit_if_error $? "Failed to compile ${KERNEL_OUT_DIR}" @@ -52,6 +53,8 @@ function build_pixel { LTO=${LTO} \ MIXED_BUILD=1 \ KBUILD_MIXED_TREE=${GKI_BINARIES_DIR} \ + KMI_SYMBOL_LIST_STRICT_MODE=${ENABLE_STRICT_KMI} \ + TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI} \ build/build.sh KCFLAGS=-Werror "$@" exit_if_error $? "Failed to compile device kernel" } @@ -65,6 +68,7 @@ GKI_BINARIES_DIR=$(readlink -m ${DIST_DIR}) GKI_PREBUILTS_DIR=$(readlink -m "prebuilts/boot-artifacts/kernel/") DEFAULT_CONFIG="private/gs-google/build.config.slider" DEVICE_KERNEL_BUILD_CONFIG=${DEVICE_KERNEL_BUILD_CONFIG:-${DEFAULT_CONFIG}} +TRIM_NONLISTED_KMI=${TRIM_NONLISTED_KMI:-1} if [ -z "${BUILD_KERNEL}" ]; then if [ "${EXPERIMENTAL_BUILD}" != "0" -o -n "${GKI_DEFCONFIG_FRAGMENT}" ]; then BUILD_KERNEL=1 @@ -76,7 +80,7 @@ fi if [ "${LTO}" = "none" ]; then ENABLE_STRICT_KMI=0 else - ENABLE_STRICT_KMI=1 + ENABLE_STRICT_KMI=${ENABLE_STRICT_KMI:-1} fi if [ "${EXPERIMENTAL_BUILD}" != "0" ]; then diff --git a/update_symbol_list.sh b/update_symbol_list.sh index f52d7f43d0ba..2e1ef2e47bed 100755 --- a/update_symbol_list.sh +++ b/update_symbol_list.sh @@ -1,9 +1,6 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -# Exit script on error -set -e - # Add a trap to remove the temporary vmlinux in case of an error occurs before # we finish. cleanup_trap() { @@ -12,6 +9,26 @@ cleanup_trap() { } trap 'cleanup_trap' EXIT +# We need to update the AOSP symbol list by cat'ing the Pixel symbol list and +# the AOSP symbol list together so that we don't drop symbols that may have +# merged in AOSP before they were merged into the pixel tree. +# +# $1 pixel symbol list +# $2 aosp symbol list +function update_aosp_symbol_list { + local pixel_symbol_list=$1 + local aosp_symbol_list=$2 + + # Remove blank lines and comments. Then sort + TMP_LIST=$(mktemp -t symbol_list.XXXX) + cat ${pixel_symbol_list} ${aosp_symbol_list} > ${TMP_LIST} + sed -i '/^$/d' ${TMP_LIST} + sed -i '/^#/d' ${TMP_LIST} + sort -u ${TMP_LIST} > ${aosp_symbol_list} + + rm -f ${TMP_LIST} +} + function extract_pixel_symbols { echo "========================================================" echo " Extracting symbols and updating the symbol list" @@ -24,11 +41,16 @@ function extract_pixel_symbols { cp ${DIST_DIR}/vmlinux ${VMLINUX_TMP} PATH=${PATH}:${clang_prebuilt_bin} - build/abi/extract_symbols \ + build/abi/extract_symbols \ --symbol-list ${pixel_symbol_list} \ - --skip-module-grouping \ - --additions-only \ + --skip-module-grouping \ + --additions-only \ ${BASE_OUT}/device-kernel/private + err=$? + if [ "${err}" != "0" ]; then + echo "ERROR: Failed to extract symbols! ret=${err}" >&2 + exit ${err} + fi # Strip the core ABI symbols from the pixel symbol list grep "^ " aosp/android/abi_gki_aarch64_core | while read l; do @@ -46,13 +68,21 @@ function extract_pixel_symbols { rm -f ${VMLINUX_TMP} ${TMP_LIST} } -BASE_OUT=${OUT_DIR:-out}/mixed/ -DIST_DIR=${DIST_DIR:-${BASE_OUT}/dist/} +export SKIP_MRPROPER=1 +export BASE_OUT=${OUT_DIR:-out}/mixed/ +export DIST_DIR=${DIST_DIR:-${BASE_OUT}/dist/} VMLINUX_TMP=${BASE_OUT}/device-kernel/private/vmlinux +BUILD_KERNEL=1 TRIM_NONLISTED_KMI=0 ENABLE_STRICT_KMI=0 ./build_slider.sh "$@" +err=$? +if [ "${err}" != "0" ]; then + echo "ERROR: Failed to run ./build_slider.sh! ret=${err}" >&2 + exit 1 +fi + extract_pixel_symbols "private/gs-google/android/abi_gki_aarch64_generic" -cp -f private/gs-google/android/abi_gki_aarch64_generic \ - aosp/android/abi_gki_aarch64_generic +update_aosp_symbol_list "private/gs-google/android/abi_gki_aarch64_generic" \ + "aosp/android/abi_gki_aarch64_generic" echo "========================================================" echo " The symbol list has been update locally in aosp/ and private/gs-google." @@ -61,5 +91,3 @@ echo " are merged. Re-compile using the below command:" echo echo " SKIP_MRPROPER=1 BUILD_KERNEL=1 ./build_slider.sh" echo - -set +e