// SPDX-License-Identifier: GPL-2.0
#include "aslr.h"
#include "addr_location.h"
#include "debug.h"
#include "event.h"
#include "evsel.h"
#include "evlist.h"
#include "machine.h"
#include "map.h"
#include "thread.h"
#include "tool.h"
#include "session.h"
#include "data.h"
#include "dso.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>
/**
* struct remap_addresses_key - Key for mapping original addresses to remapped ones.
* @dso: Pointer to the DSO (Dynamic Shared Object) associated with the mapping.
* @invariant: Unique offset invariant within the VMA (Virtual Memory Area).
* Calculated as `start - pgoff`. This value remains constant when
* perf's internal `maps__fixup_overlap_and_insert` splits a map into
* fragmented VMA pieces due to overlapping events, allowing us to
* resolve split maps consistently back to the original VMA.
* @pid: Process ID associated with the mapping.
*/
struct remap_addresses_key {
struct machine *machine;
struct dso *dso;
u64 invariant;
pid_t pid;
};
struct aslr_mapping {
struct list_head node;
u64 orig_start;
u64 len;
u64 remap_start;
};
struct aslr_evsel_priv {
u64 orig_sample_type;
u64 orig_sample_regs_user;
u64 orig_sample_regs_intr;
int orig_sample_size;
};
static size_t evsel_hash(long key, void *ctx __maybe_unused)
{
return (size_t)key;
}
static bool evsel_equal(long key1, long key2, void *ctx __maybe_unused)
{
return key1 == key2;
}
struct process_top_address {
u64 remapped_max;