File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -950,9 +950,11 @@ mod_sign_cmd = true
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
Original file line number Diff line number Diff line change @@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
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)
You can’t perform that action at this time.
0 commit comments