File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -950,9 +950,11 @@ mod_sign_cmd = true
950950endif
951951export mod_sign_cmd
952952
953+ HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
954+
953955ifdef CONFIG_STACK_VALIDATION
954956 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)
956958 ifeq ($(has_libelf),1)
957959 objtool_target := tools/objtool FORCE
958960 else
Original file line number Diff line number Diff line change @@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
2525OBJTOOL := $(OUTPUT ) objtool
2626OBJTOOL_IN := $(OBJTOOL ) -in.o
2727
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+
2831all : $(OBJTOOL )
2932
3033INCLUDES := -I$(srctree ) /tools/include \
3134 -I$(srctree ) /tools/arch/$(HOSTARCH ) /include/uapi \
3235 -I$(srctree ) /tools/objtool/arch/$(ARCH ) /include
3336WARNINGS := $(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 )
3639
3740# Allow old libelf to be used:
3841elfshdr := $(shell echo '$(pound ) include <libelf.h>' | $(CC ) $(CFLAGS ) -x c -E - | grep elf_getshdr)
You can’t perform that action at this time.
0 commit comments