lkml.org 
[lkml]   [2020]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v5 08/57] objtool: Make ORC support optional
Date
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(-)

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 */
--
2.21.0
\
 
 \ /
  Last update: 2020-01-09 17:04    [W:0.254 / U:12.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site