Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bukzor
Created December 18, 2011 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bukzor/1492306 to your computer and use it in GitHub Desktop.
Save bukzor/1492306 to your computer and use it in GitHub Desktop.
// Prerequisite: python2.7-dev
// Compile with: gcc -shared -fPIC -o liboverride.so override_pydict.c -ldl
// Run as: LD_PRELOAD=./liboverride.so python
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include "python2.7/Python.h"
PyObject* PyDict_New(void)
{
PyObject* (*orig_PyDict_New)(void) = dlsym(RTLD_NEXT, "PyDict_New");
printf("Calling PyDict_New\n");
return orig_PyDict_New();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment