@@ -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
@@ -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
@@ -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) {
@@ -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;
@@ -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 */
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(-)