This patch isn't in a finished state, but I wanted some guidance on how to properly do the GOT parts. Right now it's hacked to just look for the TLSLD relocs. We're also going to run into an issue with GOT entries when we do global dynamic TLS. Each TLS symbol gets two entries, each with a different relocation.
I switched compareOutputSections to a numeric based compare because adding proper order for TLS to it over complicated the code.
It seems that we don't really have to pass the number to this function because the symbol should know that. If it's STT_TLS, we need two slots. Otherwise one. Can you remove the second parameter?