Can the GOT pointer switch between GOTs within a single function?
A function which references more than ((1<<16) / sizeof(void *))
external symbols must use more than one GOT.
That's a corner case that I wouldn't be surprised if it wasn't handled at
all -- ... switching GOTs in the middle of a function is complicated -- ...
alternatively the current GOT pointer can be used to offset against.
Either way rather painful. Then you need to track
backward branches to switch back as appropriate, etc., etc.
One way to handle the overflow is to put a vector of pointers to every GOT_i
at some fixed offset in each GOT:
GOT0: .addr GOT0, GOT1, GOT2, GOT3
...
GOT1: .addr GOT0, GOT1, GOT2, GOT3
...
GOT2: .addr GOT0, GOT1, GOT2, GOT3
...
GOT3: .addr GOT0, GOT1, GOT2, GOT3
...
Then you don't need to _switch_, you just suffer an indirection
(another load with delay slot) for outlanders. For a FETCH to GPR
the indirection can use the same register as the destination,
else use $AT as for a STORE. Yes, the compiler must be told
to generate such code.