TL;DR <i>when instantiating a process, constant external variables that are referenced in executables are forcefully relocated to a writable memory segment without warning</i><p>So my first reaction was to add a check to see that my constants are in fact mapped read-only.<p><pre><code> const int constant_int = 42;
</code></pre>
It'd be nice to validate this read-only property and refuse to run but while <i>mprotect()</i> will set the memory protections there seems to be no associated getter. How do you check this in a reasonably portably manner?