**Use case**

https://colab.research.google.com/drive/1wzYn59PA9EDyra6356a8rUpwd3zUX0Zt?usp=sharing

**Describe the solution you'd like**

There are multiple ways to prevent LD_PRELOAD:

- link statically with musl to prevent any chance for LD_PRELOAD working;
- add some flag to the binary like capabilities or setuid to also prevent LD_PRELOAD working;
- don't allow it with some env variable;
- implement our own dynamic loader.

Also possible workaround:

- check if LD_PRELOAD is set very early at program startup. If it is, reset it and exec ourself with the same argc, argv.
#if defined(__POPCNT__)
    fail = InstructionFail::POPCNT;
    {
        uint64_t a = 0;
        uint64_t b = 0;
        __asm__ volatile ("popcnt %1, %0" : "=r"(a) :"r"(b) :);
    }
#endif
#if defined(__AVX__)
    fail = InstructionFail::AVX;
    __asm__ volatile ("vaddpd %%ymm0, %%ymm0, %%ymm0" : : : "ymm0");
#endif
#if defined(__AVX2__)
    fail = InstructionFail::AVX2;
    __asm__ volatile ("vpabsw %%ymm0, %%ymm0" : : : "ymm0");
#endif
#if defined(__AVX512__)
    fail = InstructionFail::AVX512;
    __asm__ volatile ("vpabsw %%zmm0, %%zmm0" : : : "zmm0");
#endif
    fail = InstructionFail::NONE;
}
#define writeError(data) do \
    { \
        static_assert(__builtin_constant_p(data)); \
        if (!writeRetry(STDERR_FILENO, data, ARRAY_SIZE(data) - 1)) \
            _Exit(1); \
    } while (false)
void checkRequiredInstructions()