When the target of the TlsOffsetRel is non-preemptible we can write the offset directly into the GOT without needing a dynamic relocation. This is optional for dynamically linked executables but is required for static linking.
We used to rely on the GOTSection::writeTo member function to get the TLS offset of the symbol when writing the VA of the symbol. However in r288107 the GOTSection::writeTo was changed to only use relocations for writing values. Unfortunately we were missing the GOT relocation so all TLS offsets were being written as 0. This change adds the relocation to the GOT entry and a test case for non-0 offsets.
This was found as a result of investigating D31274
The new code is probably fine, but as a whole I think I don't fully understand this piece of code because it is entangled and complicated. What is this for?