Skip to content

Commit

Permalink
GKI: update_symbol_list: add compiling with symbol trimming disabled
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: I89fbd59c9bb2498ae2c1fb1d3b115bf91b1161be
  • Loading branch information
Will McVicker committed Apr 28, 2021
1 parent 9d2da75 commit 3dfe842
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.config.gs101
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion build_slider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
}
Expand All @@ -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
Expand All @@ -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
Expand Down
52 changes: 40 additions & 12 deletions update_symbol_list.sh
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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."
Expand All @@ -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

0 comments on commit 3dfe842

Please sign in to comment.