/*
* Kernel constants to make available for plugins without the need to include
* kernel headers.
*
* There's overlap with asm-offsets.h, but we want type preserving symbols, not
* defines to have proper compiler visibility and be able to use them in
* plugins.
*
* This file's preprocessor output will be post-processed to generate "ksyms.h"
*
* Written by Mathias Krause <[email protected]>
* Copyright 2020 by Open Source Security, Inc.
* Copyright 2020-2024 by PaX Team
* Licensed under the GPL v2
*/
#define KSYMS_GENERATE_INCLUDES
#include "ksyms.def"
/* Dummy struct to be able to preserve the original types */
static const struct __plugin_ksyms {
/* These symbols will be generated as struct fields 'typeof(val) sym;' */
#define DEFINE(sym, val) typeof(val) ksym_##sym;
#define DEFINE_OPTIONAL(sym, val) koptional_##sym
#define DEFINE_ENUM(name, val) enum ksym_##name ksym_##val;
#define DEFINE_DECL(sym, val) typeof(val) *ksym_##sym;
#define DEFINE_DECL_OPTIONAL(def, sym, val) kdecloptional(def_##def, sym_##sym)
#define DEFINE_TYPE(name, val) struct val ksym_##val;
#define COMMENT(s) COMMENT(s)
#define BLANK() BLANK()
#define KSYMS_GENERATE_DEFINES
#include "ksyms.def"
} __plugin_ksyms __maybe_unused = {
/* These symbols will be generated as designated initializers '.sym = val,' */
#define DEFINE(sym, val) .ksym_##sym = val,
#define DEFINE_OPTIONAL(sym, val) kinit_##val
#define DEFINE_ENUM(name, val)
#define DEFINE_DECL(sym, val) .ksym_##sym = &val,
#define DEFINE_DECL_OPTIONAL(def, sym, val) kdeclinit(def_##def, sym_##sym, val_##val)
#define DEFINE_TYPE(name, val)
#define COMMENT(s) COMMENT(s)
#define BLANK() BLANK()
#define KSYMS_GENERATE_DEFINES
#include "ksyms.def"
};