perf dwarf-aux: Fix build with HAVE_DWARF_CFI_SUPPORT
authorJames Clark <james.clark@arm.com>
Wed, 8 May 2024 14:14:57 +0000 (15:14 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 9 May 2024 21:19:27 +0000 (18:19 -0300)
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>
tools/perf/util/dwarf-aux.c

index ec988f2944972cc4a7d14e23be299780d22a5e23..44ef968a7ad331d2f7db046def676bb772ac13f8 100644 (file)
@@ -1217,6 +1217,34 @@ static int offset_from_dwarf_op(Dwarf_Op *op)
        }
        return -1;
 }
+
+static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
+{
+       /* The first op is checked separately */
+       ops++;
+       nops--;
+
+       /*
+        * It needs to make sure if the location expression matches to the given
+        * register and offset exactly.  Thus it rejects any complex expressions
+        * and only allows a few of selected operators that doesn't change the
+        * location.
+        */
+       while (nops) {
+               switch (ops->atom) {
+               case DW_OP_stack_value:
+               case DW_OP_deref_size:
+               case DW_OP_deref:
+               case DW_OP_piece:
+                       break;
+               default:
+                       return false;
+               }
+               ops++;
+               nops--;
+       }
+       return true;
+}
 #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT || HAVE_DWARF_CFI_SUPPORT */
 
 #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
@@ -1397,34 +1425,6 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
        return true;
 }
 
-static bool check_allowed_ops(Dwarf_Op *ops, size_t nops)
-{
-       /* The first op is checked separately */
-       ops++;
-       nops--;
-
-       /*
-        * It needs to make sure if the location expression matches to the given
-        * register and offset exactly.  Thus it rejects any complex expressions
-        * and only allows a few of selected operators that doesn't change the
-        * location.
-        */
-       while (nops) {
-               switch (ops->atom) {
-               case DW_OP_stack_value:
-               case DW_OP_deref_size:
-               case DW_OP_deref:
-               case DW_OP_piece:
-                       break;
-               default:
-                       return false;
-               }
-               ops++;
-               nops--;
-       }
-       return true;
-}
-
 /* Only checks direct child DIEs in the given scope. */
 static int __die_find_var_reg_cb(Dwarf_Die *die_mem, void *arg)
 {