linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] objtool: allow building with older libelf
@ 2016-05-16 20:31 Josh Poimboeuf
  2016-05-17  9:00 ` [tip:core/urgent] objtool: Allow " tip-bot for Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Josh Poimboeuf @ 2016-05-16 20:31 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Jan Beulich

From: Jan Beulich <JBeulich@suse.com>

The switch to elf_getshdr{num,strndx} post-dates the oldest tool chain
the kernel is supposed to be able to build with, so try to cope with
such an environment.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/objtool/Makefile | 4 ++++
 tools/objtool/elf.h    | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 6765c7e..f094f3c 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -30,6 +30,10 @@ INCLUDES := -I$(srctree)/tools/include
 CFLAGS   += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
 LDFLAGS  += -lelf $(LIBSUBCMD)
 
+# Allow old libelf to be used:
+elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
+CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
+
 AWK = awk
 export srctree OUTPUT CFLAGS ARCH AWK
 include $(srctree)/tools/build/Makefile.include
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index 7f3e00a..aa1ff65 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -23,6 +23,11 @@
 #include <linux/list.h>
 #include <linux/hashtable.h>
 
+#ifdef LIBELF_USE_DEPRECATED
+# define elf_getshdrnum    elf_getshnum
+# define elf_getshdrstrndx elf_getshstrndx
+#endif
+
 struct section {
 	struct list_head list;
 	GElf_Shdr sh;
-- 
2.4.11

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:core/urgent] objtool: Allow building with older libelf
  2016-05-16 20:31 [PATCH] objtool: allow building with older libelf Josh Poimboeuf
@ 2016-05-17  9:00 ` tip-bot for Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Jan Beulich @ 2016-05-17  9:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: JBeulich, jolsa, jpoimboe, mingo, alexander.shishkin, peterz,
	vincent.weaver, tglx, acme, linux-kernel, hpa, jbeulich,
	torvalds, eranian

Commit-ID:  2e51f26245701cb28f154552836b7807159088a8
Gitweb:     http://git.kernel.org/tip/2e51f26245701cb28f154552836b7807159088a8
Author:     Jan Beulich <JBeulich@suse.com>
AuthorDate: Mon, 16 May 2016 15:31:07 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 17 May 2016 10:42:46 +0200

objtool: Allow building with older libelf

The switch to elf_getshdr{num,strndx} post-dates the oldest tool chain
the kernel is supposed to be able to build with, so try to cope with
such an environment.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: <stable@vger.kernel.org> # for v4.6
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/732dae6872b7ff187d94f22bb699a12849d3fe04.1463430618.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 tools/objtool/Makefile | 4 ++++
 tools/objtool/elf.h    | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 6765c7e..f094f3c 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -30,6 +30,10 @@ INCLUDES := -I$(srctree)/tools/include
 CFLAGS   += -Wall -Werror $(EXTRA_WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
 LDFLAGS  += -lelf $(LIBSUBCMD)
 
+# Allow old libelf to be used:
+elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
+CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
+
 AWK = awk
 export srctree OUTPUT CFLAGS ARCH AWK
 include $(srctree)/tools/build/Makefile.include
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index 7f3e00a..aa1ff65 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -23,6 +23,11 @@
 #include <linux/list.h>
 #include <linux/hashtable.h>
 
+#ifdef LIBELF_USE_DEPRECATED
+# define elf_getshdrnum    elf_getshnum
+# define elf_getshdrstrndx elf_getshstrndx
+#endif
+
 struct section {
 	struct list_head list;
 	GElf_Shdr sh;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-17  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-16 20:31 [PATCH] objtool: allow building with older libelf Josh Poimboeuf
2016-05-17  9:00 ` [tip:core/urgent] objtool: Allow " tip-bot for Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).