Linker assertion failures when loading large ELF objects
When building a package that uses the aeson library in `haskell.nix` I ran into some strange linker errors:
```
[ ghc-iserv-prof] discardCtrlC
[ ghc-iserv-prof] msg: LoadObj "/nix/store/ybwpbkxbnjlnqrbkacpf6syd829pf141-aeson-lib-aeson-2.2.3.0/lib/x86_64-linux-ghc-9.12.2-inplace/aeson-2.2.3.0-19a3l3RAuf6EIape1L9Qhw/HSaeson-2.2.3.0-19a3l3RAuf6EIape1L9Qhw.p_o"
[ ghc-iserv-prof] writing pipe: ()
[ ghc-iserv-prof] reading pipe...
[ ghc-iserv-prof] discardCtrlC
[ ghc-iserv-prof] msg: ResolveObjs
ghc-iserv-prof: internal error: ASSERTION FAILED: file rts/linker/InitFini.c, line 159
(GHC version 9.12.2 for x86_64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
This ELF object has more than 65535 sections, and crucially the section header string table is stored above index 65535. When run with linker tracing all the strings are incorrect.
The reason is that the ELF header only has 16 bit space for the section header string table section index, and we're not handling the overflow situation correctly (where the value in the header is 0xFFFF and the actual value is stored elsewhere).
I'll add an MR shortly.
issue