diff --git a/Makefile b/Makefile
index b14483742a6704e03300d289fa378d4838616cbc..a0319d0a6a86c611aa597823158f8e001262164c 100644
--- a/Makefile
+++ b/Makefile
@@ -1066,7 +1066,7 @@ export MODLIB
 HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
 
 has_libelf = $(call try-run,\
-               echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
+               echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
 
 ifdef CONFIG_STACK_VALIDATION
   ifeq ($(has_libelf),1)