I think normally, you would allocate a single large (a multiple of page size) block for your code and manage the permissions on that using some wrapper functions.

Memory with rwx permissions is going back to the bad old days of self modifying code.