[PATCH v1 01/11] perf aslr: Add missing includes and sort headers

From: Ian Rogers

Date: Thu Sep 17 2026 - 00:54:18 EST


Sashiko reported:

When building the perf utility against strict C standard libraries
such as musl libc, compilation fails in tools/perf/util/aslr.c due
to missing explicit inclusions of <stdlib.h> and <string.h>.

The implementation relies on standard memory management and string
functions like malloc(), free(), memcpy(), and memset() in routines
such as aslr_tool__findnew_mapping(), aslr_tool__process_sample(),
and aslr_tool__delete(). Because the required headers are omitted,
the compiler must resolve these calls via implicit function
declarations. While glibc may transitively provide these definitions
via other headers, musl libc does not. This violates strict C99+
standard compliance and triggers fatal build errors under modern
compiler configurations.

Add the header files and use git clang-format to sort.

Reported-by: sashiko-bot@xxxxxxxxxx
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/aslr.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/aslr.c b/tools/perf/util/aslr.c
index 027695d96779..f49e965243aa 100644
--- a/tools/perf/util/aslr.c
+++ b/tools/perf/util/aslr.c
@@ -1,28 +1,32 @@
// SPDX-License-Identifier: GPL-2.0
#include "aslr.h"

+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <byteswap.h>
+#include <linux/compiler.h>
+#include <linux/zalloc.h>
+#include <unistd.h>
+
+#include <internal/lib.h> /* page_size */
+
#include "addr_location.h"
+#include "data.h"
#include "debug.h"
+#include "dso.h"
#include "event.h"
-#include "evsel.h"
#include "evlist.h"
+#include "evsel.h"
#include "machine.h"
#include "map.h"
-#include "thread.h"
-#include "tool.h"
-#include "session.h"
-#include "data.h"
-#include "dso.h"
#include "pmu.h"
#include "pmus.h"
-
-#include <internal/lib.h> /* page_size */
-#include <linux/compiler.h>
-#include <linux/zalloc.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <byteswap.h>
+#include "session.h"
+#include "thread.h"
+#include "tool.h"

/**
* struct remap_addresses_key - Key for mapping original addresses to remapped ones.
--
2.55.0.1082.g2b9226bbc0-goog