This adds support for the --discard-locals flag, which acts similarly to --discard-all, except it only applies to compiler-generated symbols (i.e. symbols starting with .L in ELF).
I am not sure about COFF local symbols: those appear to also use .L in most cases, but also use just L in other cases, so for now I am just leaving it unimplemented there.
Fixes PR36160