This looks ok, but it acts unconditionally. In comparison GAS requires the -mno-shared to generate these style .cpsetup expansions as the resulting code cannot be put in a shared library.
This should only be enabled with a new command line flag -mno-shared.
Comment here on that it's a specific GNU extension / optimization for N32, off by default as it cannot be used to generate libraries.
I'd like to come back to the -mshared implementation later if you're ok with that. This is partly because it's not the default case (at least not on our mips-mti-linux-gnu-gcc toolchain) and we don't have the relevant option yet, but it's mostly because we don't support %hi(%neg(%gp_rel(foo))) expressions properly for N32 at the moment (only one of the three relocs is emitted). Fixing that requires further changes to our MCFixups and the handling of this nested expression. This patch currently fixes just enough for me to fix the ELFCLASS bug (N32 should be ELFCLASS32 but is currently ELFCLASS64) in a way that allows it to have cpsetup.s check for a correct output instead of having to change it to another incorrect output.
Is that ok with you?