The MIPS GOT section has a number of local entries based on the number of pages needed for output sections referenced by GOT page relocations. The number is recorded in the DT_MIPS_LOCAL_GOTNO dynamic section tag. However, the dynamic tag is added before assignAddresses has been called, meaning that any section size used to calculate the value will not include size modifications caused by linker scripts, thunks, etc.
This change moves the calculation of DT_MIPS_LOCAL_GOTNO until writeTo, by which time the output section sizes have been finalized.
I have spun it off from D38361, because the behaviour is already broken.
Other targets might have dynamic table tags with the same value so we have to check Config->EMachine == EM_MIPS here.