diff options
-rw-r--r-- | tools/perf/arch/common.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 2367b253f039..5683529135b1 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c | |||
@@ -93,16 +93,46 @@ static int lookup_triplets(const char *const *triplets, const char *name) | |||
93 | return -1; | 93 | return -1; |
94 | } | 94 | } |
95 | 95 | ||
96 | /* | ||
97 | * Return architecture name in a normalized form. | ||
98 | * The conversion logic comes from the Makefile. | ||
99 | */ | ||
100 | static const char *normalize_arch(char *arch) | ||
101 | { | ||
102 | if (!strcmp(arch, "x86_64")) | ||
103 | return "x86"; | ||
104 | if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6') | ||
105 | return "x86"; | ||
106 | if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5)) | ||
107 | return "sparc"; | ||
108 | if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110")) | ||
109 | return "arm"; | ||
110 | if (!strncmp(arch, "s390", 4)) | ||
111 | return "s390"; | ||
112 | if (!strncmp(arch, "parisc", 6)) | ||
113 | return "parisc"; | ||
114 | if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3)) | ||
115 | return "powerpc"; | ||
116 | if (!strncmp(arch, "mips", 4)) | ||
117 | return "mips"; | ||
118 | if (!strncmp(arch, "sh", 2) && isdigit(arch[2])) | ||
119 | return "sh"; | ||
120 | |||
121 | return arch; | ||
122 | } | ||
123 | |||
96 | static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, | 124 | static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, |
97 | const char *name, | 125 | const char *name, |
98 | const char **path) | 126 | const char **path) |
99 | { | 127 | { |
100 | int idx; | 128 | int idx; |
101 | char *arch, *cross_env; | 129 | const char *arch, *cross_env; |
102 | struct utsname uts; | 130 | struct utsname uts; |
103 | const char *const *path_list; | 131 | const char *const *path_list; |
104 | char *buf = NULL; | 132 | char *buf = NULL; |
105 | 133 | ||
134 | arch = normalize_arch(env->arch); | ||
135 | |||
106 | if (uname(&uts) < 0) | 136 | if (uname(&uts) < 0) |
107 | goto out; | 137 | goto out; |
108 | 138 | ||
@@ -110,7 +140,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, | |||
110 | * We don't need to try to find objdump path for native system. | 140 | * We don't need to try to find objdump path for native system. |
111 | * Just use default binutils path (e.g.: "objdump"). | 141 | * Just use default binutils path (e.g.: "objdump"). |
112 | */ | 142 | */ |
113 | if (!strcmp(uts.machine, env->arch)) | 143 | if (!strcmp(normalize_arch(uts.machine), arch)) |
114 | goto out; | 144 | goto out; |
115 | 145 | ||
116 | cross_env = getenv("CROSS_COMPILE"); | 146 | cross_env = getenv("CROSS_COMPILE"); |
@@ -127,8 +157,6 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, | |||
127 | free(buf); | 157 | free(buf); |
128 | } | 158 | } |
129 | 159 | ||
130 | arch = env->arch; | ||
131 | |||
132 | if (!strcmp(arch, "arm")) | 160 | if (!strcmp(arch, "arm")) |
133 | path_list = arm_triplets; | 161 | path_list = arm_triplets; |
134 | else if (!strcmp(arch, "powerpc")) | 162 | else if (!strcmp(arch, "powerpc")) |
@@ -139,9 +167,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, | |||
139 | path_list = s390_triplets; | 167 | path_list = s390_triplets; |
140 | else if (!strcmp(arch, "sparc")) | 168 | else if (!strcmp(arch, "sparc")) |
141 | path_list = sparc_triplets; | 169 | path_list = sparc_triplets; |
142 | else if (!strcmp(arch, "x86") || !strcmp(arch, "i386") || | 170 | else if (!strcmp(arch, "x86")) |
143 | !strcmp(arch, "i486") || !strcmp(arch, "i586") || | ||
144 | !strcmp(arch, "i686")) | ||
145 | path_list = x86_triplets; | 171 | path_list = x86_triplets; |
146 | else if (!strcmp(arch, "mips")) | 172 | else if (!strcmp(arch, "mips")) |
147 | path_list = mips_triplets; | 173 | path_list = mips_triplets; |