Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/tools/testing/selftests/bpf/progs/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 1 kB image not shown  

Quelle  test_core_reloc_misc.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019 Facebook

#include <linux/bpf.h>
#include <stdint.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_core_read.h>

char _license[] SEC("license") = "GPL";

struct {
 char in[256];
 char out[256];
} data = {};

struct core_reloc_misc_output {
 int a, b, c;
};

struct core_reloc_misc___a {
 int a1;
 int a2;
};

struct core_reloc_misc___b {
 int b1;
 int b2;
};

/* fixed two first members, can be extended with new fields */
struct core_reloc_misc_extensible {
 int a;
 int b;
};

#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)

SEC("raw_tracepoint/sys_enter")
int test_core_misc(void *ctx)
{
 struct core_reloc_misc___a *in_a = (void *)&data.in;
 struct core_reloc_misc___b *in_b = (void *)&data.in;
 struct core_reloc_misc_extensible *in_ext = (void *)&data.in;
 struct core_reloc_misc_output *out = (void *)&data.out;

 /* record two different relocations with the same accessor string */
 if (CORE_READ(&out->a, &in_a->a1) ||  /* accessor: 0:0 */
     CORE_READ(&out->b, &in_b->b1))  /* accessor: 0:0 */
  return 1;

 /* Validate relocations capture array-only accesses for structs with
 * fixed header, but with potentially extendable tail. This will read
 * first 4 bytes of 2nd element of in_ext array of potentially
 * variably sized struct core_reloc_misc_extensible. */

 if (CORE_READ(&out->c, &in_ext[2]))  /* accessor: 2 */
  return 1;

 return 0;
}


Messung V0.5
C=93 H=97 G=94

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.