PTR_MANGLEis an internal macro function of glibc. It is not automated by the compiler. You can duplicate the same thing in your applications, but you also have to do it manually; it works something like this:
uintptr_t xor_key; // needs to be initialized with random "key" before use
This may be completely different from the glibc implementation; I did not look at him for a long time and just wrote it from my head. The apparently useless use of the conditional operator is to force the resulting expression to be of the same type as the original pointer, so it can be used directly.
Please note that the operation is its own inversion; therefore, it PTR_MANGLEcan be used both for “encryption” and for “decryption”.
source
share