Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1124014img; Tue, 19 Mar 2019 00:30:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqGDxh0l92mPqtnqUqelo1o27ynNnKJOGe58X4dZCXKoRkhrERq+/1Dv/l7Fog/asWo+jT X-Received: by 2002:a62:4553:: with SMTP id s80mr535455pfa.141.1552980639620; Tue, 19 Mar 2019 00:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552980639; cv=none; d=google.com; s=arc-20160816; b=PEhn1kfYoyER8Gc1DKD1d7ZDCcmZ6RyTwfanAqHg13PPx5wF7SVj2QTAtMIWwcUffJ DAo34NZ+zlfFbg63GETMCNpgOKJPEMsdrSeR13LNjPbRQQSfDM0eGW+aKe+WVQQW877m 96GMvPeEKOVUThqx5dbXL1+Iu0ZrRx4+3KLof+6p5fRaeAlBSDFWdAD7iKNCSpdP6NGu UCXS64jRpONmyxErQ4YHeCb8+/2UnNbmkISd3VAacKtYxZ+2bAlQUXHDSHEmzSbBLgVX ad1lm8Iu6eTma79ucwEt5M3Iz3HBZAUbO/IiBISJ4cOBn7uJy6YhK4R/KVodzXkQc90m XnTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:message-id:date:subject:cc:to:from; bh=QbT9l7O0M9bcyE5XxfWtI/w/0LRkR1rV4UMlRcHg9c0=; b=WgbPt8t02MyGZDK31N503eMDkCw1XK45i1V5qV62YtJ4IZbV9goOsEQH9rAs1XgZ3l scf1+2b21YN4hdLZorMqwNJvp2LO1E0QVMqmdQl345wf+heQ1/fTiDm642L9lpoALIh1 ZS0+AjvYCD3LQutSEsaLIv0cSVJz8UeD67zyEioMKkzln5M3KqHFGu70EidaqasJv4G1 C7mZTotykmgBTZxqcSWkE6Tj4q8d9LZLOan6pk8jXkrbSCuChitUmvUudRbEa1qLU7oI o8DTCE6tcw3WSHxf4w8wY/XDV2qyhKubxt7zahdeBXoDjFrjXBis6ayYwFeXDv3dzSJr g6Vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si8334404pfi.23.2019.03.19.00.30.23; Tue, 19 Mar 2019 00:30:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726573AbfCSH3s convert rfc822-to-8bit (ORCPT + 99 others); Tue, 19 Mar 2019 03:29:48 -0400 Received: from mx1.emlix.com ([188.40.240.192]:55692 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfCSH3s (ORCPT ); Tue, 19 Mar 2019 03:29:48 -0400 X-Greylist: delayed 573 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 Mar 2019 03:29:47 EDT Received: from mailer.emlix.com (unknown [81.20.119.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id 42CDA5F97B; Tue, 19 Mar 2019 08:20:12 +0100 (CET) From: Rolf Eike Beer To: Josh Poimboeuf , Peter Zijlstra Cc: Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] objtool: query pkg-config for libelf location Date: Tue, 19 Mar 2019 08:20:12 +0100 Message-ID: <3381642.TeJ1gWjbju@devpool35> Organization: emlix GmbH MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If it is not in the default location compilation would fail at several points. Signed-off-by: Rolf Eike Beer --- Makefile | 4 +++- tools/objtool/Makefile | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9ef547fc7ffe..666b52c1c5f4 100644 --- a/Makefile +++ b/Makefile @@ -940,9 +940,11 @@ mod_sign_cmd = true endif export mod_sign_cmd +HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) + ifdef CONFIG_STACK_VALIDATION has_libelf := $(call try-run,\ - echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0) + echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) ifeq ($(has_libelf),1) objtool_target := tools/objtool FORCE else diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index c9d038f91af6..0c8dd1609348 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a OBJTOOL := $(OUTPUT)objtool OBJTOOL_IN := $(OBJTOOL)-in.o +LIBELF_FLAGS = $(shell pkg-config libelf --cflags) +LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) + all: $(OBJTOOL) INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/objtool/arch/$(ARCH)/include WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) -LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) +CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) +LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) # Allow old libelf to be used: elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) -- 2.21.0 -- Rolf Eike Beer, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source