aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/arch/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/arch/common.c')
-rw-r--r--tools/perf/arch/common.c44
1 files changed, 3 insertions, 41 deletions
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 8c0cfeb55f8e..c6f373508a4f 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -1,12 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <stdio.h> 2#include <stdio.h>
3#include <sys/utsname.h>
4#include "common.h" 3#include "common.h"
4#include "../util/env.h"
5#include "../util/util.h" 5#include "../util/util.h"
6#include "../util/debug.h" 6#include "../util/debug.h"
7 7
8#include "sane_ctype.h"
9
10const char *const arm_triplets[] = { 8const char *const arm_triplets[] = {
11 "arm-eabi-", 9 "arm-eabi-",
12 "arm-linux-androideabi-", 10 "arm-linux-androideabi-",
@@ -120,55 +118,19 @@ static int lookup_triplets(const char *const *triplets, const char *name)
120 return -1; 118 return -1;
121} 119}
122 120
123/*
124 * Return architecture name in a normalized form.
125 * The conversion logic comes from the Makefile.
126 */
127const char *normalize_arch(char *arch)
128{
129 if (!strcmp(arch, "x86_64"))
130 return "x86";
131 if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6')
132 return "x86";
133 if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5))
134 return "sparc";
135 if (!strcmp(arch, "aarch64") || !strcmp(arch, "arm64"))
136 return "arm64";
137 if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110"))
138 return "arm";
139 if (!strncmp(arch, "s390", 4))
140 return "s390";
141 if (!strncmp(arch, "parisc", 6))
142 return "parisc";
143 if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3))
144 return "powerpc";
145 if (!strncmp(arch, "mips", 4))
146 return "mips";
147 if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
148 return "sh";
149
150 return arch;
151}
152
153static int perf_env__lookup_binutils_path(struct perf_env *env, 121static int perf_env__lookup_binutils_path(struct perf_env *env,
154 const char *name, const char **path) 122 const char *name, const char **path)
155{ 123{
156 int idx; 124 int idx;
157 const char *arch, *cross_env; 125 const char *arch = perf_env__arch(env), *cross_env;
158 struct utsname uts;
159 const char *const *path_list; 126 const char *const *path_list;
160 char *buf = NULL; 127 char *buf = NULL;
161 128
162 arch = normalize_arch(env->arch);
163
164 if (uname(&uts) < 0)
165 goto out;
166
167 /* 129 /*
168 * We don't need to try to find objdump path for native system. 130 * We don't need to try to find objdump path for native system.
169 * Just use default binutils path (e.g.: "objdump"). 131 * Just use default binutils path (e.g.: "objdump").
170 */ 132 */
171 if (!strcmp(normalize_arch(uts.machine), arch)) 133 if (!strcmp(perf_env__arch(NULL), arch))
172 goto out; 134 goto out;
173 135
174 cross_env = getenv("CROSS_COMPILE"); 136 cross_env = getenv("CROSS_COMPILE");