diff --git a/kernel/module/Makefile b/kernel/module/Makefile index 06201b9a0574..dbcd507a733a 100644 --- a/kernel/module/Makefile +++ b/kernel/module/Makefile @@ -22,18 +22,26 @@ obj-$(CONFIG_MODVERSIONS) += version.o obj-$(CONFIG_MODULE_UNLOAD_TAINT_TRACKING) += tracking.o # -# ANDROID: GKI: Generate headerfile required for gki_module.o +# ANDROID: GKI: Generate headerfiles required for gki_module.o # # Dependencies on generated files need to be listed explicitly $(obj)/gki_module.o: $(obj)/gki_module_protected_exports.h \ $(obj)/gki_module_unprotected.h -$(obj)/gki_module_unprotected.h: $(srctree)/scripts/gen_gki_modules_headers.sh \ - $(if $(wildcard ${OUT_DIR}/abi_symbollist.raw), ${OUT_DIR}/abi_symbollist.raw) +ALL_KMI_SYMBOLS := all_kmi_symbols + +$(obj)/gki_module_unprotected.h: $(ALL_KMI_SYMBOLS) \ + $(srctree)/scripts/gen_gki_modules_headers.sh $(Q)$(CONFIG_SHELL) $(srctree)/scripts/gen_gki_modules_headers.sh $@ \ - "$(srctree)" + "$(srctree)" \ + $(ALL_KMI_SYMBOLS) + +# Generate symbol list with union of all symbol list for arm64; empty for others +$(ALL_KMI_SYMBOLS): $(if $(filter arm64,$(ARCH)),$(wildcard $(srctree)/android/abi_gki_aarch64*),) + $(if $(strip $^),cat $^ > $(ALL_KMI_SYMBOLS), echo "" > $(ALL_KMI_SYMBOLS)) $(obj)/gki_module_protected_exports.h: $(srctree)/android/abi_gki_protected_exports \ $(srctree)/scripts/gen_gki_modules_headers.sh $(Q)$(CONFIG_SHELL) $(srctree)/scripts/gen_gki_modules_headers.sh $@ \ - "$(srctree)" + "$(srctree)" \ + $< diff --git a/scripts/gen_gki_modules_headers.sh b/scripts/gen_gki_modules_headers.sh index 4fe9d6faa19b..c1074ebd59c0 100755 --- a/scripts/gen_gki_modules_headers.sh +++ b/scripts/gen_gki_modules_headers.sh @@ -19,6 +19,7 @@ # Collect arguments from Makefile TARGET=$1 SRCTREE=$2 +SYMBOL_LIST=$3 set -e @@ -47,8 +48,14 @@ generate_header() { rm -f -- "${header_file}" fi - # Find Maximum symbol name length if valid symbol_file exist + # If symbol_file exist preprocess it and find maximum name length if [ -s "${symbol_file}" ]; then + # Remove White Spaces, empty lines and symbol list markers if any + sed -i '/^[[:space:]]*$/d; /^#/d; /\[abi_symbol_list\]/d' "${symbol_file}" + + # Sort in byte order for kernel binary search at runtime + LC_ALL=C sort -o "${symbol_file}" "${symbol_file}" + # Trim white spaces & +1 for null termination local max_name_len=$(awk ' { @@ -88,13 +95,12 @@ generate_header() { } if [ "$(basename "${TARGET}")" = "gki_module_unprotected.h" ]; then - # Sorted list of vendor symbols - GKI_VENDOR_SYMBOLS="${OUT_DIR}/abi_symbollist.raw" - + # Union of vendor symbol lists + GKI_VENDOR_SYMBOLS="${SYMBOL_LIST}" generate_header "${TARGET}" "${GKI_VENDOR_SYMBOLS}" "unprotected" else # Sorted list of exported symbols - GKI_EXPORTED_SYMBOLS="${SRCTREE}/android/abi_gki_protected_exports" + GKI_EXPORTED_SYMBOLS="${SYMBOL_LIST}" generate_header "${TARGET}" "${GKI_EXPORTED_SYMBOLS}" "protected_exports" fi