Code Monkey home page Code Monkey logo

spectre_memtools's Introduction

spectre_memtools

String and memory handling functions based around the Spectre misfeature.

Functions:

static inline void spectre_init();

Calculates accurate timing values for the rest of the spectre_* functions. This function is automatically called at the start of your program when compiled with GCC/clang but it's fine to call more than once.

char read_memory_byte(const void * const address);

The core spectre function; reads the value stored at address speculatively.

void *spectre_memcpy(void * restrict dest, void const * restrict src, size_t n);
void *spectre_memmove(void *dest, void *src, size_t n);
int spectre_memcmp(const void *buf1, const void *buf2, size_t count);
void *spectre_memchr(const void *ptr, int ch, size_t count);
void *spectre_memmem(const void * restrict haystack, size_t haystacklen, const void * restrict needle, size_t needlelen);
char *spectre_memccpy(void * restrict dest, const void * restrict src, int c, size_t count);
size_t spectre_strlen(const char *str);
size_t spectre_strnlen(const char *str, size_t max_len);
char *spectre_strcpy(char * restrict dest, const char * restrict src);
char *spectre_strncpy(char * restrict dest, const char * restrict src, size_t count);

These functions are equivalent to their non spectre_* counterparts except that all const arguments are accessed speculatively.

Notes

These functions will not trigger hardware watchpoints on const arguments; software watchpoints will prevent speculation and cause an endless loop.

Functions that write data are unreliable when compiled at or above -O2 on clang, meaning spectre_memmove the spectre_*cpy family.

spectre_memtools's People

Contributors

m1lkweed avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.