Merge branch '00.00-inst' of git://github.com/skeggsb/linux into drm-fixes
[linux-2.6-microblaze.git] / tools / objtool / objtool.c
index 58fdda5..7b97ce4 100644 (file)
@@ -21,7 +21,9 @@
 #include <subcmd/pager.h>
 #include <linux/kernel.h>
 
-#include "builtin.h"
+#include <objtool/builtin.h>
+#include <objtool/objtool.h>
+#include <objtool/warn.h>
 
 struct cmd_struct {
        const char *name;
@@ -39,6 +41,35 @@ static struct cmd_struct objtool_cmds[] = {
 
 bool help;
 
+const char *objname;
+static struct objtool_file file;
+
+struct objtool_file *objtool_open_read(const char *_objname)
+{
+       if (objname) {
+               if (strcmp(objname, _objname)) {
+                       WARN("won't handle more than one file at a time");
+                       return NULL;
+               }
+               return &file;
+       }
+       objname = _objname;
+
+       file.elf = elf_open_read(objname, O_RDWR);
+       if (!file.elf)
+               return NULL;
+
+       INIT_LIST_HEAD(&file.insn_list);
+       hash_init(file.insn_hash);
+       INIT_LIST_HEAD(&file.static_call_list);
+       INIT_LIST_HEAD(&file.mcount_loc_list);
+       file.c_file = !vmlinux && find_section_by_name(file.elf, ".comment");
+       file.ignore_unreachables = no_unreachable;
+       file.hints = false;
+
+       return &file;
+}
+
 static void cmd_usage(void)
 {
        unsigned int i, longest = 0;