diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | tools/objtool/Makefile | 7 |
2 files changed, 8 insertions, 3 deletions
@@ -950,9 +950,11 @@ mod_sign_cmd = true | |||
950 | endif | 950 | endif |
951 | export mod_sign_cmd | 951 | export mod_sign_cmd |
952 | 952 | ||
953 | HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) | ||
954 | |||
953 | ifdef CONFIG_STACK_VALIDATION | 955 | ifdef CONFIG_STACK_VALIDATION |
954 | has_libelf := $(call try-run,\ | 956 | has_libelf := $(call try-run,\ |
955 | echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0) | 957 | echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) |
956 | ifeq ($(has_libelf),1) | 958 | ifeq ($(has_libelf),1) |
957 | objtool_target := tools/objtool FORCE | 959 | objtool_target := tools/objtool FORCE |
958 | else | 960 | else |
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index c9d038f91af6..53f8be0f4a1f 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile | |||
@@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a | |||
25 | OBJTOOL := $(OUTPUT)objtool | 25 | OBJTOOL := $(OUTPUT)objtool |
26 | OBJTOOL_IN := $(OBJTOOL)-in.o | 26 | OBJTOOL_IN := $(OBJTOOL)-in.o |
27 | 27 | ||
28 | LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null) | ||
29 | LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) | ||
30 | |||
28 | all: $(OBJTOOL) | 31 | all: $(OBJTOOL) |
29 | 32 | ||
30 | INCLUDES := -I$(srctree)/tools/include \ | 33 | INCLUDES := -I$(srctree)/tools/include \ |
31 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ | 34 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ |
32 | -I$(srctree)/tools/objtool/arch/$(ARCH)/include | 35 | -I$(srctree)/tools/objtool/arch/$(ARCH)/include |
33 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed | 36 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed |
34 | CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) | 37 | CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) |
35 | LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) | 38 | LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) |
36 | 39 | ||
37 | # Allow old libelf to be used: | 40 | # Allow old libelf to be used: |
38 | elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) | 41 | elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) |