ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
dfsan_interface.h
Go to the documentation of this file.
1 //===-- dfsan_interface.h -------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of DataFlowSanitizer.
10 //
11 // Public interface header.
12 //===----------------------------------------------------------------------===//
13 #ifndef DFSAN_INTERFACE_H
14 #define DFSAN_INTERFACE_H
15 
16 #include <stddef.h>
17 #include <stdint.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
25 
32  // Fields for union labels, set to 0 for base labels.
35 
36  // Fields for base labels.
37  const char *desc;
38  void *userdata;
39 };
40 
42 typedef void (*dfsan_write_callback_t)(int fd, const void *buf, size_t count);
43 
47 
49 dfsan_label dfsan_create_label(const char *desc, void *userdata);
50 
52 void dfsan_set_label(dfsan_label label, void *addr, size_t size);
53 
56 void dfsan_add_label(dfsan_label label, void *addr, size_t size);
57 
65 
67 dfsan_label dfsan_read_label(const void *addr, size_t size);
68 
71 
74 
78 
80 size_t dfsan_get_label_count(void);
81 
86 void dfsan_flush(void);
87 
91 void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback);
92 
97 void dfsan_dump_labels(int fd);
98 
105 void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2,
106  size_t n, dfsan_label s1_label,
107  dfsan_label s2_label, dfsan_label n_label);
108 void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2,
109  size_t n, dfsan_label s1_label,
110  dfsan_label s2_label, dfsan_label n_label);
111 #ifdef __cplusplus
112 } // extern "C"
113 
114 template <typename T>
115 void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
116  dfsan_set_label(label, (void *)&data, sizeof(T));
117 }
118 
119 #endif
120 
121 #endif // DFSAN_INTERFACE_H
static __inline__ uint16_t
Definition: arm_mve.h:315
size_t dfsan_get_label_count(void)
Returns the number of labels allocated.
void dfsan_flush(void)
Flushes the DFSan shadow, i.e.
dfsan_label dfsan_create_label(const char *desc, void *userdata)
Creates and returns a base label with the given description and user data.
dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2)
Computes the union of l1 and l2, possibly creating a union label in the process.
void dfsan_set_label(dfsan_label label, void *addr, size_t size)
Sets the label for each address in [addr,addr+size) to label.
int dfsan_has_label(dfsan_label label, dfsan_label elem)
Returns whether the given label label contains the label elem.
uint16_t dfsan_label
void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2, size_t n, dfsan_label s1_label, dfsan_label s2_label, dfsan_label n_label)
void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback)
Sets a callback to be invoked on calls to write().
void(* dfsan_write_callback_t)(int fd, const void *buf, size_t count)
Signature of the callback argument to dfsan_set_write_callback().
void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2, size_t n, dfsan_label s1_label, dfsan_label s2_label, dfsan_label n_label)
Interceptor hooks.
dfsan_label dfsan_read_label(const void *addr, size_t size)
Retrieves the label associated with the data at the given address.
void dfsan_add_label(dfsan_label label, void *addr, size_t size)
Sets the label for each address in [addr,addr+size) to the union of the current label for that addres...
const struct dfsan_label_info * dfsan_get_label_info(dfsan_label label)
Retrieves a pointer to the dfsan_label_info struct for the given label.
dfsan_label dfsan_get_label(long data)
Retrieves the label associated with the given data.
void dfsan_dump_labels(int fd)
Writes the labels currently used by the program to the given file descriptor.
dfsan_label dfsan_has_label_with_desc(dfsan_label label, const char *desc)
If the given label label contains a label with the description desc, returns that label,...
Stores information associated with a specific label identifier.
const char * desc