Skip to content

Commit cd6c9dc

Browse files
captain5050namhyung
authored andcommitted
perf disasm: Add e_machine/e_flags to struct arch
Currently functions like get_dwarf_regnum only work with the host architecture. Carry the elf machine and flags in struct arch so that in disassembly these can be used to allow cross platform disassembly. Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: Anup Patel <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: David S. Miller <[email protected]> Cc: Albert Ou <[email protected]> Cc: Shenlin Liang <[email protected]> Cc: Nick Terrell <[email protected]> Cc: Guilherme Amadio <[email protected]> Cc: Steinar H. Gunderson <[email protected]> Cc: Changbin Du <[email protected]> Cc: Alexander Lobakin <[email protected]> Cc: Przemek Kitszel <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Guo Ren <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Will Deacon <[email protected]> Cc: James Clark <[email protected]> Cc: Mike Leach <[email protected]> Cc: Chen Pei <[email protected]> Cc: Leo Yan <[email protected]> Cc: Oliver Upton <[email protected]> Cc: Aditya Gupta <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Bibo Mao <[email protected]> Cc: John Garry <[email protected]> Cc: Atish Patra <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent ae894b7 commit cd6c9dc

File tree

12 files changed

+30
-2
lines changed

12 files changed

+30
-2
lines changed

tools/perf/arch/arc/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ static int arc__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
55
{
66
arch->initialized = true;
77
arch->objdump.comment_char = ';';
8+
arch->e_machine = EM_ARC;
9+
arch->e_flags = 0;
810
return 0;
911
}

tools/perf/arch/arm/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
5353
arch->associate_instruction_ops = arm__associate_instruction_ops;
5454
arch->objdump.comment_char = ';';
5555
arch->objdump.skip_functions_char = '+';
56+
arch->e_machine = EM_ARM;
57+
arch->e_flags = 0;
5658
return 0;
5759

5860
out_free_call:

tools/perf/arch/arm64/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
113113
arch->associate_instruction_ops = arm64__associate_instruction_ops;
114114
arch->objdump.comment_char = '/';
115115
arch->objdump.skip_functions_char = '+';
116+
arch->e_machine = EM_AARCH64;
117+
arch->e_flags = 0;
116118
return 0;
117119

118120
out_free_call:

tools/perf/arch/csky/annotate/instructions.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ static int csky__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
4343
arch->initialized = true;
4444
arch->objdump.comment_char = '/';
4545
arch->associate_instruction_ops = csky__associate_ins_ops;
46-
46+
arch->e_machine = EM_CSKY;
47+
#if defined(__CSKYABIV2__)
48+
arch->e_flags = EF_CSKY_ABIV2;
49+
#else
50+
arch->e_flags = EF_CSKY_ABIV1;
51+
#endif
4752
return 0;
4853
}

tools/perf/arch/loongarch/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ int loongarch__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
131131
arch->associate_instruction_ops = loongarch__associate_ins_ops;
132132
arch->initialized = true;
133133
arch->objdump.comment_char = '#';
134+
arch->e_machine = EM_LOONGARCH;
135+
arch->e_flags = 0;
134136
}
135137

136138
return 0;

tools/perf/arch/mips/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ int mips__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
4040
arch->associate_instruction_ops = mips__associate_ins_ops;
4141
arch->initialized = true;
4242
arch->objdump.comment_char = '#';
43+
arch->e_machine = EM_MIPS;
44+
arch->e_flags = 0;
4345
}
4446

4547
return 0;

tools/perf/arch/powerpc/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ static int powerpc__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
309309
arch->associate_instruction_ops = powerpc__associate_instruction_ops;
310310
arch->objdump.comment_char = '#';
311311
annotate_opts.show_asm_raw = true;
312+
arch->e_machine = EM_PPC;
313+
arch->e_flags = 0;
312314
}
313315

314316
return 0;

tools/perf/arch/riscv64/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ int riscv64__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
2828
arch->associate_instruction_ops = riscv64__associate_ins_ops;
2929
arch->initialized = true;
3030
arch->objdump.comment_char = '#';
31+
arch->e_machine = EM_RISCV;
32+
arch->e_flags = 0;
3133
}
3234

3335
return 0;

tools/perf/arch/s390/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
166166
if (s390__cpuid_parse(arch, cpuid))
167167
err = SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING;
168168
}
169+
arch->e_machine = EM_S390;
170+
arch->e_flags = 0;
169171
}
170172

171173
return err;

tools/perf/arch/sparc/annotate/instructions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ static int sparc__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
163163
arch->initialized = true;
164164
arch->associate_instruction_ops = sparc__associate_instruction_ops;
165165
arch->objdump.comment_char = '#';
166+
arch->e_machine = EM_SPARC;
167+
arch->e_flags = 0;
166168
}
167169

168170
return 0;

0 commit comments

Comments
 (0)