When discarding local symbols with --discard-all or --discard-locals, the ones which are used in relocations should be preserved. LLD used the simplest approach and just ignored those switches when -r or --emit-relocs was specified.
The patch implements handling the --discard-* switches for the cases when relocations are kept by identifying used local symbols and allowing removing only unused ones. This makes the behavior of LLD compatible with GNU linkers.
So, when !gcSections and the symbol is local, it bow sets used to false,
though the previous code set it to true in this case.
Seems this doesn't break anything in the current implementation,
though I wonder if we might want to have config->copyRelocs involved in the condition.
It perhaps would be a bit cleaner way to work with this flag.
Also, perhaps it can be initialized in the constructor body now, since the condition is not trivial.
nit: You can probably use isLocal() instead of checking the binding field directly.