Skip to content

Commit ae894b7

Browse files
captain5050namhyung
authored andcommitted
perf dwarf-regs: Add EM_HOST and EF_HOST defines
Computed from the build architecture defines, EM_HOST and EF_HOST give values that can be used in dwarf register lookup. Place in dwarf-regs.h so the value can be shared. Move some dwarf-regs.c constants used for EM_HOST to dwarf-regs.h. Add CSky constants that may be missing. In disasm.c add an include of dwarf-regs.h as the included arch/*/annotate/instructions.c files make use of the constants and we want the elf.h/dwarf-regs.h dependency to be explicit. 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 6ac7528 commit ae894b7

File tree

3 files changed

+83
-8
lines changed

3 files changed

+83
-8
lines changed

tools/perf/util/disasm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "disasm.h"
1919
#include "disasm_bpf.h"
2020
#include "dso.h"
21+
#include "dwarf-regs.h"
2122
#include "env.h"
2223
#include "evsel.h"
2324
#include "map.h"

tools/perf/util/dwarf-regs.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
#include <errno.h>
1414
#include <linux/kernel.h>
1515

16-
#ifndef EM_AARCH64
17-
#define EM_AARCH64 183 /* ARM 64 bit */
18-
#endif
19-
20-
#ifndef EM_LOONGARCH
21-
#define EM_LOONGARCH 258 /* LoongArch */
22-
#endif
23-
2416
/* Define const char * {arch}_register_tbl[] */
2517
#define DEFINE_DWARF_REGSTR_TABLE
2618
#include "../arch/x86/include/dwarf-regs-table.h"

tools/perf/util/include/dwarf-regs.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,88 @@
22
#ifndef _PERF_DWARF_REGS_H_
33
#define _PERF_DWARF_REGS_H_
44
#include "annotate.h"
5+
#include <elf.h>
6+
7+
#ifndef EM_AARCH64
8+
#define EM_AARCH64 183 /* ARM 64 bit */
9+
#endif
10+
11+
#ifndef EM_CSKY
12+
#define EM_CSKY 252 /* C-SKY */
13+
#endif
14+
#ifndef EF_CSKY_ABIV1
15+
#define EF_CSKY_ABIV1 0X10000000
16+
#endif
17+
#ifndef EF_CSKY_ABIV2
18+
#define EF_CSKY_ABIV2 0X20000000
19+
#endif
20+
21+
#ifndef EM_LOONGARCH
22+
#define EM_LOONGARCH 258 /* LoongArch */
23+
#endif
24+
25+
/* EM_HOST gives the ELF machine for host, EF_HOST gives additional flags. */
26+
#if defined(__x86_64__)
27+
#define EM_HOST EM_X86_64
28+
#elif defined(__i386__)
29+
#define EM_HOST EM_386
30+
#elif defined(__aarch64__)
31+
#define EM_HOST EM_AARCH64
32+
#elif defined(__arm__)
33+
#define EM_HOST EM_ARM
34+
#elif defined(__alpha__)
35+
#define EM_HOST EM_ALPHA
36+
#elif defined(__arc__)
37+
#define EM_HOST EM_ARC
38+
#elif defined(__AVR__)
39+
#define EM_HOST EM_AVR
40+
#elif defined(__AVR32__)
41+
#define EM_HOST EM_AVR32
42+
#elif defined(__bfin__)
43+
#define EM_HOST EM_BLACKFIN
44+
#elif defined(__csky__)
45+
#define EM_HOST EM_CSKY
46+
#if defined(__CSKYABIV2__)
47+
#define EF_HOST EF_CSKY_ABIV2
48+
#else
49+
#define EF_HOST EF_CSKY_ABIV1
50+
#endif
51+
#elif defined(__cris__)
52+
#define EM_HOST EM_CRIS
53+
#elif defined(__hppa__) // HP PA-RISC
54+
#define EM_HOST EM_PARISC
55+
#elif defined(__loongarch__)
56+
#define EM_HOST EM_LOONGARCH
57+
#elif defined(__mips__)
58+
#define EM_HOST EM_MIPS
59+
#elif defined(__m32r__)
60+
#define EM_HOST EM_M32R
61+
#elif defined(__microblaze__)
62+
#define EM_HOST EM_MICROBLAZE
63+
#elif defined(__MSP430__)
64+
#define EM_HOST EM_MSP430
65+
#elif defined(__powerpc64__)
66+
#define EM_HOST EM_PPC64
67+
#elif defined(__powerpc__)
68+
#define EM_HOST EM_PPC
69+
#elif defined(__riscv)
70+
#define EM_HOST EM_RISCV
71+
#elif defined(__s390x__)
72+
#define EM_HOST EM_S390
73+
#elif defined(__sh__)
74+
#define EM_HOST EM_SH
75+
#elif defined(__sparc64__) || defined(__sparc__)
76+
#define EM_HOST EM_SPARC
77+
#elif defined(__xtensa__)
78+
#define EM_HOST EM_XTENSA
79+
#else
80+
/* Unknown host ELF machine type. */
81+
#define EM_HOST EM_NONE
82+
#endif
83+
84+
#if !defined(EF_HOST)
85+
#define EF_HOST 0
86+
#endif
587

688
#define DWARF_REG_PC 0xd3af9c /* random number */
789
#define DWARF_REG_FB 0xd3affb /* random number */

0 commit comments

Comments
 (0)