Skip to content

Commit d44becb

Browse files
Julien Thierryjpoimboe
authored andcommitted
objtool: Move ORC logic out of check()
Now that the objtool_file can be obtained outside of the check function, orc generation builtin no longer requires check to explicitly call its orc related functions. Signed-off-by: Julien Thierry <jthierry@redhat.com> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
1 parent 6545eb0 commit d44becb

5 files changed

Lines changed: 32 additions & 21 deletions

File tree

‎tools/objtool/builtin-check.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ int cmd_check(int argc, const char **argv)
4242
{
4343
const char *objname, *s;
4444
struct objtool_file *file;
45+
int ret;
4546

4647
argc = parse_options(argc, argv, check_options, check_usage, 0);
4748

@@ -58,5 +59,12 @@ int cmd_check(int argc, const char **argv)
5859
if (!file)
5960
return 1;
6061

61-
return check(file, false);
62+
ret = check(file);
63+
if (ret)
64+
return ret;
65+
66+
if (file->elf->changed)
67+
return elf_write(file->elf);
68+
69+
return 0;
6270
}

‎tools/objtool/builtin-orc.c‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int cmd_orc(int argc, const char **argv)
3232

3333
if (!strncmp(argv[0], "gen", 3)) {
3434
struct objtool_file *file;
35+
int ret;
3536

3637
argc = parse_options(argc, argv, check_options, orc_usage, 0);
3738
if (argc != 1)
@@ -43,7 +44,25 @@ int cmd_orc(int argc, const char **argv)
4344
if (!file)
4445
return 1;
4546

46-
return check(file, true);
47+
ret = check(file);
48+
if (ret)
49+
return ret;
50+
51+
if (list_empty(&file->insn_list))
52+
return 0;
53+
54+
ret = create_orc(file);
55+
if (ret)
56+
return ret;
57+
58+
ret = create_orc_sections(file);
59+
if (ret)
60+
return ret;
61+
62+
if (!file->elf->changed)
63+
return 0;
64+
65+
return elf_write(file->elf);
4766
}
4867

4968
if (!strcmp(argv[0], "dump")) {

‎tools/objtool/check.c‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,7 @@ static int validate_reachable_instructions(struct objtool_file *file)
29082908
return 0;
29092909
}
29102910

2911-
int check(struct objtool_file *file, bool orc)
2911+
int check(struct objtool_file *file)
29122912
{
29132913
int ret, warnings = 0;
29142914

@@ -2960,22 +2960,6 @@ int check(struct objtool_file *file, bool orc)
29602960
goto out;
29612961
warnings += ret;
29622962

2963-
if (orc) {
2964-
ret = create_orc(file);
2965-
if (ret < 0)
2966-
goto out;
2967-
2968-
ret = create_orc_sections(file);
2969-
if (ret < 0)
2970-
goto out;
2971-
}
2972-
2973-
if (file->elf->changed) {
2974-
ret = elf_write(file->elf);
2975-
if (ret < 0)
2976-
goto out;
2977-
}
2978-
29792963
out:
29802964
if (ret < 0) {
29812965
/*

‎tools/objtool/objtool.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct objtool_file {
2222

2323
struct objtool_file *objtool_open_read(const char *_objname);
2424

25-
int check(struct objtool_file *file, bool orc);
25+
int check(struct objtool_file *file);
2626
int orc_dump(const char *objname);
2727
int create_orc(struct objtool_file *file);
2828
int create_orc_sections(struct objtool_file *file);

‎tools/objtool/weak.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
return ENOSYS; \
1818
})
1919

20-
int __weak check(struct objtool_file *file, bool orc)
20+
int __weak check(struct objtool_file *file)
2121
{
2222
UNSUPPORTED("check subcommand");
2323
}

0 commit comments

Comments
 (0)