diff mbox series

[RFC,v5,08/57] objtool: Make ORC support optional

Message ID 20200109160300.26150-9-jthierry@redhat.com (mailing list archive)
State New, archived
Headers show
Series objtool: Add support for arm64 | expand

Commit Message

Julien Thierry Jan. 9, 2020, 4:02 p.m. UTC
Currently, only x86 supports ORC. To simplify the addition of other
supported architectures to objtool 'check' command, make the 'orc'
objtool command optional to implement for a given architecture.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
---
 tools/objtool/Build     |  2 +-
 tools/objtool/Makefile  | 10 +++++++++-
 tools/objtool/check.c   |  4 ++++
 tools/objtool/objtool.c |  2 ++
 tools/objtool/orc.h     | 33 +++++++++++++++++++++++++++++++--
 5 files changed, 47 insertions(+), 4 deletions(-)

Comments

Josh Poimboeuf Jan. 21, 2020, 4:37 p.m. UTC | #1
On Thu, Jan 09, 2020 at 04:02:11PM +0000, Julien Thierry wrote:
> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
> index d2a19b0bc05a..24d653e0b6ec 100644
> --- a/tools/objtool/Makefile
> +++ b/tools/objtool/Makefile
> @@ -6,6 +6,10 @@ ifeq ($(ARCH),x86_64)
>  ARCH := x86
>  endif
>  
> +ifeq ($(ARCH),x86)
> +OBJTOOL_ORC := y
> +endif

I think this should check SRCARCH instead, a la:

  https://lkml.kernel.org/r/d5d11370ae116df6c653493acd300ec3d7f5e925.1579543924.git.jpoimboe@redhat.com
Julien Thierry Jan. 23, 2020, 11:45 a.m. UTC | #2
On 1/21/20 4:37 PM, Josh Poimboeuf wrote:
> On Thu, Jan 09, 2020 at 04:02:11PM +0000, Julien Thierry wrote:
>> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
>> index d2a19b0bc05a..24d653e0b6ec 100644
>> --- a/tools/objtool/Makefile
>> +++ b/tools/objtool/Makefile
>> @@ -6,6 +6,10 @@ ifeq ($(ARCH),x86_64)
>>   ARCH := x86
>>   endif
>>   
>> +ifeq ($(ARCH),x86)
>> +OBJTOOL_ORC := y
>> +endif
> 
> I think this should check SRCARCH instead, a la:
> 
>    https://lkml.kernel.org/r/d5d11370ae116df6c653493acd300ec3d7f5e925.1579543924.git.jpoimboe@redhat.com
> 

Yes, thanks for pointing it out.
diff mbox series

Patch

diff --git a/tools/objtool/Build b/tools/objtool/Build
index d069d26d97fa..6e7163f9522a 100644
--- a/tools/objtool/Build
+++ b/tools/objtool/Build
@@ -1,6 +1,6 @@ 
 objtool-y += arch/$(SRCARCH)/
 objtool-y += builtin-check.o
-objtool-y += builtin-orc.o
+objtool-$(OBJTOOL_ORC) += builtin-orc.o
 objtool-y += check.o
 objtool-y += elf.o
 objtool-y += special.o
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index d2a19b0bc05a..24d653e0b6ec 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -6,6 +6,10 @@  ifeq ($(ARCH),x86_64)
 ARCH := x86
 endif
 
+ifeq ($(ARCH),x86)
+OBJTOOL_ORC := y
+endif
+
 # always use the host compiler
 HOSTAR	?= ar
 HOSTCC	?= gcc
@@ -42,8 +46,12 @@  LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
 CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
 
+ifeq ($(OBJTOOL_ORC),y)
+CFLAGS	+= -DOBJTOOL_ORC
+endif
+
 AWK = awk
-export srctree OUTPUT CFLAGS SRCARCH AWK
+export srctree OUTPUT CFLAGS SRCARCH AWK OBJTOOL_ORC
 include $(srctree)/tools/build/Makefile.include
 
 $(OBJTOOL_IN): fixdep FORCE
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 2c5ccf61510a..8f2ff030936d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1317,6 +1317,7 @@  static bool has_valid_stack_frame(struct insn_state *state)
 	return false;
 }
 
+#ifdef OBJTOOL_ORC
 static int update_insn_state_regs(struct instruction *insn, struct insn_state *state)
 {
 	struct cfi_reg *cfa = &state->cfa;
@@ -1340,6 +1341,7 @@  static int update_insn_state_regs(struct instruction *insn, struct insn_state *s
 
 	return 0;
 }
+#endif
 
 static void save_reg(struct insn_state *state, unsigned char reg, int base,
 		     int offset)
@@ -1425,8 +1427,10 @@  static int update_insn_state(struct instruction *insn, struct insn_state *state)
 		return 0;
 	}
 
+#ifdef OBJTOOL_ORC
 	if (state->type == ORC_TYPE_REGS || state->type == ORC_TYPE_REGS_IRET)
 		return update_insn_state_regs(insn, state);
+#endif
 
 	switch (op->dest.type) {
 
diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c
index 0b3528f05053..8db7139b72cd 100644
--- a/tools/objtool/objtool.c
+++ b/tools/objtool/objtool.c
@@ -34,7 +34,9 @@  static const char objtool_usage_string[] =
 
 static struct cmd_struct objtool_cmds[] = {
 	{"check",	cmd_check,	"Perform stack metadata validation on an object file" },
+#ifdef OBJTOOL_ORC
 	{"orc",		cmd_orc,	"Generate in-place ORC unwind tables for an object file" },
+#endif
 };
 
 bool help;
diff --git a/tools/objtool/orc.h b/tools/objtool/orc.h
index ffda072cf4ad..f5303b8264e3 100644
--- a/tools/objtool/orc.h
+++ b/tools/objtool/orc.h
@@ -6,14 +6,43 @@ 
 #ifndef _ORC_H
 #define _ORC_H
 
-#include <asm/orc_types.h>
-
 struct objtool_file;
 
+#ifdef OBJTOOL_ORC
+
+#include <asm/orc_types.h>
+
 int arch_orc_init(struct objtool_file *file);
 int arch_orc_create_sections(struct objtool_file *file);
 int arch_orc_read_unwind_hints(struct objtool_file *file);
 
 int orc_dump(const char *objname);
 
+#else
+
+struct orc_entry {
+};
+
+static inline int arch_orc_init(struct objtool_file *file)
+{
+	return 0;
+}
+
+static inline int arch_orc_create_sections(struct objtool_file *file)
+{
+	return 0;
+}
+
+static inline int arch_orc_read_unwind_hints(struct objtool_file *file)
+{
+	return 0;
+}
+
+static inline int orc_dump(const char *objname)
+{
+	return 0;
+}
+
+#endif /* OBJTOOL_ORC */
+
 #endif /* _ORC_H */