Add support for cross-compilation. The user must export ARCH, and either CROSS_COMPILE or LLVM.
Signed-off-by: Josh Poimboeuf <[email protected]> --- scripts/livepatch/klp-build | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build index 809e198a561d..b6c057e2120f 100755 --- a/scripts/livepatch/klp-build +++ b/scripts/livepatch/klp-build @@ -404,6 +404,14 @@ validate_patches() { revert_patches } +cross_compile_init() { + if [[ -v LLVM ]]; then + OBJCOPY=llvm-objcopy + else + OBJCOPY="${CROSS_COMPILE:-}objcopy" + fi +} + do_init() { # We're not yet smart enough to handle anything other than in-tree # builds in pwd. @@ -420,6 +428,7 @@ do_init() { validate_config set_module_name set_kernelversion + cross_compile_init } # Refresh the patch hunk headers, specifically the line numbers and counts. @@ -783,7 +792,7 @@ build_patch_module() { cp -f "$kmod_file" "$kmod_file.orig" # Work around issue where slight .config change makes corrupt BTF - objcopy --remove-section=.BTF "$kmod_file" + "$OBJCOPY" --remove-section=.BTF "$kmod_file" # Fix (and work around) linker wreckage for klp syms / relocs "$SRC/tools/objtool/objtool" klp post-link "$kmod_file" || die "objtool klp post-link failed" -- 2.53.0

