I'm working on SPARC support in lld. I've got a working diff against lld 4.0.0, and I'm working on moving the changes over into the current source tree. Here is a first diff that addresses one of the more fundamental issues I ran into.
On SPARC, .plt is both writeable and executable. The current way sections are sorted means that lld puts it after .data/.bss. but it really needs to be close to .test to make sure branches into .plt don't overflow. I'd argue that because .bss is supposed to come last on all architectures, we should change the default sort order such that writable and executable sections come before sections that are just writeable. read-only executable sections should still come after sections that are just read-only of course. This diff makes this change.
With this diff, the following tests fail:
lld :: ELF/amdgpu-globals.s lld :: ELF/gc-sections.s lld :: ELF/i386-tls-ie-shared.s lld :: ELF/relocation-size-shared.s lld :: ELF/relocation-size.s lld :: ELF/section-layout.s lld :: ELF/tls-i686.s
The ELF/section-layout.s test fails because it explicitly tests that writeable and executable sections come after sections that are just writeable. Once adjusted that tests will act as a regression test for this diff.
I think most of the other tests just accidentally include a executable and writeable section. I'm not sure about amdgpu-globals.s though as I'm not really familliar with the requirements of that architecture.
nit: RF_WRITE_EXEC is probably more natural order, as in rwx.