Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT

check_allowed_ops() is used from both HAVE_DWARF_GETLOCATIONS_SUPPORT
and HAVE_DWARF_CFI_SUPPORT sections, so move it into the right place so
that it's available when either are defined. This shows up when doing
a static cross compile for arm64:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
EXTRA_PERFLIBS="-lexpat"

util/dwarf-aux.c:1723:6: error: implicit declaration of function 'check_allowed_ops'

Fixes: 55442cc2f22d0727 ("perf dwarf-aux: Check allowed DWARF Ops")
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@arm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240508141458.439017-1-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
c9d49237 3536c257

+28 -28
+28 -28
tools/perf/util/dwarf-aux.c
··· 1217 1217 } 1218 1218 return -1; 1219 1219 } 1220 + 1221 + static bool check_allowed_ops(Dwarf_Op *ops, size_t nops) 1222 + { 1223 + /* The first op is checked separately */ 1224 + ops++; 1225 + nops--; 1226 + 1227 + /* 1228 + * It needs to make sure if the location expression matches to the given 1229 + * register and offset exactly. Thus it rejects any complex expressions 1230 + * and only allows a few of selected operators that doesn't change the 1231 + * location. 1232 + */ 1233 + while (nops) { 1234 + switch (ops->atom) { 1235 + case DW_OP_stack_value: 1236 + case DW_OP_deref_size: 1237 + case DW_OP_deref: 1238 + case DW_OP_piece: 1239 + break; 1240 + default: 1241 + return false; 1242 + } 1243 + ops++; 1244 + nops--; 1245 + } 1246 + return true; 1247 + } 1220 1248 #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT || HAVE_DWARF_CFI_SUPPORT */ 1221 1249 1222 1250 #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT ··· 1422 1394 1423 1395 /* Update offset relative to the start of the variable */ 1424 1396 data->offset = addr_offset - addr_type; 1425 - return true; 1426 - } 1427 - 1428 - static bool check_allowed_ops(Dwarf_Op *ops, size_t nops) 1429 - { 1430 - /* The first op is checked separately */ 1431 - ops++; 1432 - nops--; 1433 - 1434 - /* 1435 - * It needs to make sure if the location expression matches to the given 1436 - * register and offset exactly. Thus it rejects any complex expressions 1437 - * and only allows a few of selected operators that doesn't change the 1438 - * location. 1439 - */ 1440 - while (nops) { 1441 - switch (ops->atom) { 1442 - case DW_OP_stack_value: 1443 - case DW_OP_deref_size: 1444 - case DW_OP_deref: 1445 - case DW_OP_piece: 1446 - break; 1447 - default: 1448 - return false; 1449 - } 1450 - ops++; 1451 - nops--; 1452 - } 1453 1397 return true; 1454 1398 } 1455 1399