When passing an --emit-relocs flag to lld, there seems to be a possibility for the output section to be NULL. This causes lld to crash which results in the executable not being generated. This patch works around this issue by simply checking if the output section exists and returns "" as the name if it doesn't. The check of the return value then prevents propagation of "" in other bits of the code.
I've inspected a number of resulting ELF files generated with this and it looks correct and it breaks no additional tests.
It seems like the problem here is that when this is called with .rela.eh_frame getRelocatedSection() returns an EhInputSection where ->getParent() returns null.
If I link the test file with ld.bfd it contains relocations so we should probably be emitting the same output and not just omit the relocations: