Implement text_map_writable() for Darwin

Using the exact same mprotect()-based code as for Linux, which has been
moved into a new source file compiled for both platforms.