Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

objtool: Query pkg-config for libelf location

If it is not in the default location, compilation fails at several points.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/91a25e992566a7968fedc89ec80e7f4c83ad0548.1553622500.git.jpoimboe@redhat.com

authored by

Rolf Eike Beer and committed by
Thomas Gleixner
056d28d1 cfa637cb

+8 -3
+3 -1
Makefile
··· 950 950 endif 951 951 export mod_sign_cmd 952 952 953 + HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) 954 + 953 955 ifdef CONFIG_STACK_VALIDATION 954 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 958 ifeq ($(has_libelf),1) 957 959 objtool_target := tools/objtool FORCE 958 960 else
+5 -2
tools/objtool/Makefile
··· 25 25 OBJTOOL := $(OUTPUT)objtool 26 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 31 all: $(OBJTOOL) 29 32 30 33 INCLUDES := -I$(srctree)/tools/include \ 31 34 -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ 32 35 -I$(srctree)/tools/objtool/arch/$(ARCH)/include 33 36 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed 34 - CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) 35 - LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) 37 + CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) 38 + LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) 36 39 37 40 # Allow old libelf to be used: 38 41 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)