Hacker News new | ask | show | jobs
by shaded-enmity 1468 days ago
Turns out (1) works:

  #include <stdio.h>
  #include <stdlib.h>

  static void begin() __attribute__((constructor));

  void begin() {
    unsetenv("LD_PRELOAD");
  }
Build with:

  gcc -shared -fpie -o library.so library.c
Test:

  LD_PRELOAD=~/library.so env | grep LD_PRELOAD
1 comments

Usually guarded with an #ifndef DEBUG. Disallow LD_PRELOAD in Release builds